@anteros/core 0.0.2-alpha.0 → 0.0.2-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/database/file.ts CHANGED
@@ -10,13 +10,11 @@ async function syncFileCollections() {
10
10
  const fileCollections: FileCollection[] = []
11
11
  for (let tenant of cfg.tenants ?? []) {
12
12
  const TENANT_PATH = path.join(process.cwd(), tenant.dir)
13
- const FILES_PATH = path.join(TENANT_PATH, 'files')
14
- let exist = await fs.exists(FILES_PATH)
15
- if (!exist) continue;
16
- const isDirectory = await (await fs.stat(FILES_PATH)).isDirectory()
17
13
 
18
- if (isDirectory) {
19
- // Charger les fichiers *.file.ts
14
+ // Scan files/ directory
15
+ const FILES_PATH = path.join(TENANT_PATH, 'files')
16
+ const filesExist = await fs.exists(FILES_PATH).catch(() => false)
17
+ if (filesExist && (await fs.stat(FILES_PATH)).isDirectory()) {
20
18
  const globFiles = new Glob(path.join(FILES_PATH, '**/*.file.ts'))
21
19
  for await (let file of globFiles.scan('.')) {
22
20
  let fileModule = await import(file)
@@ -28,7 +26,7 @@ async function syncFileCollections() {
28
26
  }
29
27
  }
30
28
 
31
- // Charger aussi les fichiers *.model.ts avec _isFileCollection_
29
+ // Also scan *.model.ts in files/ with _isFileCollection_
32
30
  const globModels = new Glob(path.join(FILES_PATH, '**/*.model.ts'))
33
31
  for await (let file of globModels.scan('.')) {
34
32
  let fileModule = await import(file)
@@ -40,6 +38,22 @@ async function syncFileCollections() {
40
38
  }
41
39
  }
42
40
  }
41
+
42
+ // Also scan collections/ directory for *.file.ts
43
+ const COLLECTIONS_PATH = path.join(TENANT_PATH, 'collections')
44
+ const collectionsExist = await fs.exists(COLLECTIONS_PATH).catch(() => false)
45
+ if (collectionsExist && (await fs.stat(COLLECTIONS_PATH)).isDirectory()) {
46
+ const globFiles = new Glob(path.join(COLLECTIONS_PATH, '**/*.file.ts'))
47
+ for await (let file of globFiles.scan('.')) {
48
+ let fileModule = await import(file)
49
+ if (fileModule?.default?._isFileCollection_) {
50
+ fileCollections.push({
51
+ ...fileModule?.default,
52
+ _tenant_: tenant.id
53
+ })
54
+ }
55
+ }
56
+ }
43
57
  }
44
58
 
45
59
  cfg.fileCollections = fileCollections
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@anteros/core",
3
3
  "module": "index.ts",
4
- "version": "0.0.2-alpha.0",
4
+ "version": "0.0.2-alpha.2",
5
5
  "type": "module",
6
6
  "description": "Anteros Core",
7
7
  "private": false,
package/server/api.ts CHANGED
@@ -250,12 +250,10 @@ function initializeApi(app: Hono<{ Variables: HonoVariables }>) {
250
250
  payload: body?.payload,
251
251
  error: fn.error,
252
252
  jwt: func.jwt,
253
- req: {
254
- cookies: {
255
- delete: (name: string) => {
256
- cookie.deleteCookie(c, name)
257
- },
258
- }
253
+ cookies: {
254
+ delete: (name: string) => {
255
+ cookie.deleteCookie(c, name)
256
+ },
259
257
  }
260
258
  })
261
259
 
@@ -296,26 +294,24 @@ function initializeApi(app: Hono<{ Variables: HonoVariables }>) {
296
294
  payload: body?.payload,
297
295
  error: fn.error,
298
296
  jwt: func.jwt,
299
- req: {
300
- cookies: {
301
- set: (name: string, value: string, options?: {
302
- httpOnly?: boolean;
303
- secure?: boolean;
304
- maxAge?: number;
305
- path?: string;
306
- domain?: string;
307
- sameSite?: 'lax' | 'strict' | 'none';
308
- }) => {
309
- cookie.setCookie(c, name, value, options)
310
- },
311
- get: (name: string) => {
312
- return cookie.getCookie(c, name)
313
- },
314
- delete: (name: string) => {
315
- cookie.deleteCookie(c, name)
316
- },
317
-
318
- }
297
+ cookies: {
298
+ set: (name: string, value: string, options?: {
299
+ httpOnly?: boolean;
300
+ secure?: boolean;
301
+ maxAge?: number;
302
+ path?: string;
303
+ domain?: string;
304
+ sameSite?: 'lax' | 'strict' | 'none';
305
+ }) => {
306
+ cookie.setCookie(c, name, value, options)
307
+ },
308
+ get: (name: string) => {
309
+ return cookie.getCookie(c, name)
310
+ },
311
+ delete: (name: string) => {
312
+ cookie.deleteCookie(c, name)
313
+ },
314
+
319
315
  }
320
316
 
321
317
  })