@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 +21 -7
- package/package.json +1 -1
- package/server/api.ts +22 -26
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
|
-
|
|
19
|
-
|
|
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
|
-
//
|
|
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
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
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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
|
})
|