@volcanicminds/backend 2.0.4 → 2.1.1
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/README.md +8 -7
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +160 -210
- package/dist/index.js.map +1 -1
- package/dist/lib/api/auth/controller/auth.d.ts +35 -0
- package/dist/lib/api/auth/controller/auth.d.ts.map +1 -0
- package/dist/lib/api/auth/controller/auth.js +245 -333
- package/dist/lib/api/auth/controller/auth.js.map +1 -1
- package/dist/lib/api/auth/routes.d.ts +90 -0
- package/dist/lib/api/auth/routes.d.ts.map +1 -0
- package/dist/lib/api/auth/routes.js +1 -2
- package/dist/lib/api/auth/routes.js.map +1 -1
- package/dist/lib/api/health/controller/health.d.ts +3 -0
- package/dist/lib/api/health/controller/health.d.ts.map +1 -0
- package/dist/lib/api/health/controller/health.js +1 -4
- package/dist/lib/api/health/controller/health.js.map +1 -1
- package/dist/lib/api/health/routes.d.ts +26 -0
- package/dist/lib/api/health/routes.d.ts.map +1 -0
- package/dist/lib/api/health/routes.js +1 -2
- package/dist/lib/api/health/routes.js.map +1 -1
- package/dist/lib/api/token/controller/token.d.ts +16 -0
- package/dist/lib/api/token/controller/token.d.ts.map +1 -0
- package/dist/lib/api/token/controller/token.js +69 -105
- package/dist/lib/api/token/controller/token.js.map +1 -1
- package/dist/lib/api/token/routes.d.ts +179 -0
- package/dist/lib/api/token/routes.d.ts.map +1 -0
- package/dist/lib/api/token/routes.js +1 -2
- package/dist/lib/api/token/routes.js.map +1 -1
- package/dist/lib/api/tool/controller/tool.d.ts +3 -0
- package/dist/lib/api/tool/controller/tool.d.ts.map +1 -0
- package/dist/lib/api/tool/controller/tool.js +8 -22
- package/dist/lib/api/tool/controller/tool.js.map +1 -1
- package/dist/lib/api/tool/routes.d.ts +26 -0
- package/dist/lib/api/tool/routes.d.ts.map +1 -0
- package/dist/lib/api/tool/routes.js +1 -2
- package/dist/lib/api/tool/routes.js.map +1 -1
- package/dist/lib/api/users/controller/user.d.ts +12 -0
- package/dist/lib/api/users/controller/user.d.ts.map +1 -0
- package/dist/lib/api/users/controller/user.js +59 -112
- package/dist/lib/api/users/controller/user.js.map +1 -1
- package/dist/lib/api/users/routes.d.ts +173 -0
- package/dist/lib/api/users/routes.d.ts.map +1 -0
- package/dist/lib/api/users/routes.js +1 -2
- package/dist/lib/api/users/routes.js.map +1 -1
- package/dist/lib/apollo/context.d.ts +6 -0
- package/dist/lib/apollo/context.d.ts.map +1 -0
- package/dist/lib/apollo/context.js +2 -16
- package/dist/lib/apollo/context.js.map +1 -1
- package/dist/lib/apollo/resolvers.d.ts +8 -0
- package/dist/lib/apollo/resolvers.d.ts.map +1 -0
- package/dist/lib/apollo/resolvers.js +1 -2
- package/dist/lib/apollo/resolvers.js.map +1 -1
- package/dist/lib/apollo/type-defs.d.ts +3 -0
- package/dist/lib/apollo/type-defs.d.ts.map +1 -0
- package/dist/lib/apollo/type-defs.js +1 -2
- package/dist/lib/apollo/type-defs.js.map +1 -1
- package/dist/lib/config/general.d.ts +12 -0
- package/dist/lib/config/general.d.ts.map +1 -0
- package/dist/lib/config/general.js +1 -2
- package/dist/lib/config/general.js.map +1 -1
- package/dist/lib/config/plugins.d.ts +25 -0
- package/dist/lib/config/plugins.d.ts.map +1 -0
- package/dist/lib/config/plugins.js +1 -2
- package/dist/lib/config/plugins.js.map +1 -1
- package/dist/lib/config/roles.d.ts +7 -0
- package/dist/lib/config/roles.d.ts.map +1 -0
- package/dist/lib/config/roles.js +1 -2
- package/dist/lib/config/roles.js.map +1 -1
- package/dist/lib/config/tracking.d.ts +10 -0
- package/dist/lib/config/tracking.d.ts.map +1 -0
- package/dist/lib/config/tracking.js +1 -2
- package/dist/lib/config/tracking.js.map +1 -1
- package/dist/lib/hooks/onError.d.ts +3 -0
- package/dist/lib/hooks/onError.d.ts.map +1 -0
- package/dist/lib/hooks/onError.js +2 -12
- package/dist/lib/hooks/onError.js.map +1 -1
- package/dist/lib/hooks/onRequest.d.ts +3 -0
- package/dist/lib/hooks/onRequest.d.ts.map +1 -0
- package/dist/lib/hooks/onRequest.js +24 -35
- package/dist/lib/hooks/onRequest.js.map +1 -1
- package/dist/lib/hooks/onResponse.d.ts +3 -0
- package/dist/lib/hooks/onResponse.d.ts.map +1 -0
- package/dist/lib/hooks/onResponse.js +2 -12
- package/dist/lib/hooks/onResponse.js.map +1 -1
- package/dist/lib/hooks/preHandler.d.ts +3 -0
- package/dist/lib/hooks/preHandler.d.ts.map +1 -0
- package/dist/lib/hooks/preHandler.js +3 -47
- package/dist/lib/hooks/preHandler.js.map +1 -1
- package/dist/lib/hooks/preSerialization.d.ts +3 -0
- package/dist/lib/hooks/preSerialization.d.ts.map +1 -0
- package/dist/lib/hooks/preSerialization.js +6 -53
- package/dist/lib/hooks/preSerialization.js.map +1 -1
- package/dist/lib/loader/general.d.ts +3 -0
- package/dist/lib/loader/general.d.ts.map +1 -0
- package/dist/lib/loader/general.js +15 -13
- package/dist/lib/loader/general.js.map +1 -1
- package/dist/lib/loader/hooks.d.ts +2 -0
- package/dist/lib/loader/hooks.d.ts.map +1 -0
- package/dist/lib/loader/hooks.js +19 -18
- package/dist/lib/loader/hooks.js.map +1 -1
- package/dist/lib/loader/plugins.d.ts +2 -0
- package/dist/lib/loader/plugins.d.ts.map +1 -0
- package/dist/lib/loader/plugins.js +11 -12
- package/dist/lib/loader/plugins.js.map +1 -1
- package/dist/lib/loader/roles.d.ts +3 -0
- package/dist/lib/loader/roles.d.ts.map +1 -0
- package/dist/lib/loader/roles.js +11 -12
- package/dist/lib/loader/roles.js.map +1 -1
- package/dist/lib/loader/router.d.ts +2 -0
- package/dist/lib/loader/router.d.ts.map +1 -0
- package/dist/lib/loader/router.js +111 -129
- package/dist/lib/loader/router.js.map +1 -1
- package/dist/lib/loader/schedules.d.ts +3 -0
- package/dist/lib/loader/schedules.d.ts.map +1 -0
- package/dist/lib/loader/schedules.js +18 -25
- package/dist/lib/loader/schedules.js.map +1 -1
- package/dist/lib/loader/schemas.d.ts +2 -0
- package/dist/lib/loader/schemas.d.ts.map +1 -0
- package/dist/lib/loader/schemas.js +26 -22
- package/dist/lib/loader/schemas.js.map +1 -1
- package/dist/lib/loader/tracking.d.ts +6 -0
- package/dist/lib/loader/tracking.d.ts.map +1 -0
- package/dist/lib/loader/tracking.js +17 -19
- package/dist/lib/loader/tracking.js.map +1 -1
- package/dist/lib/loader/translation.d.ts +2 -0
- package/dist/lib/loader/translation.d.ts.map +1 -0
- package/dist/lib/loader/translation.js +11 -10
- package/dist/lib/loader/translation.js.map +1 -1
- package/dist/lib/middleware/dispatchForgotPasswordLink.d.ts +3 -0
- package/dist/lib/middleware/dispatchForgotPasswordLink.d.ts.map +1 -0
- package/dist/lib/middleware/dispatchForgotPasswordLink.js +2 -16
- package/dist/lib/middleware/dispatchForgotPasswordLink.js.map +1 -1
- package/dist/lib/middleware/isAdmin.d.ts +3 -0
- package/dist/lib/middleware/isAdmin.d.ts.map +1 -0
- package/dist/lib/middleware/isAdmin.js +1 -4
- package/dist/lib/middleware/isAdmin.js.map +1 -1
- package/dist/lib/middleware/isAuthenticated.d.ts +3 -0
- package/dist/lib/middleware/isAuthenticated.d.ts.map +1 -0
- package/dist/lib/middleware/isAuthenticated.js +2 -6
- package/dist/lib/middleware/isAuthenticated.js.map +1 -1
- package/dist/lib/middleware/postAuth.d.ts +3 -0
- package/dist/lib/middleware/postAuth.d.ts.map +1 -0
- package/dist/lib/middleware/postAuth.js +2 -16
- package/dist/lib/middleware/postAuth.js.map +1 -1
- package/dist/lib/middleware/preAuth.d.ts +3 -0
- package/dist/lib/middleware/preAuth.d.ts.map +1 -0
- package/dist/lib/middleware/preAuth.js +1 -15
- package/dist/lib/middleware/preAuth.js.map +1 -1
- package/dist/lib/middleware/preForgotPasswordHandler.d.ts +3 -0
- package/dist/lib/middleware/preForgotPasswordHandler.d.ts.map +1 -0
- package/dist/lib/middleware/preForgotPasswordHandler.js +1 -15
- package/dist/lib/middleware/preForgotPasswordHandler.js.map +1 -1
- package/dist/lib/schedules/test.job.d.ts +4 -0
- package/dist/lib/schedules/test.job.d.ts.map +1 -0
- package/dist/lib/schedules/test.job.js +3 -18
- package/dist/lib/schedules/test.job.js.map +1 -1
- package/dist/lib/schemas/auth.d.ts +175 -0
- package/dist/lib/schemas/auth.d.ts.map +1 -0
- package/dist/lib/schemas/auth.js +9 -12
- package/dist/lib/schemas/auth.js.map +1 -1
- package/dist/lib/schemas/common.d.ts +81 -0
- package/dist/lib/schemas/common.d.ts.map +1 -0
- package/dist/lib/schemas/common.js +6 -9
- package/dist/lib/schemas/common.js.map +1 -1
- package/dist/lib/schemas/global.d.ts +29 -0
- package/dist/lib/schemas/global.d.ts.map +1 -0
- package/dist/lib/schemas/global.js +2 -5
- package/dist/lib/schemas/global.js.map +1 -1
- package/dist/lib/schemas/token.d.ts +68 -0
- package/dist/lib/schemas/token.d.ts.map +1 -0
- package/dist/lib/schemas/token.js +3 -6
- package/dist/lib/schemas/token.js.map +1 -1
- package/dist/lib/schemas/user.d.ts +120 -0
- package/dist/lib/schemas/user.d.ts.map +1 -0
- package/dist/lib/schemas/user.js +5 -8
- package/dist/lib/schemas/user.js.map +1 -1
- package/dist/lib/util/common.d.ts +5 -0
- package/dist/lib/util/common.d.ts.map +1 -0
- package/dist/lib/util/common.js +4 -8
- package/dist/lib/util/common.js.map +1 -1
- package/dist/lib/util/errors.d.ts +15 -0
- package/dist/lib/util/errors.d.ts.map +1 -0
- package/dist/lib/util/errors.js +7 -7
- package/dist/lib/util/errors.js.map +1 -1
- package/dist/lib/util/generate.d.ts +2 -0
- package/dist/lib/util/generate.d.ts.map +1 -0
- package/dist/lib/util/generate.js +2 -5
- package/dist/lib/util/generate.js.map +1 -1
- package/dist/lib/util/logger.d.ts +35 -0
- package/dist/lib/util/logger.d.ts.map +1 -0
- package/dist/lib/util/logger.js +8 -12
- package/dist/lib/util/logger.js.map +1 -1
- package/dist/lib/util/mark.d.ts +2 -0
- package/dist/lib/util/mark.d.ts.map +1 -0
- package/dist/lib/util/mark.js +2 -4
- package/dist/lib/util/mark.js.map +1 -1
- package/dist/lib/util/path.d.ts +2 -0
- package/dist/lib/util/path.d.ts.map +1 -0
- package/dist/lib/util/path.js +5 -5
- package/dist/lib/util/path.js.map +1 -1
- package/dist/lib/util/regexp.d.ts +12 -0
- package/dist/lib/util/regexp.d.ts.map +1 -0
- package/dist/lib/util/regexp.js +11 -14
- package/dist/lib/util/regexp.js.map +1 -1
- package/dist/lib/util/require.d.ts +3 -0
- package/dist/lib/util/require.d.ts.map +1 -0
- package/dist/lib/util/require.js +4 -0
- package/dist/lib/util/require.js.map +1 -0
- package/dist/lib/util/tracker.d.ts +4 -0
- package/dist/lib/util/tracker.d.ts.map +1 -0
- package/dist/lib/util/tracker.js +63 -86
- package/dist/lib/util/tracker.js.map +1 -1
- package/dist/lib/util/yn.d.ts +2 -0
- package/dist/lib/util/yn.d.ts.map +1 -0
- package/dist/lib/util/yn.js +1 -3
- package/dist/lib/util/yn.js.map +1 -1
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +1 -2
- package/dist/server.js.map +1 -1
- package/lib/api/auth/controller/auth.ts +1 -1
- package/lib/api/auth/routes.ts +1 -1
- package/lib/api/health/routes.ts +1 -1
- package/lib/api/token/routes.ts +1 -1
- package/lib/api/tool/routes.ts +1 -1
- package/lib/api/users/controller/user.ts +2 -2
- package/lib/api/users/routes.ts +1 -1
- package/lib/apollo/resolvers.ts +1 -1
- package/lib/config/general.ts +1 -3
- package/lib/config/plugins.ts +1 -3
- package/lib/config/roles.ts +1 -1
- package/lib/config/tracking.ts +1 -1
- package/lib/hooks/onError.ts +1 -1
- package/lib/hooks/onRequest.ts +8 -6
- package/lib/hooks/onResponse.ts +1 -1
- package/lib/hooks/preHandler.ts +2 -2
- package/lib/hooks/preSerialization.ts +2 -2
- package/lib/loader/general.ts +13 -9
- package/lib/loader/hooks.ts +15 -11
- package/lib/loader/plugins.ts +14 -10
- package/lib/loader/roles.ts +14 -9
- package/lib/loader/router.ts +106 -88
- package/lib/loader/schedules.ts +6 -6
- package/lib/loader/schemas.ts +27 -19
- package/lib/loader/tracking.ts +14 -9
- package/lib/loader/translation.ts +9 -14
- package/lib/schedules/test.job.ts +1 -1
- package/lib/util/common.ts +1 -1
- package/lib/util/generate.ts +1 -1
- package/lib/util/logger.ts +1 -1
- package/lib/util/mark.ts +1 -0
- package/lib/util/path.ts +6 -1
- package/lib/util/require.ts +3 -0
- package/lib/util/tracker.ts +1 -1
- package/package.json +24 -15
- package/.dockerignore +0 -6
- package/.mocharc.json +0 -3
- package/.nvmrc +0 -1
- package/.prettierignore +0 -5
- package/.prettierrc +0 -9
- package/DOCKER.md +0 -27
- package/Dockerfile +0 -24
- package/Dockerfile.prod +0 -33
- package/NPM.md +0 -24
- package/TODO.md +0 -14
- package/combine.js +0 -124
- package/dist/lib/locales/en.json +0 -12
- package/dist/lib/locales/it.json +0 -12
- package/dist/nodemon.json +0 -7
- package/dist/package-lock.json +0 -9787
- package/dist/package.json +0 -108
- package/dist/tsconfig.json +0 -32
- package/index.d.ts +0 -16
- package/index.ts +0 -410
- package/logo-dark.png +0 -0
- package/nodemon.json +0 -7
- package/server.ts +0 -5
- package/test/common/api.ts +0 -80
- package/test/common/bootstrap.ts +0 -33
- package/test/demo/demo.ts +0 -9
- package/test/demo/index.ts +0 -14
- package/test/e2e/index.ts +0 -14
- package/test/index.spec.ts +0 -20
- package/test/unit/index.ts +0 -14
- package/test/unit/semver.ts +0 -24
- package/test/unit/translation.ts +0 -77
- package/tsconfig.json +0 -40
- package/types/global.d.ts +0 -225
package/lib/loader/schemas.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { normalizePatterns } from '../util/path'
|
|
1
|
+
import { normalizePatterns } from '../util/path.js'
|
|
2
|
+
import { globSync } from 'glob'
|
|
3
|
+
import path from 'path'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
const path = require('path')
|
|
5
|
-
|
|
6
|
-
export function apply(server: any): void {
|
|
5
|
+
export async function apply(server: any): Promise<void> {
|
|
7
6
|
const [baseSchemaPath, customSchemaPath] = normalizePatterns(
|
|
8
7
|
['..', 'schemas', '*.{ts,js}'],
|
|
9
8
|
['src', 'schemas', '*.{ts,js}']
|
|
@@ -14,14 +13,19 @@ export function apply(server: any): void {
|
|
|
14
13
|
let schemaCount = 0
|
|
15
14
|
|
|
16
15
|
log.t && log.trace('Looking for custom schemas in ' + customSchemaPath)
|
|
17
|
-
|
|
16
|
+
const customFiles = globSync(customSchemaPath, { windowsPathsNoEscape: true })
|
|
17
|
+
|
|
18
|
+
for (const f of customFiles) {
|
|
19
|
+
if (f.endsWith('.d.ts')) continue
|
|
20
|
+
|
|
18
21
|
try {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
22
|
+
const schemaModule = await import(f)
|
|
23
|
+
const schemaClass = schemaModule.default || schemaModule
|
|
24
|
+
const schemaNames = Object.keys(schemaModule)
|
|
21
25
|
|
|
22
26
|
schemaNames.forEach((name) => {
|
|
23
|
-
const schema =
|
|
24
|
-
if (schema
|
|
27
|
+
const schema = schemaModule[name]
|
|
28
|
+
if (schema && typeof schema === 'object' && schema.$id) {
|
|
25
29
|
customSchemas.push(schema)
|
|
26
30
|
customSchemaIds.add(schema.$id)
|
|
27
31
|
}
|
|
@@ -29,7 +33,7 @@ export function apply(server: any): void {
|
|
|
29
33
|
} catch (e) {
|
|
30
34
|
log.w && log.warn(`Could not load custom schema file: ${f}`, e)
|
|
31
35
|
}
|
|
32
|
-
}
|
|
36
|
+
}
|
|
33
37
|
|
|
34
38
|
customSchemas.forEach((schema) => {
|
|
35
39
|
log.trace(`* Registering custom schema [${schema.$id}]`)
|
|
@@ -38,15 +42,19 @@ export function apply(server: any): void {
|
|
|
38
42
|
})
|
|
39
43
|
|
|
40
44
|
log.t && log.trace('Looking for base schemas in ' + baseSchemaPath)
|
|
41
|
-
|
|
45
|
+
const baseFiles = globSync(baseSchemaPath, { windowsPathsNoEscape: true })
|
|
46
|
+
|
|
47
|
+
for (const f of baseFiles) {
|
|
48
|
+
if (f.endsWith('.d.ts')) continue
|
|
49
|
+
|
|
42
50
|
try {
|
|
43
51
|
const schemaFileName = path.basename(f)
|
|
44
|
-
const
|
|
45
|
-
const schemaNames = Object.keys(
|
|
52
|
+
const schemaModule = await import(f)
|
|
53
|
+
const schemaNames = Object.keys(schemaModule)
|
|
46
54
|
|
|
47
55
|
schemaNames.forEach((name) => {
|
|
48
|
-
const schema =
|
|
49
|
-
if (schema
|
|
56
|
+
const schema = schemaModule[name]
|
|
57
|
+
if (schema && typeof schema === 'object' && schema.$id) {
|
|
50
58
|
if (customSchemaIds.has(schema.$id)) {
|
|
51
59
|
log.w &&
|
|
52
60
|
log.warn(
|
|
@@ -57,14 +65,14 @@ export function apply(server: any): void {
|
|
|
57
65
|
server.addSchema(schema)
|
|
58
66
|
schemaCount++
|
|
59
67
|
}
|
|
60
|
-
} else {
|
|
61
|
-
log.w && log.warn(`* Schema with no $id found in ${schemaFileName}, cannot be registered.`)
|
|
68
|
+
} else if (name !== 'default') {
|
|
69
|
+
log.w && log.warn(`* Schema with no $id found in ${schemaFileName} (export ${name}), cannot be registered.`)
|
|
62
70
|
}
|
|
63
71
|
})
|
|
64
72
|
} catch (e) {
|
|
65
73
|
log.w && log.warn(`Could not load base schema file: ${f}`, e)
|
|
66
74
|
}
|
|
67
|
-
}
|
|
75
|
+
}
|
|
68
76
|
|
|
69
77
|
log.d && log.debug(`Schemas loaded: ${schemaCount} referenceable by $ref`)
|
|
70
78
|
}
|
package/lib/loader/tracking.ts
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import { TrackChanges, TrackChangesList, Data } from '../../types/global'
|
|
2
|
-
import { normalizePatterns } from '../util/path'
|
|
3
|
-
|
|
1
|
+
import type { TrackChanges, TrackChangesList, Data } from '../../types/global.js'
|
|
2
|
+
import { normalizePatterns } from '../util/path.js'
|
|
3
|
+
import { globSync } from 'glob'
|
|
4
4
|
|
|
5
5
|
const METHODS = ['POST', 'PUT', 'DELETE']
|
|
6
6
|
|
|
7
|
-
export function load() {
|
|
7
|
+
export async function load() {
|
|
8
8
|
const trackChangesList: TrackChangesList = {}
|
|
9
9
|
let trackConfig: Data = {}
|
|
10
10
|
|
|
11
11
|
const patterns = normalizePatterns(['..', 'config', 'tracking.{ts,js}'], ['src', 'config', 'tracking.{ts,js}'])
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
for (const pattern of patterns) {
|
|
13
14
|
log.t && log.trace('Looking for ' + pattern)
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const files = globSync(pattern, { windowsPathsNoEscape: true })
|
|
16
|
+
|
|
17
|
+
for (const f of files) {
|
|
18
|
+
const module = await import(f)
|
|
19
|
+
const configTracking = module.default || module
|
|
20
|
+
|
|
16
21
|
const { config, changes } = configTracking || {}
|
|
17
22
|
const { enableAll = true, primaryKey = 'id', changeEntity = 'Change' } = config || {}
|
|
18
23
|
|
|
@@ -30,8 +35,8 @@ export function load() {
|
|
|
30
35
|
trackChangesList[code] = tc
|
|
31
36
|
}
|
|
32
37
|
})
|
|
33
|
-
}
|
|
34
|
-
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
35
40
|
|
|
36
41
|
const keys = Object.keys(trackChangesList) || []
|
|
37
42
|
log.d && log.debug(`Tracking changes loaded: ${keys?.length || 0}`)
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import { globSync } from 'glob'
|
|
3
|
+
import { I18n } from 'i18n'
|
|
4
|
+
import { fileURLToPath } from 'url'
|
|
5
|
+
import require from '../util/require.js'
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
8
|
+
const __dirname = path.dirname(__filename)
|
|
6
9
|
|
|
7
10
|
export function load(): any {
|
|
8
11
|
const i18n = new I18n({
|
|
@@ -25,7 +28,7 @@ export function load(): any {
|
|
|
25
28
|
|
|
26
29
|
const basePath = path.join(__dirname, '..', 'locales', '*.json').replaceAll('\\', '/')
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
globSync(basePath, { windowsPathsNoEscape: true }).forEach((f: string) => {
|
|
29
32
|
log.info('* Loading base dictionary %s', path.parse(f).base)
|
|
30
33
|
try {
|
|
31
34
|
const content = require(f)
|
|
@@ -37,7 +40,7 @@ export function load(): any {
|
|
|
37
40
|
|
|
38
41
|
const addPath = path.join(process.cwd(), 'src', 'locales', '*.json').replaceAll('\\', '/')
|
|
39
42
|
|
|
40
|
-
|
|
43
|
+
globSync(addPath, { windowsPathsNoEscape: true }).forEach((f: string) => {
|
|
41
44
|
log.info('* Loading additional dictionary %s', path.parse(f).base)
|
|
42
45
|
try {
|
|
43
46
|
const content = require(f)
|
|
@@ -48,14 +51,6 @@ export function load(): any {
|
|
|
48
51
|
})
|
|
49
52
|
|
|
50
53
|
i18n.setLocale(i18n.defaultLocale || 'en')
|
|
51
|
-
// let test1 = i18n.__('greeting.formal')
|
|
52
|
-
// let test2 = i18n.__('hello')
|
|
53
|
-
// let test3 = i18n.__('greeting.placeholder.formal', 'UGO')
|
|
54
|
-
// let test4 = i18n.__('greeting.placeholder.formalize:Buondì %s', 'UGO')
|
|
55
|
-
// let test5 = i18n.__('greeting.formal')
|
|
56
|
-
// let test6 = i18n.__({ phrase: 'greeting.formal', locale: 'it' })
|
|
57
|
-
// let test7 = i18n.__({ phrase: 'greeting.placeholder.formal', locale: 'it' }, 'UGO')
|
|
58
|
-
// i18n.setLocale(i18n.defaultLocale || 'en')
|
|
59
54
|
return i18n
|
|
60
55
|
}
|
|
61
56
|
|
package/lib/util/common.ts
CHANGED
package/lib/util/generate.ts
CHANGED
package/lib/util/logger.ts
CHANGED
package/lib/util/mark.ts
CHANGED
package/lib/util/path.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import { fileURLToPath } from 'url'
|
|
3
|
+
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
5
|
+
const __dirname = path.dirname(__filename)
|
|
6
|
+
|
|
2
7
|
export function normalizePatterns(path1: Array<string>, path2: Array<string>): Array<string> {
|
|
3
8
|
// replaceAll is needed for windows
|
|
4
9
|
return [
|
package/lib/util/tracker.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import dayjs from 'dayjs'
|
|
2
|
-
import { FastifyRequest, FastifyReply } from '../../types/global'
|
|
2
|
+
import type { FastifyRequest, FastifyReply } from '../../types/global.js'
|
|
3
3
|
|
|
4
4
|
export async function initialize(req: FastifyRequest, reply: FastifyReply) {
|
|
5
5
|
if (req.server['dataBaseManager'].isImplemented()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volcanicminds/backend",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"codename": "rome",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"description": "The volcanic (minds) backend",
|
|
@@ -27,23 +28,32 @@
|
|
|
27
28
|
"rate limit",
|
|
28
29
|
"jest"
|
|
29
30
|
],
|
|
30
|
-
"main": "dist/index",
|
|
31
|
-
"
|
|
31
|
+
"main": "dist/index.js",
|
|
32
|
+
"module": "dist/index.js",
|
|
33
|
+
"types": "dist/index.d.ts",
|
|
34
|
+
"sideEffects": false,
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"import": "./dist/index.js",
|
|
39
|
+
"require": "./dist/index.js"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"lib"
|
|
45
|
+
],
|
|
32
46
|
"scripts": {
|
|
33
|
-
"clean": "rm -rf dist
|
|
47
|
+
"clean": "rm -rf dist",
|
|
34
48
|
"prebuild": "npm run clean",
|
|
35
|
-
"build
|
|
36
|
-
"build:cjs": "tsc --target es2015 --module commonjs --outDir dist",
|
|
37
|
-
"build": "npm run build:esm && npm run build:cjs",
|
|
38
|
-
"compile": "npm run build",
|
|
49
|
+
"build": "tsc",
|
|
39
50
|
"preprod": "npm run build",
|
|
40
51
|
"prod": "cd dist && node server.js",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"dev": "nodemon --exec \"ts-node\" server.ts",
|
|
52
|
+
"start": "tsx server.ts",
|
|
53
|
+
"dev": "node --import tsx/esm --watch server.ts",
|
|
44
54
|
"test": "npm run test:full",
|
|
45
|
-
"test:full": "cross-env PORT=2231 NODE_ENV=memory BROWSER=false mocha ./test/index.spec.ts -t 100000",
|
|
46
|
-
"reset": "npm install && npm update && npm run
|
|
55
|
+
"test:full": "cross-env PORT=2231 NODE_ENV=memory BROWSER=false mocha --loader=tsx ./test/index.spec.ts -t 100000",
|
|
56
|
+
"reset": "npm install && npm update && npm run build",
|
|
47
57
|
"upgrade-deps": "npx npm-check-updates -u",
|
|
48
58
|
"combine": "node combine.js"
|
|
49
59
|
},
|
|
@@ -81,9 +91,8 @@
|
|
|
81
91
|
"cross-env": "^10.1.0",
|
|
82
92
|
"expect": "^30.2.0",
|
|
83
93
|
"mocha": "^11.7.5",
|
|
84
|
-
"nodemon": "^3.1.10",
|
|
85
94
|
"npm-upgrade": "^3.1.2",
|
|
86
|
-
"
|
|
95
|
+
"tsx": "^4.19.2",
|
|
87
96
|
"typescript": "^5.9.3"
|
|
88
97
|
},
|
|
89
98
|
"repository": {
|
package/.dockerignore
DELETED
package/.mocharc.json
DELETED
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
v24.11.0
|
package/.prettierignore
DELETED
package/.prettierrc
DELETED
package/DOCKER.md
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# Docker
|
|
2
|
-
|
|
3
|
-
try to use these to run the app in a docker node:16-alpine image:
|
|
4
|
-
|
|
5
|
-
```js
|
|
6
|
-
|
|
7
|
-
// easy
|
|
8
|
-
docker build -t volcanic-backend .
|
|
9
|
-
docker run -dp 2230:2230 -it volcanic-backend
|
|
10
|
-
|
|
11
|
-
// prod
|
|
12
|
-
docker build -f Dockerfile.prod -t volcanic-backend-prod .
|
|
13
|
-
docker run -dp 2230:2230 -it volcanic-backend-prod
|
|
14
|
-
|
|
15
|
-
// detached mode with autoremove when stopped
|
|
16
|
-
docker run --rm -dp 2230:2230 -it volcanic-backend
|
|
17
|
-
|
|
18
|
-
// attached mode with autoremove when stopped
|
|
19
|
-
docker run --rm -p 2230:2230 -it volcanic-backend
|
|
20
|
-
|
|
21
|
-
// remove
|
|
22
|
-
docker image rm volcanic-backend
|
|
23
|
-
|
|
24
|
-
// prune all
|
|
25
|
-
docker system prune --all
|
|
26
|
-
|
|
27
|
-
```
|
package/Dockerfile
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
FROM --platform=linux/amd64 node:18-alpine AS builder
|
|
2
|
-
|
|
3
|
-
# Create app directory
|
|
4
|
-
WORKDIR /usr/src/app
|
|
5
|
-
|
|
6
|
-
# Install app dependencies
|
|
7
|
-
COPY package*.json ./
|
|
8
|
-
COPY lib lib/
|
|
9
|
-
|
|
10
|
-
RUN npm install
|
|
11
|
-
|
|
12
|
-
# Bundle app source
|
|
13
|
-
COPY . .
|
|
14
|
-
|
|
15
|
-
FROM --platform=linux/amd64 node:18-alpine
|
|
16
|
-
LABEL version="0.1.0"
|
|
17
|
-
LABEL description="Volcanic Backend"
|
|
18
|
-
LABEL maintainer="Developers <developers@volcanicminds.com>"
|
|
19
|
-
|
|
20
|
-
WORKDIR /usr/src/app
|
|
21
|
-
COPY --from=builder /usr/src/app .
|
|
22
|
-
|
|
23
|
-
EXPOSE 2230
|
|
24
|
-
CMD [ "npm", "run start" ]
|
package/Dockerfile.prod
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
FROM --platform=linux/amd64 node:18-alpine AS builder
|
|
2
|
-
|
|
3
|
-
# Create app directory
|
|
4
|
-
WORKDIR /usr/src/app
|
|
5
|
-
|
|
6
|
-
# Install app dependencies
|
|
7
|
-
COPY package*.json ./
|
|
8
|
-
COPY lib lib/
|
|
9
|
-
|
|
10
|
-
RUN npm install \
|
|
11
|
-
--prefer-offline \
|
|
12
|
-
--non-interactive
|
|
13
|
-
|
|
14
|
-
# Bundle app source
|
|
15
|
-
COPY . .
|
|
16
|
-
|
|
17
|
-
RUN npm run compile && \
|
|
18
|
-
rm -rf node_modules && \
|
|
19
|
-
npm install \
|
|
20
|
-
--prefer-offline \
|
|
21
|
-
--non-interactive \
|
|
22
|
-
--production
|
|
23
|
-
|
|
24
|
-
FROM --platform=linux/amd64 node:18-alpine
|
|
25
|
-
LABEL version="0.1.0"
|
|
26
|
-
LABEL description="Volcanic Backend"
|
|
27
|
-
LABEL maintainer="Developers <developers@volcanicminds.com>"
|
|
28
|
-
|
|
29
|
-
WORKDIR /usr/src/app
|
|
30
|
-
COPY --from=builder /usr/src/app .
|
|
31
|
-
|
|
32
|
-
EXPOSE 2230
|
|
33
|
-
CMD [ "npm", "run server" ]
|
package/NPM.md
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# NPM
|
|
2
|
-
|
|
3
|
-
[more info](https://zellwk.com/blog/publish-to-npm/)
|
|
4
|
-
|
|
5
|
-
## how to publish
|
|
6
|
-
|
|
7
|
-
```ruby
|
|
8
|
-
npm install npm@latest -g
|
|
9
|
-
npm login
|
|
10
|
-
npm init --scope=volcanicminds
|
|
11
|
-
npm publish --access public
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## local linking
|
|
15
|
-
|
|
16
|
-
```ruby
|
|
17
|
-
npm link
|
|
18
|
-
npm link "@volcanicminds/backend"
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
```ruby
|
|
22
|
-
npm unlink
|
|
23
|
-
npm unlink "@volcanicminds/backend"
|
|
24
|
-
```
|
package/TODO.md
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# TODO
|
|
2
|
-
|
|
3
|
-
- add example / demo project (with @volcanicminds/backend & @volcanicminds/typeorm)
|
|
4
|
-
- validations (see typeorm)
|
|
5
|
-
- subscribers / hooks (Active Records: in separated files)
|
|
6
|
-
- api versioning
|
|
7
|
-
|
|
8
|
-
## Useful links
|
|
9
|
-
|
|
10
|
-
https://tutorialjavascript.altervista.org/moduli-typescript
|
|
11
|
-
https://swagger.io/specification/v2/#swaggerObject
|
|
12
|
-
https://github.com/fastify/fastify-swagger
|
|
13
|
-
https://www.fastify.io/docs/latest/Reference/Validation-and-Serialization/
|
|
14
|
-
https://json-schema.org/draft/2020-12/json-schema-validation.html#name-pattern
|
package/combine.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
|
|
4
|
-
const MAIN_DIRECTORY = './'
|
|
5
|
-
const INCLUDE_FILES = ['package.json', 'tsconfig.json', 'README.md', '.nvmrc', 'index.ts', 'index.d.ts']
|
|
6
|
-
const SUB_DIRECTORIES = ['lib', 'types']
|
|
7
|
-
const OUTPUT_FILE = 'OUTPUT.md'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Recursively collects .js and .ts files from a given directory.
|
|
11
|
-
*
|
|
12
|
-
* @param {string} directory - _The directory to scan recursively._
|
|
13
|
-
* @returns {Array<{ relativePath: string }>} - _List of file objects with relative paths._
|
|
14
|
-
*/
|
|
15
|
-
const getFilesFromDirectory = (directory) => {
|
|
16
|
-
let filesList = []
|
|
17
|
-
const items = fs.readdirSync(directory)
|
|
18
|
-
|
|
19
|
-
items.forEach((item) => {
|
|
20
|
-
const itemPath = path.join(directory, item)
|
|
21
|
-
const stats = fs.statSync(itemPath)
|
|
22
|
-
|
|
23
|
-
if (stats.isDirectory()) {
|
|
24
|
-
filesList = filesList.concat(getFilesFromDirectory(itemPath))
|
|
25
|
-
} else if (
|
|
26
|
-
item.endsWith('.html') ||
|
|
27
|
-
item.endsWith('.vue') ||
|
|
28
|
-
item.endsWith('.css') ||
|
|
29
|
-
item.endsWith('.json') ||
|
|
30
|
-
item.endsWith('.js') ||
|
|
31
|
-
item.endsWith('.ts') ||
|
|
32
|
-
item.endsWith('.md')
|
|
33
|
-
) {
|
|
34
|
-
filesList.push({ relativePath: path.relative(MAIN_DIRECTORY, itemPath) })
|
|
35
|
-
}
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
return filesList
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Retrieves files from the specified subdirectories.
|
|
43
|
-
*
|
|
44
|
-
* @returns {Object} - _Object containing individual subdirectory files and a combined list._
|
|
45
|
-
*/
|
|
46
|
-
const getFilesFromSubDirectories = () => {
|
|
47
|
-
const subDirectoryFiles = {}
|
|
48
|
-
let combinedFiles = []
|
|
49
|
-
|
|
50
|
-
SUB_DIRECTORIES.forEach((dir) => {
|
|
51
|
-
const files = getFilesFromDirectory(dir)
|
|
52
|
-
subDirectoryFiles[dir] = files
|
|
53
|
-
combinedFiles = combinedFiles.concat(files)
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
return { subDirectoryFiles, combinedFiles }
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async function generateMarkdown() {
|
|
60
|
-
const rootFiles = fs
|
|
61
|
-
.readdirSync(MAIN_DIRECTORY)
|
|
62
|
-
.filter(
|
|
63
|
-
(file) =>
|
|
64
|
-
file.endsWith('.html') ||
|
|
65
|
-
(file.endsWith('.ts') && file !== 'combine.ts') ||
|
|
66
|
-
(file.endsWith('.js') && file !== 'combine.js') ||
|
|
67
|
-
INCLUDE_FILES.includes(file)
|
|
68
|
-
)
|
|
69
|
-
.map((file) => ({ relativePath: file }))
|
|
70
|
-
|
|
71
|
-
const { subDirectoryFiles, combinedFiles } = getFilesFromSubDirectories()
|
|
72
|
-
const allFiles = [...rootFiles, ...combinedFiles]
|
|
73
|
-
const currentISOString = new Date().toISOString()
|
|
74
|
-
|
|
75
|
-
const markdownLines = []
|
|
76
|
-
markdownLines.push('# Full Project - Updated At ' + currentISOString, '')
|
|
77
|
-
markdownLines.push('Below are all the files, materials and documentation of the project to analyze.', '')
|
|
78
|
-
markdownLines.push('```bash')
|
|
79
|
-
markdownLines.push('./')
|
|
80
|
-
|
|
81
|
-
rootFiles.forEach((file) => {
|
|
82
|
-
markdownLines.push(`├── ${file.relativePath}`)
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
if (SUB_DIRECTORIES.length > 0) {
|
|
86
|
-
SUB_DIRECTORIES.forEach((dir) => {
|
|
87
|
-
markdownLines.push(`├── ${dir}`)
|
|
88
|
-
|
|
89
|
-
const sortedSubFiles = subDirectoryFiles[dir].sort((a, b) => a.relativePath.localeCompare(b.relativePath))
|
|
90
|
-
sortedSubFiles.forEach((file) => {
|
|
91
|
-
const displayPath = file.relativePath.replace(new RegExp(`^(${SUB_DIRECTORIES.join('|')})[\\\\/]`), '')
|
|
92
|
-
markdownLines.push(` ├── ${displayPath}`)
|
|
93
|
-
})
|
|
94
|
-
})
|
|
95
|
-
}
|
|
96
|
-
markdownLines.push('```', '')
|
|
97
|
-
|
|
98
|
-
markdownLines.push('## Source Files Index', '')
|
|
99
|
-
allFiles.forEach((file) => {
|
|
100
|
-
const filePath = file.relativePath
|
|
101
|
-
|
|
102
|
-
const slug = filePath.replace(/[\/.]/g, '-')
|
|
103
|
-
markdownLines.push(`- [${filePath}](#file-${slug})`)
|
|
104
|
-
})
|
|
105
|
-
markdownLines.push('')
|
|
106
|
-
|
|
107
|
-
for (const file of allFiles) {
|
|
108
|
-
const filePath = file.relativePath
|
|
109
|
-
const fullPath = path.join(MAIN_DIRECTORY, filePath)
|
|
110
|
-
|
|
111
|
-
const language = filePath.endsWith('.md') ? 'markdown' : filePath.endsWith('.ts') ? 'typescript' : 'javascript'
|
|
112
|
-
|
|
113
|
-
const fileContent = fs.readFileSync(fullPath, 'utf-8')
|
|
114
|
-
markdownLines.push(`## File: ${filePath}`, '')
|
|
115
|
-
markdownLines.push('```' + language)
|
|
116
|
-
markdownLines.push(fileContent)
|
|
117
|
-
markdownLines.push('```', '')
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
fs.writeFileSync(OUTPUT_FILE, markdownLines.join('\n'))
|
|
121
|
-
console.log(`Markdown file generated: ${OUTPUT_FILE}`)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
generateMarkdown()
|
package/dist/lib/locales/en.json
DELETED
package/dist/lib/locales/it.json
DELETED