@dismissible/nestjs-api 0.0.2-canary.585db17.0
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/config/.env.yaml +41 -0
- package/jest.config.ts +35 -0
- package/jest.e2e-config.ts +13 -0
- package/nest-cli.json +16 -0
- package/package.json +58 -0
- package/project.json +94 -0
- package/scripts/performance-test.config.json +29 -0
- package/scripts/performance-test.ts +845 -0
- package/src/app-test.factory.ts +39 -0
- package/src/app.module.ts +60 -0
- package/src/app.setup.ts +52 -0
- package/src/bootstrap.ts +29 -0
- package/src/config/app.config.spec.ts +117 -0
- package/src/config/app.config.ts +20 -0
- package/src/config/config.module.spec.ts +94 -0
- package/src/config/config.module.ts +50 -0
- package/src/config/default-app.config.spec.ts +74 -0
- package/src/config/default-app.config.ts +24 -0
- package/src/config/index.ts +2 -0
- package/src/cors/cors.config.spec.ts +162 -0
- package/src/cors/cors.config.ts +37 -0
- package/src/cors/index.ts +1 -0
- package/src/health/health.controller.spec.ts +24 -0
- package/src/health/health.controller.ts +16 -0
- package/src/health/health.module.ts +9 -0
- package/src/health/index.ts +2 -0
- package/src/helmet/helmet.config.spec.ts +197 -0
- package/src/helmet/helmet.config.ts +60 -0
- package/src/helmet/index.ts +1 -0
- package/src/index.ts +5 -0
- package/src/main.ts +3 -0
- package/src/server/index.ts +1 -0
- package/src/server/server.config.spec.ts +65 -0
- package/src/server/server.config.ts +8 -0
- package/src/swagger/index.ts +2 -0
- package/src/swagger/swagger.config.spec.ts +113 -0
- package/src/swagger/swagger.config.ts +12 -0
- package/src/swagger/swagger.factory.spec.ts +125 -0
- package/src/swagger/swagger.factory.ts +24 -0
- package/src/validation/index.ts +1 -0
- package/src/validation/validation.config.ts +47 -0
- package/test/config/.env.yaml +23 -0
- package/test/config-jwt-auth/.env.yaml +26 -0
- package/test/dismiss.e2e-spec.ts +61 -0
- package/test/full-cycle.e2e-spec.ts +55 -0
- package/test/get-or-create.e2e-spec.ts +51 -0
- package/test/jwt-auth.e2e-spec.ts +335 -0
- package/test/restore.e2e-spec.ts +61 -0
- package/tsconfig.app.json +13 -0
- package/tsconfig.e2e.json +12 -0
- package/tsconfig.json +13 -0
- package/tsconfig.spec.json +12 -0
package/config/.env.yaml
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
server:
|
|
2
|
+
port: ${DISMISSIBLE_PORT:-3001}
|
|
3
|
+
|
|
4
|
+
swagger:
|
|
5
|
+
enabled: ${DISMISSIBLE_SWAGGER_ENABLED:-true}
|
|
6
|
+
|
|
7
|
+
helmet:
|
|
8
|
+
enabled: ${DISMISSIBLE_HELMET_ENABLED:-true}
|
|
9
|
+
contentSecurityPolicy: ${DISMISSIBLE_HELMET_CSP:-false}
|
|
10
|
+
crossOriginEmbedderPolicy: ${DISMISSIBLE_HELMET_COEP:-false}
|
|
11
|
+
hstsMaxAge: ${DISMISSIBLE_HELMET_HSTS_MAX_AGE:-31536000}
|
|
12
|
+
hstsIncludeSubDomains: ${DISMISSIBLE_HELMET_HSTS_INCLUDE_SUBDOMAINS:-true}
|
|
13
|
+
hstsPreload: ${DISMISSIBLE_HELMET_HSTS_PRELOAD:-false}
|
|
14
|
+
|
|
15
|
+
cors:
|
|
16
|
+
enabled: ${DISMISSIBLE_CORS_ENABLED:-true}
|
|
17
|
+
origins: ${DISMISSIBLE_CORS_ORIGINS:-http://localhost:3001,http://localhost:5173}
|
|
18
|
+
methods: ${DISMISSIBLE_CORS_METHODS:-GET,POST,DELETE,OPTIONS}
|
|
19
|
+
allowedHeaders: ${DISMISSIBLE_CORS_ALLOWED_HEADERS:-Content-Type,Authorization,x-request-id}
|
|
20
|
+
credentials: ${DISMISSIBLE_CORS_CREDENTIALS:-true}
|
|
21
|
+
maxAge: ${DISMISSIBLE_CORS_MAX_AGE:-86400}
|
|
22
|
+
|
|
23
|
+
db:
|
|
24
|
+
connectionString: ${DISMISSIBLE_POSTGRES_STORAGE_CONNECTION_STRING:-postgresql://postgres:postgres@localhost:5432/dismissible}
|
|
25
|
+
|
|
26
|
+
jwtAuth:
|
|
27
|
+
enabled: ${DISMISSIBLE_JWT_AUTH_ENABLED:-false}
|
|
28
|
+
wellKnownUrl: ${DISMISSIBLE_JWT_AUTH_WELL_KNOWN_URL:-}
|
|
29
|
+
issuer: ${DISMISSIBLE_JWT_AUTH_ISSUER:-}
|
|
30
|
+
audience: ${DISMISSIBLE_JWT_AUTH_AUDIENCE:-}
|
|
31
|
+
algorithms:
|
|
32
|
+
- ${DISMISSIBLE_JWT_AUTH_ALGORITHMS:-RS256}
|
|
33
|
+
jwksCacheDuration: ${DISMISSIBLE_JWT_AUTH_JWKS_CACHE_DURATION:-600000}
|
|
34
|
+
requestTimeout: ${DISMISSIBLE_JWT_AUTH_REQUEST_TIMEOUT:-30000}
|
|
35
|
+
priority: ${DISMISSIBLE_JWT_AUTH_PRIORITY:--100}
|
|
36
|
+
|
|
37
|
+
validation:
|
|
38
|
+
disableErrorMessages: ${DISMISSIBLE_VALIDATION_DISABLE_ERROR_MESSAGES:-true}
|
|
39
|
+
whitelist: ${DISMISSIBLE_VALIDATION_WHITELIST:-true}
|
|
40
|
+
forbidNonWhitelisted: ${DISMISSIBLE_VALIDATION_FORBID_NON_WHITELISTED:-true}
|
|
41
|
+
transform: ${DISMISSIBLE_VALIDATION_TRANSFORM:-true}
|
package/jest.config.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
displayName: 'api',
|
|
3
|
+
preset: '../jest.preset.js',
|
|
4
|
+
testEnvironment: 'node',
|
|
5
|
+
transform: {
|
|
6
|
+
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
|
|
7
|
+
},
|
|
8
|
+
moduleFileExtensions: ['ts', 'js', 'html'],
|
|
9
|
+
coverageDirectory: '../coverage/api',
|
|
10
|
+
testMatch: ['**/*.spec.ts'],
|
|
11
|
+
testPathIgnorePatterns: ['\\.e2e-spec\\.ts$'],
|
|
12
|
+
transformIgnorePatterns: ['node_modules/(?!(nest-typed-config|uuid)/)'],
|
|
13
|
+
collectCoverageFrom: [
|
|
14
|
+
'src/**/*.ts',
|
|
15
|
+
'!src/**/*.spec.ts',
|
|
16
|
+
'!src/**/*.e2e-spec.ts',
|
|
17
|
+
'!src/**/*.interface.ts',
|
|
18
|
+
'!src/**/*.dto.ts',
|
|
19
|
+
'!src/**/*.enum.ts',
|
|
20
|
+
'!src/**/index.ts',
|
|
21
|
+
'!src/**/*.module.ts',
|
|
22
|
+
'!src/main.ts',
|
|
23
|
+
'!src/bootstrap.ts',
|
|
24
|
+
'!src/app.setup.ts',
|
|
25
|
+
'!src/app-test.factory.ts',
|
|
26
|
+
],
|
|
27
|
+
coverageThreshold: {
|
|
28
|
+
global: {
|
|
29
|
+
branches: 80,
|
|
30
|
+
functions: 80,
|
|
31
|
+
lines: 80,
|
|
32
|
+
statements: 80,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
displayName: 'api-e2e',
|
|
3
|
+
preset: '../jest.preset.js',
|
|
4
|
+
testEnvironment: 'node',
|
|
5
|
+
transform: {
|
|
6
|
+
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.e2e.json' }],
|
|
7
|
+
},
|
|
8
|
+
moduleFileExtensions: ['ts', 'js', 'html'],
|
|
9
|
+
coverageDirectory: '../coverage/api-e2e',
|
|
10
|
+
testMatch: ['**/*.e2e-spec.ts'],
|
|
11
|
+
transformIgnorePatterns: ['node_modules/(?!(nest-typed-config|uuid)/)'],
|
|
12
|
+
maxWorkers: 1,
|
|
13
|
+
};
|
package/nest-cli.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/nest-cli",
|
|
3
|
+
"collection": "@nestjs/schematics",
|
|
4
|
+
"sourceRoot": "src",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"deleteOutDir": true,
|
|
7
|
+
"tsConfigPath": "tsconfig.app.json",
|
|
8
|
+
"assets": [
|
|
9
|
+
{
|
|
10
|
+
"include": "../config/**/*.yaml",
|
|
11
|
+
"outDir": "../dist/api/config",
|
|
12
|
+
"watchAssets": true
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dismissible/nestjs-api",
|
|
3
|
+
"version": "0.0.2-canary.585db17.0",
|
|
4
|
+
"description": "Dismissible API application",
|
|
5
|
+
"main": "./src/main.js",
|
|
6
|
+
"types": "./src/main.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./src/main.mjs",
|
|
10
|
+
"require": "./src/main.js",
|
|
11
|
+
"types": "./src/main.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"dismissible-api": "./src/main.js"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"start": "node src/main.js",
|
|
19
|
+
"prisma:generate": "npx dismissible-prisma generate",
|
|
20
|
+
"prisma:migrate:deploy": "npx dismissible-prisma migrate deploy",
|
|
21
|
+
"prisma:migrate:dev": "npx dismissible-prisma migrate dev",
|
|
22
|
+
"prisma:db:push": "npx dismissible-prisma db push",
|
|
23
|
+
"prisma:studio": "npx dismissible-prisma studio"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@dismissible/nestjs-dismissible": "^0.0.2-canary.585db17.0",
|
|
27
|
+
"@dismissible/nestjs-dismissible-item": "^0.0.2-canary.585db17.0",
|
|
28
|
+
"@dismissible/nestjs-jwt-auth-hook": "^0.0.2-canary.585db17.0",
|
|
29
|
+
"@dismissible/nestjs-storage": "^0.0.2-canary.585db17.0",
|
|
30
|
+
"@dismissible/nestjs-postgres-storage": "^0.0.2-canary.585db17.0",
|
|
31
|
+
"@dismissible/nestjs-logger": "^0.0.2-canary.585db17.0",
|
|
32
|
+
"@nestjs/common": "^11.1.10",
|
|
33
|
+
"@nestjs/core": "^11.1.10",
|
|
34
|
+
"@nestjs/platform-fastify": "^11.1.10",
|
|
35
|
+
"fastify": "^5.6.2",
|
|
36
|
+
"@fastify/helmet": "^13.0.2",
|
|
37
|
+
"@fastify/static": "^8.3.0",
|
|
38
|
+
"@nestjs/swagger": "^11.2.3",
|
|
39
|
+
"class-transformer": "^0.5.1",
|
|
40
|
+
"class-validator": "^0.14.3",
|
|
41
|
+
"nest-typed-config": "^2.10.1",
|
|
42
|
+
"reflect-metadata": "^0.2.2",
|
|
43
|
+
"rxjs": "^7.8.2"
|
|
44
|
+
},
|
|
45
|
+
"keywords": [
|
|
46
|
+
"nestjs",
|
|
47
|
+
"api"
|
|
48
|
+
],
|
|
49
|
+
"author": "",
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "https://github.com/DismissibleIo/dismissible-api"
|
|
54
|
+
},
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
}
|
|
58
|
+
}
|
package/project.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "api",
|
|
3
|
+
"$schema": "../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "api/src",
|
|
5
|
+
"projectType": "application",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"targets": {
|
|
8
|
+
"build": {
|
|
9
|
+
"executor": "@nx/js:tsc",
|
|
10
|
+
"outputs": ["{options.outputPath}"],
|
|
11
|
+
"dependsOn": ["^build"],
|
|
12
|
+
"options": {
|
|
13
|
+
"outputPath": "dist/api",
|
|
14
|
+
"main": "api/src/main.ts",
|
|
15
|
+
"tsConfig": "api/tsconfig.app.json",
|
|
16
|
+
"assets": [
|
|
17
|
+
{
|
|
18
|
+
"input": "api/config",
|
|
19
|
+
"glob": "**/*.yaml",
|
|
20
|
+
"output": "config"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"generatePackageJson": true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"serve": {
|
|
27
|
+
"executor": "@nx/js:node",
|
|
28
|
+
"options": {
|
|
29
|
+
"buildTarget": "api:build",
|
|
30
|
+
"runBuildTargetDependencies": true,
|
|
31
|
+
"watch": true
|
|
32
|
+
},
|
|
33
|
+
"configurations": {
|
|
34
|
+
"development": {
|
|
35
|
+
"buildTarget": "api:build"
|
|
36
|
+
},
|
|
37
|
+
"production": {
|
|
38
|
+
"buildTarget": "api:build"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"defaultConfiguration": "development"
|
|
42
|
+
},
|
|
43
|
+
"lint": {
|
|
44
|
+
"executor": "@nx/eslint:lint",
|
|
45
|
+
"outputs": ["{options.outputFile}"],
|
|
46
|
+
"options": {
|
|
47
|
+
"lintFilePatterns": ["api/**/*.ts"]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"test": {
|
|
51
|
+
"executor": "@nx/jest:jest",
|
|
52
|
+
"outputs": ["{workspaceRoot}/coverage/api"],
|
|
53
|
+
"options": {
|
|
54
|
+
"jestConfig": "api/jest.config.ts",
|
|
55
|
+
"passWithNoTests": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"test-e2e": {
|
|
59
|
+
"executor": "@nx/jest:jest",
|
|
60
|
+
"outputs": ["{workspaceRoot}/coverage/api-e2e"],
|
|
61
|
+
"options": {
|
|
62
|
+
"jestConfig": "api/jest.e2e-config.ts"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"prisma:generate": {
|
|
66
|
+
"executor": "nx:run-commands",
|
|
67
|
+
"options": {
|
|
68
|
+
"command": "npm run prisma:generate",
|
|
69
|
+
"cwd": "api"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"prisma:migrate": {
|
|
73
|
+
"executor": "nx:run-commands",
|
|
74
|
+
"options": {
|
|
75
|
+
"command": "npm run prisma:migrate:dev",
|
|
76
|
+
"cwd": "api"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"prisma:push": {
|
|
80
|
+
"executor": "nx:run-commands",
|
|
81
|
+
"options": {
|
|
82
|
+
"command": "npm run prisma:db:push",
|
|
83
|
+
"cwd": "api"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"npm-publish": {
|
|
87
|
+
"executor": "nx:run-commands",
|
|
88
|
+
"options": {
|
|
89
|
+
"command": "npm publish --access public",
|
|
90
|
+
"cwd": "dist/api"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"presets": {
|
|
3
|
+
"light": {
|
|
4
|
+
"createCount": 50,
|
|
5
|
+
"getCount": 50,
|
|
6
|
+
"connections": 5,
|
|
7
|
+
"duration": 5
|
|
8
|
+
},
|
|
9
|
+
"medium": {
|
|
10
|
+
"createCount": 100,
|
|
11
|
+
"getCount": 100,
|
|
12
|
+
"connections": 10,
|
|
13
|
+
"duration": 10
|
|
14
|
+
},
|
|
15
|
+
"heavy": {
|
|
16
|
+
"createCount": 500,
|
|
17
|
+
"getCount": 500,
|
|
18
|
+
"connections": 25,
|
|
19
|
+
"duration": 30
|
|
20
|
+
},
|
|
21
|
+
"stress": {
|
|
22
|
+
"createCount": 1000,
|
|
23
|
+
"getCount": 1000,
|
|
24
|
+
"connections": 50,
|
|
25
|
+
"duration": 60
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"default": "medium"
|
|
29
|
+
}
|