@dismissible/nestjs-api 0.0.2-canary.8976e84.0 → 0.0.2-canary.d2f56d7.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.
Files changed (43) hide show
  1. package/config/.env.yaml +34 -1
  2. package/jest.config.ts +23 -1
  3. package/jest.e2e-config.ts +3 -1
  4. package/package.json +20 -11
  5. package/project.json +6 -3
  6. package/scripts/performance-test.config.json +29 -0
  7. package/scripts/performance-test.ts +855 -0
  8. package/src/app-test.factory.ts +8 -1
  9. package/src/app.module.ts +13 -1
  10. package/src/app.setup.ts +42 -4
  11. package/src/bootstrap.ts +8 -3
  12. package/src/config/app.config.spec.ts +118 -0
  13. package/src/config/app.config.ts +5 -0
  14. package/src/config/default-app.config.spec.ts +74 -0
  15. package/src/config/default-app.config.ts +15 -0
  16. package/src/cors/cors.config.spec.ts +162 -0
  17. package/src/cors/cors.config.ts +37 -0
  18. package/src/cors/index.ts +1 -0
  19. package/src/health/health.controller.spec.ts +7 -31
  20. package/src/health/health.controller.ts +4 -5
  21. package/src/health/health.module.ts +2 -3
  22. package/src/health/index.ts +0 -1
  23. package/src/helmet/helmet.config.spec.ts +197 -0
  24. package/src/helmet/helmet.config.ts +60 -0
  25. package/src/helmet/index.ts +1 -0
  26. package/src/server/server.config.spec.ts +65 -0
  27. package/src/swagger/swagger.config.spec.ts +113 -0
  28. package/src/swagger/swagger.config.ts +2 -10
  29. package/src/swagger/swagger.factory.spec.ts +126 -0
  30. package/src/validation/index.ts +1 -0
  31. package/src/validation/validation.config.ts +47 -0
  32. package/test/config/.env.yaml +23 -0
  33. package/test/config-jwt-auth/.env.yaml +26 -0
  34. package/test/dismiss.e2e-spec.ts +64 -0
  35. package/test/full-cycle.e2e-spec.ts +57 -0
  36. package/test/get-or-create.e2e-spec.ts +51 -0
  37. package/test/jwt-auth.e2e-spec.ts +353 -0
  38. package/test/restore.e2e-spec.ts +63 -0
  39. package/tsconfig.e2e.json +12 -0
  40. package/tsconfig.spec.json +12 -0
  41. package/src/app.e2e-spec.ts +0 -221
  42. package/src/health/health.service.spec.ts +0 -46
  43. package/src/health/health.service.ts +0 -16
package/config/.env.yaml CHANGED
@@ -4,5 +4,38 @@ server:
4
4
  swagger:
5
5
  enabled: ${DISMISSIBLE_SWAGGER_ENABLED:-true}
6
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
+
7
23
  db:
8
- connectionString: ${DISMISSIBLE_POSTGRES_STORAGE_CONNECTION_STRING:-'postgresql://postgres:postgres@localhost:5432/dismissible'}
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 CHANGED
@@ -3,11 +3,33 @@ export default {
3
3
  preset: '../jest.preset.js',
4
4
  testEnvironment: 'node',
5
5
  transform: {
6
- '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.json' }],
6
+ '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
7
7
  },
8
8
  moduleFileExtensions: ['ts', 'js', 'html'],
9
9
  coverageDirectory: '../coverage/api',
10
10
  testMatch: ['**/*.spec.ts'],
11
11
  testPathIgnorePatterns: ['\\.e2e-spec\\.ts$'],
12
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
+ },
13
35
  };
@@ -3,10 +3,12 @@ export default {
3
3
  preset: '../jest.preset.js',
4
4
  testEnvironment: 'node',
5
5
  transform: {
6
- '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.json' }],
6
+ '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.e2e.json' }],
7
7
  },
8
8
  moduleFileExtensions: ['ts', 'js', 'html'],
9
9
  coverageDirectory: '../coverage/api-e2e',
10
10
  testMatch: ['**/*.e2e-spec.ts'],
11
11
  transformIgnorePatterns: ['node_modules/(?!(nest-typed-config|uuid)/)'],
12
+ // Run tests sequentially to avoid database conflicts
13
+ maxWorkers: 1,
12
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dismissible/nestjs-api",
3
- "version": "0.0.2-canary.8976e84.0",
3
+ "version": "0.0.2-canary.d2f56d7.0",
4
4
  "description": "Dismissible API application",
5
5
  "main": "./src/main.js",
6
6
  "types": "./src/main.d.ts",
@@ -15,21 +15,30 @@
15
15
  "dismissible-api": "./src/main.js"
16
16
  },
17
17
  "scripts": {
18
- "start": "node src/main.js"
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"
19
24
  },
20
25
  "dependencies": {
21
- "@dismissible/nestjs-dismissible": "^0.0.2-canary.8976e84.0",
22
- "@dismissible/nestjs-dismissible-item": "^0.0.2-canary.8976e84.0",
23
- "@dismissible/nestjs-storage": "^0.0.2-canary.8976e84.0",
24
- "@dismissible/nestjs-postgres-storage": "^0.0.2-canary.8976e84.0",
25
- "@dismissible/nestjs-logger": "^0.0.2-canary.8976e84.0",
26
+ "@dismissible/nestjs-dismissible": "^0.0.2-canary.d2f56d7.0",
27
+ "@dismissible/nestjs-dismissible-item": "^0.0.2-canary.d2f56d7.0",
28
+ "@dismissible/nestjs-jwt-auth-hook": "^0.0.1",
29
+ "@dismissible/nestjs-storage": "^0.0.2-canary.d2f56d7.0",
30
+ "@dismissible/nestjs-postgres-storage": "^0.0.2-canary.d2f56d7.0",
31
+ "@dismissible/nestjs-logger": "^0.0.2-canary.d2f56d7.0",
26
32
  "@nestjs/common": "^11.1.9",
27
33
  "@nestjs/core": "^11.1.9",
28
- "@nestjs/platform-express": "^11.1.9",
29
- "@nestjs/swagger": "^11.0.0",
34
+ "@nestjs/platform-fastify": "^11.1.9",
35
+ "fastify": "^5.6.0",
36
+ "@fastify/helmet": "^13.0.0",
37
+ "@fastify/static": "^8.3.0",
38
+ "@nestjs/swagger": "^11.2.0",
30
39
  "class-transformer": "^0.5.1",
31
- "class-validator": "^0.14.1",
32
- "nest-typed-config": "^2.0.0",
40
+ "class-validator": "^0.14.3",
41
+ "nest-typed-config": "^2.10.0",
33
42
  "reflect-metadata": "^0.2.2",
34
43
  "rxjs": "^7.8.2"
35
44
  },
package/project.json CHANGED
@@ -65,19 +65,22 @@
65
65
  "prisma:generate": {
66
66
  "executor": "nx:run-commands",
67
67
  "options": {
68
- "command": "npx prisma generate --schema=libs/postgres-storage/prisma/schema.prisma"
68
+ "command": "npm run prisma:generate",
69
+ "cwd": "api"
69
70
  }
70
71
  },
71
72
  "prisma:migrate": {
72
73
  "executor": "nx:run-commands",
73
74
  "options": {
74
- "command": "npx prisma migrate dev --schema=libs/postgres-storage/prisma/schema.prisma"
75
+ "command": "npm run prisma:migrate:dev",
76
+ "cwd": "api"
75
77
  }
76
78
  },
77
79
  "prisma:push": {
78
80
  "executor": "nx:run-commands",
79
81
  "options": {
80
- "command": "npx prisma db push --schema=libs/postgres-storage/prisma/schema.prisma"
82
+ "command": "npm run prisma:db:push",
83
+ "cwd": "api"
81
84
  }
82
85
  },
83
86
  "npm-publish": {
@@ -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
+ }