@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/dist/package.json
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@volcanicminds/backend",
|
|
3
|
-
"version": "2.0.4",
|
|
4
|
-
"codename": "rome",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"description": "The volcanic (minds) backend",
|
|
7
|
-
"keywords": [
|
|
8
|
-
"volcanic",
|
|
9
|
-
"open source",
|
|
10
|
-
"api",
|
|
11
|
-
"framework",
|
|
12
|
-
"backend",
|
|
13
|
-
"http",
|
|
14
|
-
"https",
|
|
15
|
-
"fastify",
|
|
16
|
-
"apollo",
|
|
17
|
-
"swagger",
|
|
18
|
-
"graphql",
|
|
19
|
-
"helmet",
|
|
20
|
-
"json",
|
|
21
|
-
"typescript",
|
|
22
|
-
"javascript",
|
|
23
|
-
"rest",
|
|
24
|
-
"restful",
|
|
25
|
-
"graphql",
|
|
26
|
-
"pino",
|
|
27
|
-
"rate limit",
|
|
28
|
-
"jest"
|
|
29
|
-
],
|
|
30
|
-
"main": "dist/index",
|
|
31
|
-
"typings": "dist/index",
|
|
32
|
-
"scripts": {
|
|
33
|
-
"clean": "rm -rf dist esm",
|
|
34
|
-
"prebuild": "npm run clean",
|
|
35
|
-
"build:esm": "tsc --target es2018 --outDir esm",
|
|
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",
|
|
39
|
-
"preprod": "npm run build",
|
|
40
|
-
"prod": "cd dist && node server.js",
|
|
41
|
-
"server": "cd dist && node server.js",
|
|
42
|
-
"start": "ts-node server.ts",
|
|
43
|
-
"dev": "nodemon --exec \"ts-node\" server.ts",
|
|
44
|
-
"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 compile",
|
|
47
|
-
"upgrade-deps": "npx npm-check-updates -u",
|
|
48
|
-
"combine": "node combine.js"
|
|
49
|
-
},
|
|
50
|
-
"dependencies": {
|
|
51
|
-
"@apollo/server": "^5.1.0",
|
|
52
|
-
"@as-integrations/fastify": "^3.1.0",
|
|
53
|
-
"@fastify/compress": "^8.1.0",
|
|
54
|
-
"@fastify/cors": "^11.1.0",
|
|
55
|
-
"@fastify/helmet": "^13.0.2",
|
|
56
|
-
"@fastify/jwt": "^10.0.0",
|
|
57
|
-
"@fastify/multipart": "^9.3.0",
|
|
58
|
-
"@fastify/rate-limit": "^10.3.0",
|
|
59
|
-
"@fastify/schedule": "^6.0.0",
|
|
60
|
-
"@fastify/swagger": "^9.5.2",
|
|
61
|
-
"@fastify/swagger-ui": "^5.2.3",
|
|
62
|
-
"@types/node": "^24.10.0",
|
|
63
|
-
"dayjs": "^1.11.19",
|
|
64
|
-
"dotenv": "^17.2.3",
|
|
65
|
-
"fastify": "^5.6.1",
|
|
66
|
-
"fastify-raw-body": "^5.0.0",
|
|
67
|
-
"glob": "^11.0.3",
|
|
68
|
-
"graphql": "^16.12.0",
|
|
69
|
-
"i18n": "^0.15.3",
|
|
70
|
-
"lodash": "^4.17.21",
|
|
71
|
-
"nanoid": "^5.1.6",
|
|
72
|
-
"object-sizeof": "^2.6.5",
|
|
73
|
-
"pino": "^10.1.0",
|
|
74
|
-
"pino-pretty": "^13.1.2",
|
|
75
|
-
"root-require": "^0.3.1",
|
|
76
|
-
"semver": "^7.7.3",
|
|
77
|
-
"toad-scheduler": "^3.1.0"
|
|
78
|
-
},
|
|
79
|
-
"devDependencies": {
|
|
80
|
-
"@types/mocha": "^10.0.10",
|
|
81
|
-
"cross-env": "^10.1.0",
|
|
82
|
-
"expect": "^30.2.0",
|
|
83
|
-
"mocha": "^11.7.5",
|
|
84
|
-
"nodemon": "^3.1.10",
|
|
85
|
-
"npm-upgrade": "^3.1.2",
|
|
86
|
-
"ts-node": "^10.9.2",
|
|
87
|
-
"typescript": "^5.9.3"
|
|
88
|
-
},
|
|
89
|
-
"repository": {
|
|
90
|
-
"type": "git",
|
|
91
|
-
"url": "git+https://github.com/volcanicminds/volcanic-backend.git"
|
|
92
|
-
},
|
|
93
|
-
"homepage": "https://volcanicminds.com",
|
|
94
|
-
"bugs": {
|
|
95
|
-
"url": "https://github.com/volcanicminds/volcanic-backend/issues"
|
|
96
|
-
},
|
|
97
|
-
"author": "Volcanic Minds <developers@volcanicminds.com> (https://volcanicminds.com)",
|
|
98
|
-
"maintainers": [
|
|
99
|
-
"Developers <developers@volcanicminds.com> (https://volcanicminds.com)"
|
|
100
|
-
],
|
|
101
|
-
"directories": {
|
|
102
|
-
"lib": "lib",
|
|
103
|
-
"test": "test"
|
|
104
|
-
},
|
|
105
|
-
"engines": {
|
|
106
|
-
"node": ">=24"
|
|
107
|
-
}
|
|
108
|
-
}
|
package/dist/tsconfig.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "ts-node/node16/tsconfig.json",
|
|
3
|
-
"ts-node": {
|
|
4
|
-
"files": true,
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
"module": "commonjs"
|
|
7
|
-
}
|
|
8
|
-
},
|
|
9
|
-
"compilerOptions": {
|
|
10
|
-
"module": "commonjs",
|
|
11
|
-
"moduleResolution": "node",
|
|
12
|
-
"declaration": false,
|
|
13
|
-
"noImplicitAny": false,
|
|
14
|
-
"noUnusedLocals": false,
|
|
15
|
-
"removeComments": true,
|
|
16
|
-
"noLib": false,
|
|
17
|
-
"emitDecoratorMetadata": true,
|
|
18
|
-
"experimentalDecorators": true,
|
|
19
|
-
"useUnknownInCatchVariables": false,
|
|
20
|
-
"target": "es6",
|
|
21
|
-
"sourceMap": true,
|
|
22
|
-
"allowJs": true,
|
|
23
|
-
"outDir": "dist",
|
|
24
|
-
"lib": ["es7"],
|
|
25
|
-
"resolveJsonModule": true,
|
|
26
|
-
"paths": {
|
|
27
|
-
"@types": ["./types"]
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"include": ["*.ts", "*.d.ts", "*.json", "lib/**/*", "lib/**/*.json", "types/*"],
|
|
31
|
-
"exclude": ["node_modules", "test/**/*"]
|
|
32
|
-
}
|
package/index.d.ts
DELETED
package/index.ts
DELETED
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import dotenv from 'dotenv'
|
|
4
|
-
dotenv.config()
|
|
5
|
-
|
|
6
|
-
import yn from './lib/util/yn'
|
|
7
|
-
import logger from './lib/util/logger'
|
|
8
|
-
import * as mark from './lib/util/mark'
|
|
9
|
-
import { TranslatedError } from './lib/util/errors'
|
|
10
|
-
import * as loaderPlugins from './lib/loader/plugins'
|
|
11
|
-
import * as loaderRoles from './lib/loader/roles'
|
|
12
|
-
import * as loaderRouter from './lib/loader/router'
|
|
13
|
-
import * as loaderHooks from './lib/loader/hooks'
|
|
14
|
-
import * as loaderSchemas from './lib/loader/schemas'
|
|
15
|
-
import * as loaderTracking from './lib/loader/tracking'
|
|
16
|
-
import * as loaderTranslation from './lib/loader/translation'
|
|
17
|
-
import * as loaderConfig from './lib/loader/general'
|
|
18
|
-
import * as loaderSchedules from './lib/loader/schedules'
|
|
19
|
-
|
|
20
|
-
import fastify, { FastifyInstance } from 'fastify'
|
|
21
|
-
import jwtValidator from '@fastify/jwt'
|
|
22
|
-
import swagger from '@fastify/swagger'
|
|
23
|
-
import swaggerUI from '@fastify/swagger-ui'
|
|
24
|
-
import { fastifySchedule } from '@fastify/schedule'
|
|
25
|
-
|
|
26
|
-
import cors from '@fastify/cors'
|
|
27
|
-
import helmet from '@fastify/helmet'
|
|
28
|
-
import compress from '@fastify/compress'
|
|
29
|
-
import rateLimit from '@fastify/rate-limit'
|
|
30
|
-
import multipart from '@fastify/multipart'
|
|
31
|
-
import rawBody from 'fastify-raw-body'
|
|
32
|
-
|
|
33
|
-
import { ApolloServer } from '@apollo/server'
|
|
34
|
-
import fastifyApollo, { fastifyApolloDrainPlugin } from '@as-integrations/fastify'
|
|
35
|
-
import { myContextFunction, MyContext } from './lib/apollo/context'
|
|
36
|
-
import resolvers from './lib/apollo/resolvers'
|
|
37
|
-
import typeDefs from './lib/apollo/type-defs'
|
|
38
|
-
import { UserManagement, TokenManagement, DataBaseManagement } from './types/global'
|
|
39
|
-
|
|
40
|
-
global.log = logger
|
|
41
|
-
|
|
42
|
-
async function attachApollo(server: FastifyInstance) {
|
|
43
|
-
log.info('Attach ApolloServer to Fastify')
|
|
44
|
-
const apollo = new ApolloServer<MyContext>({
|
|
45
|
-
typeDefs,
|
|
46
|
-
resolvers,
|
|
47
|
-
plugins: [fastifyApolloDrainPlugin(server)]
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
await apollo.start()
|
|
51
|
-
|
|
52
|
-
return apollo
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async function addApolloRouting(server: FastifyInstance, apollo: ApolloServer<MyContext> | null) {
|
|
56
|
-
if (apollo) {
|
|
57
|
-
log.trace('Add graphql routes')
|
|
58
|
-
await server.register(fastifyApollo(apollo), {
|
|
59
|
-
context: myContextFunction
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
// // OR
|
|
63
|
-
// server.post(
|
|
64
|
-
// '/graphql-alt',
|
|
65
|
-
// fastifyApolloHandler(apollo, {
|
|
66
|
-
// context: myContextFunction
|
|
67
|
-
// })
|
|
68
|
-
// )
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async function addFastifyRouting(server: FastifyInstance) {
|
|
73
|
-
log.trace('Add server routes')
|
|
74
|
-
|
|
75
|
-
loaderHooks.apply(server)
|
|
76
|
-
loaderSchemas.apply(server)
|
|
77
|
-
|
|
78
|
-
const routes = loaderRouter.load()
|
|
79
|
-
routes && loaderRouter.apply(server, routes)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async function addFastifySwagger(server: FastifyInstance) {
|
|
83
|
-
const { SWAGGER, SWAGGER_TITLE, SWAGGER_DESCRIPTION, SWAGGER_VERSION, SWAGGER_PREFIX_URL, SWAGGER_HOST } = process.env
|
|
84
|
-
|
|
85
|
-
const loadSwagger = yn(SWAGGER, false)
|
|
86
|
-
if (loadSwagger) {
|
|
87
|
-
log.trace('Add swagger plugin')
|
|
88
|
-
|
|
89
|
-
const fs = require('fs')
|
|
90
|
-
const contents = fs.readFileSync('logo-dark.png', { encoding: 'base64' })
|
|
91
|
-
|
|
92
|
-
await server.register(swagger, {
|
|
93
|
-
swagger: {
|
|
94
|
-
info: {
|
|
95
|
-
title: SWAGGER_TITLE || 'Volcanic API Documentation',
|
|
96
|
-
description: SWAGGER_DESCRIPTION || 'List of available APIs and schemes to use',
|
|
97
|
-
version: SWAGGER_VERSION || '0.0.1'
|
|
98
|
-
},
|
|
99
|
-
host: SWAGGER_HOST || 'localhost:2230',
|
|
100
|
-
schemes: ['https', 'http'],
|
|
101
|
-
consumes: ['application/json'],
|
|
102
|
-
produces: ['application/json']
|
|
103
|
-
},
|
|
104
|
-
openapi: {
|
|
105
|
-
info: {
|
|
106
|
-
title: SWAGGER_TITLE || 'Volcanic API Documentation',
|
|
107
|
-
description: SWAGGER_DESCRIPTION || 'List of available APIs and schemes to use',
|
|
108
|
-
version: SWAGGER_VERSION || '0.0.1'
|
|
109
|
-
},
|
|
110
|
-
servers: [
|
|
111
|
-
{
|
|
112
|
-
url: SWAGGER_HOST || 'http://localhost:2230'
|
|
113
|
-
}
|
|
114
|
-
],
|
|
115
|
-
components: {
|
|
116
|
-
securitySchemes: {
|
|
117
|
-
Bearer: {
|
|
118
|
-
type: 'http',
|
|
119
|
-
scheme: 'bearer'
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
await server.register(swaggerUI, {
|
|
127
|
-
routePrefix: SWAGGER_PREFIX_URL || '/api-docs',
|
|
128
|
-
uiConfig: {
|
|
129
|
-
docExpansion: 'list',
|
|
130
|
-
deepLinking: true,
|
|
131
|
-
defaultModelsExpandDepth: 1
|
|
132
|
-
},
|
|
133
|
-
logo: {
|
|
134
|
-
type: 'image/png',
|
|
135
|
-
content: Buffer.from(contents, 'base64')
|
|
136
|
-
},
|
|
137
|
-
theme: {
|
|
138
|
-
title: SWAGGER_TITLE
|
|
139
|
-
}
|
|
140
|
-
} as any)
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async function addFastifySchedule(server: FastifyInstance) {
|
|
145
|
-
const { scheduler = false } = global.config?.options || {}
|
|
146
|
-
if (scheduler) {
|
|
147
|
-
log.trace('Add scheduler plugin')
|
|
148
|
-
|
|
149
|
-
await server.register(fastifySchedule)
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const start = async (decorators) => {
|
|
154
|
-
const begin = new Date().getTime()
|
|
155
|
-
mark.print(logger)
|
|
156
|
-
|
|
157
|
-
global.config = loaderConfig.load()
|
|
158
|
-
global.roles = loaderRoles.load()
|
|
159
|
-
global.t = loaderTranslation.load()
|
|
160
|
-
|
|
161
|
-
const { tracking, trackingConfig } = loaderTracking.load()
|
|
162
|
-
global.tracking = tracking
|
|
163
|
-
global.trackingConfig = trackingConfig
|
|
164
|
-
|
|
165
|
-
const opts = yn(process.env.LOG_FASTIFY, false) ? { logger: { development: logger } } : { logger: true }
|
|
166
|
-
const server: FastifyInstance = fastify()
|
|
167
|
-
global.server = server
|
|
168
|
-
|
|
169
|
-
const { HOST: host = '0.0.0.0', PORT: port = '2230', GRAPHQL } = process.env
|
|
170
|
-
const {
|
|
171
|
-
JWT_SECRET = '',
|
|
172
|
-
JWT_EXPIRES_IN = '15d',
|
|
173
|
-
JWT_REFRESH = 'true',
|
|
174
|
-
JWT_REFRESH_SECRET = '',
|
|
175
|
-
JWT_REFRESH_EXPIRES_IN = '180d'
|
|
176
|
-
} = process.env
|
|
177
|
-
|
|
178
|
-
const loadRefreshJWT = yn(JWT_REFRESH, true)
|
|
179
|
-
const loadApollo = yn(GRAPHQL, false)
|
|
180
|
-
const plugins = loaderPlugins.load()
|
|
181
|
-
|
|
182
|
-
// Helmet is not usable with Apollo Server
|
|
183
|
-
plugins?.rawBody && (await server.register(rawBody, plugins.rawBody || {}))
|
|
184
|
-
!loadApollo && plugins?.helmet && (await server.register(helmet, plugins.helmet || {}))
|
|
185
|
-
|
|
186
|
-
if (plugins?.rateLimit) {
|
|
187
|
-
await server.register(rateLimit, plugins.rateLimit || {})
|
|
188
|
-
server.setNotFoundHandler(
|
|
189
|
-
{
|
|
190
|
-
preHandler: server.rateLimit({
|
|
191
|
-
max: 30,
|
|
192
|
-
timeWindow: 30000
|
|
193
|
-
})
|
|
194
|
-
},
|
|
195
|
-
function (req, reply) {
|
|
196
|
-
reply.code(404).send()
|
|
197
|
-
}
|
|
198
|
-
)
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
plugins?.multipart && (await server.register(multipart, plugins.multipart || {}))
|
|
202
|
-
plugins?.cors && (await server.register(cors, plugins.cors || {}))
|
|
203
|
-
plugins?.compress && (await server.register(compress, plugins.compress || {}))
|
|
204
|
-
|
|
205
|
-
// JWT Validator
|
|
206
|
-
log.t && log.trace(`Add JWT - expiresIn: ${JWT_EXPIRES_IN}`)
|
|
207
|
-
await server.register(jwtValidator, {
|
|
208
|
-
secret: JWT_SECRET,
|
|
209
|
-
sign: { expiresIn: JWT_EXPIRES_IN }
|
|
210
|
-
})
|
|
211
|
-
|
|
212
|
-
if (loadRefreshJWT) {
|
|
213
|
-
await server.register(jwtValidator, {
|
|
214
|
-
namespace: 'refreshToken',
|
|
215
|
-
secret: JWT_REFRESH_SECRET || JWT_SECRET,
|
|
216
|
-
sign: { expiresIn: JWT_REFRESH_EXPIRES_IN }
|
|
217
|
-
})
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const apollo = loadApollo ? await attachApollo(server) : null
|
|
221
|
-
await addFastifySwagger(server)
|
|
222
|
-
await addApolloRouting(server, apollo)
|
|
223
|
-
await addFastifyRouting(server)
|
|
224
|
-
await addFastifySchedule(server)
|
|
225
|
-
|
|
226
|
-
const schedules = loaderSchedules.load()
|
|
227
|
-
|
|
228
|
-
// defaults
|
|
229
|
-
decorators = {
|
|
230
|
-
userManager: {
|
|
231
|
-
isImplemented() {
|
|
232
|
-
return false
|
|
233
|
-
},
|
|
234
|
-
isValidUser(data: any) {
|
|
235
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
236
|
-
},
|
|
237
|
-
createUser(data: any) {
|
|
238
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
239
|
-
},
|
|
240
|
-
deleteUser(data: any) {
|
|
241
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
242
|
-
},
|
|
243
|
-
resetExternalId(data: any) {
|
|
244
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
245
|
-
},
|
|
246
|
-
updateUserById(id: string, user: any) {
|
|
247
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
248
|
-
},
|
|
249
|
-
retrieveUserById(id: string) {
|
|
250
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
251
|
-
},
|
|
252
|
-
retrieveUserByEmail(email: string) {
|
|
253
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
254
|
-
},
|
|
255
|
-
retrieveUserByConfirmationToken(code: string) {
|
|
256
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
257
|
-
},
|
|
258
|
-
retrieveUserByResetPasswordToken(code: string) {
|
|
259
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
260
|
-
},
|
|
261
|
-
retrieveUserByUsername(username: string) {
|
|
262
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
263
|
-
},
|
|
264
|
-
retrieveUserByExternalId(externalId: string) {
|
|
265
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
266
|
-
},
|
|
267
|
-
retrieveUserByPassword(email: string, password: string) {
|
|
268
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
269
|
-
},
|
|
270
|
-
changePassword(email: string, password: string, oldPassword: string) {
|
|
271
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
272
|
-
},
|
|
273
|
-
forgotPassword(email: string) {
|
|
274
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
275
|
-
},
|
|
276
|
-
userConfirmation(user: any) {
|
|
277
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
278
|
-
},
|
|
279
|
-
resetPassword(user: any, password: string) {
|
|
280
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
281
|
-
},
|
|
282
|
-
blockUserById(id: string, reason: string) {
|
|
283
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
284
|
-
},
|
|
285
|
-
unblockUserById(data: any) {
|
|
286
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
287
|
-
},
|
|
288
|
-
countQuery(data: any) {
|
|
289
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
290
|
-
},
|
|
291
|
-
findQuery(data: any) {
|
|
292
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
293
|
-
},
|
|
294
|
-
disableUserById(id: string) {
|
|
295
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
296
|
-
}
|
|
297
|
-
} as UserManagement,
|
|
298
|
-
tokenManager: {
|
|
299
|
-
isImplemented() {
|
|
300
|
-
return false
|
|
301
|
-
},
|
|
302
|
-
isValidToken(data: any) {
|
|
303
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
304
|
-
},
|
|
305
|
-
createToken(data: any) {
|
|
306
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
307
|
-
},
|
|
308
|
-
resetExternalId(id: string) {
|
|
309
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
310
|
-
},
|
|
311
|
-
updateTokenById(id: string, token: any) {
|
|
312
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
313
|
-
},
|
|
314
|
-
retrieveTokenById(id: string) {
|
|
315
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
316
|
-
},
|
|
317
|
-
retrieveTokenByExternalId(id: string) {
|
|
318
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
319
|
-
},
|
|
320
|
-
blockTokenById(id: string, reason: string) {
|
|
321
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
322
|
-
},
|
|
323
|
-
unblockTokenById(id: string) {
|
|
324
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
325
|
-
},
|
|
326
|
-
countQuery(data: any) {
|
|
327
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
328
|
-
},
|
|
329
|
-
findQuery(data: any) {
|
|
330
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
331
|
-
},
|
|
332
|
-
removeTokenById(id: string) {
|
|
333
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
334
|
-
}
|
|
335
|
-
} as TokenManagement,
|
|
336
|
-
dataBaseManager: {
|
|
337
|
-
isImplemented() {
|
|
338
|
-
return false
|
|
339
|
-
},
|
|
340
|
-
synchronizeSchemas() {
|
|
341
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
342
|
-
},
|
|
343
|
-
retrieveBy(entityName, entityId) {
|
|
344
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
345
|
-
},
|
|
346
|
-
addChange(entityName, entityId, status, userId, contents, changeEntity) {
|
|
347
|
-
throw new Error('Not implemented. You need to define the specific decorator (manager).')
|
|
348
|
-
}
|
|
349
|
-
} as DataBaseManagement,
|
|
350
|
-
...decorators
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
await Promise.all(
|
|
354
|
-
Object.keys(decorators || {}).map(async (key) => {
|
|
355
|
-
await server.decorate(key, decorators[key])
|
|
356
|
-
})
|
|
357
|
-
)
|
|
358
|
-
|
|
359
|
-
await server
|
|
360
|
-
.listen({
|
|
361
|
-
port: Number(port),
|
|
362
|
-
host: host
|
|
363
|
-
})
|
|
364
|
-
.then((address) => {
|
|
365
|
-
const elapsed = (new Date().getTime() - begin) / 100
|
|
366
|
-
log.info(`All stuff loaded in ${elapsed} sec`)
|
|
367
|
-
log.info(`Server ready 🚀 at ${address}`)
|
|
368
|
-
|
|
369
|
-
const loadSwagger = yn(process.env.SWAGGER, false)
|
|
370
|
-
loadSwagger && log.info(`Swagger ready ✨ at ${address}${process.env.SWAGGER_PREFIX_URL || '/api-docs'}`)
|
|
371
|
-
})
|
|
372
|
-
|
|
373
|
-
// Ok, it's time to start the scheduler jobs
|
|
374
|
-
await loaderSchedules.start(server, schedules)
|
|
375
|
-
return server
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
export {
|
|
379
|
-
global,
|
|
380
|
-
FastifyReply,
|
|
381
|
-
FastifyRequest,
|
|
382
|
-
AuthenticatedUser,
|
|
383
|
-
AuthenticatedToken,
|
|
384
|
-
Role,
|
|
385
|
-
Data,
|
|
386
|
-
Roles,
|
|
387
|
-
Route,
|
|
388
|
-
RouteConfig,
|
|
389
|
-
ConfiguredRoute,
|
|
390
|
-
UserManagement,
|
|
391
|
-
TokenManagement,
|
|
392
|
-
DataBaseManagement,
|
|
393
|
-
JobSchedule
|
|
394
|
-
} from './types/global'
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* These export configurations enable JS and TS developers
|
|
398
|
-
* to consumer BE in whatever way best suits their needs.
|
|
399
|
-
* Some examples of supported import syntax includes:
|
|
400
|
-
* - `const server = require('@volcanicminds/backend')`
|
|
401
|
-
* - `const { server } = require('@volcanicminds/backend')`
|
|
402
|
-
* - `import * as Server from '@volcanicminds/backend'`
|
|
403
|
-
* - `import { server, TSC_definition } from '@volcanicminds/backend'`
|
|
404
|
-
* - `import server from '@volcanicminds/backend'`
|
|
405
|
-
* - `import server, { TSC_definition } from '@volcanicminds/backend'`
|
|
406
|
-
*/
|
|
407
|
-
export { yn, start, TranslatedError }
|
|
408
|
-
module.exports = { yn, start, TranslatedError }
|
|
409
|
-
module.exports.server = { yn, start, TranslatedError }
|
|
410
|
-
module.exports.default = { yn, start, TranslatedError }
|
package/logo-dark.png
DELETED
|
Binary file
|
package/nodemon.json
DELETED
package/server.ts
DELETED
package/test/common/api.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
const axios = require('axios')
|
|
2
|
-
const http = axios.create({ baseURL: `http://0.0.0.0:${process.env.PORT?.replace(/\\n/gm, '\n') || 2231}/` })
|
|
3
|
-
|
|
4
|
-
import { DEFAULT_ADMIN_EMAIL, DEFAULT_ADMIN_PASSWORD } from '../common/bootstrap'
|
|
5
|
-
|
|
6
|
-
export async function login(email = DEFAULT_ADMIN_EMAIL, password = DEFAULT_ADMIN_PASSWORD) {
|
|
7
|
-
try {
|
|
8
|
-
delete http.defaults.headers.common.Authorization
|
|
9
|
-
const { data } = await http.post('/auth/login', {
|
|
10
|
-
email,
|
|
11
|
-
password
|
|
12
|
-
})
|
|
13
|
-
http.defaults.headers.common['Authorization'] = `Bearer ${data.token}`
|
|
14
|
-
return data
|
|
15
|
-
} catch (err) {
|
|
16
|
-
console.log(err)
|
|
17
|
-
throw err
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export async function logout() {
|
|
22
|
-
try {
|
|
23
|
-
delete http.defaults.headers.common.Authorization
|
|
24
|
-
} catch (err) {
|
|
25
|
-
throw err
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export async function get(...args) {
|
|
30
|
-
try {
|
|
31
|
-
const { data } = await http.get(...args)
|
|
32
|
-
return data
|
|
33
|
-
} catch (err) {
|
|
34
|
-
throw err
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export async function get_with_headers(...args) {
|
|
39
|
-
try {
|
|
40
|
-
const { data, headers } = await http.get(...args)
|
|
41
|
-
return { data, headers }
|
|
42
|
-
} catch (err) {
|
|
43
|
-
throw err
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export async function post(...args) {
|
|
48
|
-
try {
|
|
49
|
-
const { data } = await http.post(...args)
|
|
50
|
-
return data
|
|
51
|
-
} catch (err) {
|
|
52
|
-
throw err
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export async function put(...args) {
|
|
57
|
-
try {
|
|
58
|
-
const { data } = await http.put(...args)
|
|
59
|
-
return data
|
|
60
|
-
} catch (err) {
|
|
61
|
-
throw err
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export async function del(...args) {
|
|
66
|
-
try {
|
|
67
|
-
const { data } = await http.delete(...args)
|
|
68
|
-
return data
|
|
69
|
-
} catch (err) {
|
|
70
|
-
throw err
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function toQueryString(data) {
|
|
75
|
-
let qs = ''
|
|
76
|
-
Object.keys(data).map((k) => {
|
|
77
|
-
qs += `&${k}=${data[k]}`
|
|
78
|
-
})
|
|
79
|
-
return qs.slice(1).replace(' ', '%20')
|
|
80
|
-
}
|
package/test/common/bootstrap.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const { start: startServer } = require('../../index')
|
|
2
|
-
|
|
3
|
-
export const DEFAULT_ADMIN_EMAIL = 'admin@user.com'
|
|
4
|
-
export const DEFAULT_ADMIN_PASSWORD = '71iD$k%3X#m4'
|
|
5
|
-
export const COMPANY2_SUPERUSER_EMAIL = 'user@volcanicminds.ai'
|
|
6
|
-
export const COMPANY2_SUPERUSER_PASSWORD = '44O$^yWqn@R4'
|
|
7
|
-
|
|
8
|
-
let server: any
|
|
9
|
-
|
|
10
|
-
export async function startUp() {
|
|
11
|
-
try {
|
|
12
|
-
global.log.level = 'warn'
|
|
13
|
-
server = await startServer()
|
|
14
|
-
} catch (err) {
|
|
15
|
-
console.log(err)
|
|
16
|
-
throw err
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export async function tearDown() {
|
|
21
|
-
await server.close()
|
|
22
|
-
process.exit(0)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function buildTasks() {
|
|
26
|
-
const taskToSkip = (process.env.MOCHA_SKIP_TASK || '').toLowerCase().split(',')
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
demo: !taskToSkip.includes('demo'),
|
|
30
|
-
unit: !taskToSkip.includes('unit'),
|
|
31
|
-
e2e: !taskToSkip.includes('e2e')
|
|
32
|
-
}
|
|
33
|
-
}
|