@dismissible/nestjs-api 1.0.3-alpha.0b30e6d.0 → 2.0.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 CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <a href="https://dismissible.io" target="_blank"><img src="../docs/images/dismissible_logo.png" width="120" alt="Dismissible" /></a>
2
+ <a href="https://dismissible.io" target="_blank"><img src="https://raw.githubusercontent.com/DismissibleIo/dismissible-api/main/docs/images/dismissible_logo.png" width="120" alt="Dismissible" /></a>
3
3
  </p>
4
4
 
5
5
  <p align="center">Never Show The Same Thing Twice!</p>
@@ -126,7 +126,7 @@ Enable Swagger documentation by setting `DISMISSIBLE_SWAGGER_ENABLED=true` and v
126
126
  | ------------------------------- | ------------------------------------------------------------------------- | ---------- |
127
127
  | `DISMISSIBLE_PORT` | Port the API listens on | `3001` |
128
128
  | `DISMISSIBLE_STORAGE_TYPE` | Storage backend type eg. `postgres`, `dynamodb`, `memory` | `postgres` |
129
- | `DISMISSIBLE_RUN_STORAGE_SETUP` | Run database migrations on startup. Each storage type will have their own | `false` |
129
+ | `DISMISSIBLE_STORAGE_RUN_SETUP` | Run database migrations on startup. Each storage type will have their own | `false` |
130
130
 
131
131
  ### Storage Settings
132
132
 
@@ -201,8 +201,8 @@ Cross-Origin Resource Sharing (CORS) controls which domains can access your API
201
201
 
202
202
  | Variable | Description | Default |
203
203
  | ---------------------------------- | ---------------------------------- | ----------------------------------------- |
204
- | `DISMISSIBLE_CORS_ENABLED` | Enable CORS | `true` |
205
- | `DISMISSIBLE_CORS_ORIGINS` | Allowed origins (comma-separated) | `http://localhost:3000` |
204
+ | `DISMISSIBLE_CORS_ENABLED` | Enable CORS | `false` |
205
+ | `DISMISSIBLE_CORS_ORIGINS` | Allowed origins (comma-separated) | `` |
206
206
  | `DISMISSIBLE_CORS_METHODS` | Allowed HTTP methods | `GET,POST,DELETE,OPTIONS` |
207
207
  | `DISMISSIBLE_CORS_ALLOWED_HEADERS` | Allowed headers | `Content-Type,Authorization,x-request-id` |
208
208
  | `DISMISSIBLE_CORS_CREDENTIALS` | Allow credentials | `true` |
@@ -426,7 +426,7 @@ The fastest way to get started:
426
426
  # PostgreSQL (default)
427
427
  docker run -p 3001:3001 \
428
428
  -e DISMISSIBLE_STORAGE_TYPE=postgres \
429
- -e DISMISSIBLE_RUN_STORAGE_SETUP=true \
429
+ -e DISMISSIBLE_STORAGE_RUN_SETUP=true \
430
430
  -e DISMISSIBLE_STORAGE_POSTGRES_CONNECTION_STRING="postgresql://user:password@host:5432/dismissible" \
431
431
  dismissibleio/dismissible-api:latest
432
432
 
@@ -12,6 +12,10 @@ switch (storageType) {
12
12
  console.log('Running DynamoDB storage setup...');
13
13
  execSync('npm run storage:setup:dynamodb', { stdio: 'inherit' });
14
14
  break;
15
+ case 'memory':
16
+ console.log('No setup required for In Memory storage...');
17
+ process.exit(0);
18
+ break;
15
19
  default:
16
20
  if (storageType) {
17
21
  console.log(`Warning: Unknown storage type '${storageType}'. Skipping storage setup.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dismissible/nestjs-api",
3
- "version": "1.0.3-alpha.0b30e6d.0",
3
+ "version": "2.0.1",
4
4
  "description": "Dismissible API application",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -30,25 +30,25 @@
30
30
  "storage:setup:dynamodb": "npx dismissible-dynamodb-setup"
31
31
  },
32
32
  "dependencies": {
33
- "@dismissible/nestjs-core": "1.0.3-alpha.0b30e6d.0",
34
- "@dismissible/nestjs-item": "1.0.3-alpha.0b30e6d.0",
35
- "@dismissible/nestjs-jwt-auth-hook": "1.0.3-alpha.0b30e6d.0",
36
- "@dismissible/nestjs-storage": "1.0.3-alpha.0b30e6d.0",
37
- "@dismissible/nestjs-postgres-storage": "1.0.3-alpha.0b30e6d.0",
38
- "@dismissible/nestjs-dynamodb-storage": "1.0.3-alpha.0b30e6d.0",
39
- "@dismissible/nestjs-logger": "1.0.3-alpha.0b30e6d.0",
40
- "@nestjs/common": "11.1.11",
41
- "@nestjs/core": "11.1.11",
42
- "@nestjs/platform-fastify": "11.1.11",
43
- "fastify": "5.6.2",
44
- "@fastify/helmet": "13.0.2",
45
- "@fastify/static": "8.3.0",
46
- "@nestjs/swagger": "11.2.3",
47
- "class-transformer": "0.5.1",
48
- "class-validator": "0.14.3",
49
- "nest-typed-config": "2.10.1",
50
- "reflect-metadata": "0.2.2",
51
- "rxjs": "7.8.2"
33
+ "@dismissible/nestjs-core": "^2.0.1",
34
+ "@dismissible/nestjs-item": "^2.0.1",
35
+ "@dismissible/nestjs-jwt-auth-hook": "^2.0.1",
36
+ "@dismissible/nestjs-storage": "^2.0.1",
37
+ "@dismissible/nestjs-postgres-storage": "^2.0.1",
38
+ "@dismissible/nestjs-dynamodb-storage": "^2.0.1",
39
+ "@dismissible/nestjs-logger": "^2.0.1",
40
+ "@nestjs/common": "^11.1.11",
41
+ "@nestjs/core": "^11.1.11",
42
+ "@nestjs/platform-fastify": "^11.1.11",
43
+ "fastify": "^5.6.2",
44
+ "@fastify/helmet": "^13.0.2",
45
+ "@fastify/static": "^8.3.0",
46
+ "@nestjs/swagger": "^11.2.3",
47
+ "class-transformer": "^0.5.1",
48
+ "class-validator": "^0.14.3",
49
+ "nest-typed-config": "^2.10.1",
50
+ "reflect-metadata": "^0.2.2",
51
+ "rxjs": "^7.8.2"
52
52
  },
53
53
  "keywords": [
54
54
  "nestjs",
@@ -64,4 +64,4 @@
64
64
  "access": "public"
65
65
  },
66
66
  "type": "commonjs"
67
- }
67
+ }
@@ -14,9 +14,10 @@ tslib_1.__decorate([
14
14
  tslib_1.__metadata("design:type", Boolean)
15
15
  ], CorsConfig.prototype, "enabled", void 0);
16
16
  tslib_1.__decorate([
17
+ (0, class_validator_1.ValidateIf)((o) => o.enabled === true),
17
18
  (0, class_validator_1.IsArray)(),
19
+ (0, class_validator_1.ArrayNotEmpty)({ message: 'origins must not be empty when CORS is enabled' }),
18
20
  (0, class_validator_1.IsString)({ each: true }),
19
- (0, class_validator_1.IsOptional)(),
20
21
  (0, nestjs_validation_1.TransformCommaSeparated)(),
21
22
  tslib_1.__metadata("design:type", Array)
22
23
  ], CorsConfig.prototype, "origins", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"cors.config.js","sourceRoot":"","sources":["../../../../api/src/cors/cors.config.ts"],"names":[],"mappings":";;;;AAAA,qDAAqF;AACrF,yDAAyC;AACzC,sEAA2F;AAE3F,MAAa,UAAU;CAgCtB;AAhCD,gCAgCC;AA7BiB;IAFf,IAAA,2BAAS,GAAE;IACX,IAAA,oCAAgB,GAAE;;2CACe;AAMlB;IAJf,IAAA,yBAAO,GAAE;IACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,IAAA,4BAAU,GAAE;IACZ,IAAA,2CAAuB,GAAE;;2CACS;AAMnB;IAJf,IAAA,yBAAO,GAAE;IACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,IAAA,4BAAU,GAAE;IACZ,IAAA,2CAAuB,GAAE;;2CACS;AAMnB;IAJf,IAAA,yBAAO,GAAE;IACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,IAAA,4BAAU,GAAE;IACZ,IAAA,2CAAuB,GAAE;;kDACgB;AAK1B;IAHf,IAAA,2BAAS,GAAE;IACX,IAAA,4BAAU,GAAE;IACZ,IAAA,oCAAgB,GAAE;;+CACmB;AAKtB;IAHf,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;;0CACa"}
1
+ {"version":3,"file":"cors.config.js","sourceRoot":"","sources":["../../../../api/src/cors/cors.config.ts"],"names":[],"mappings":";;;;AAAA,qDAQyB;AACzB,yDAAyC;AACzC,sEAA2F;AAE3F,MAAa,UAAU;CAiCtB;AAjCD,gCAiCC;AA9BiB;IAFf,IAAA,2BAAS,GAAE;IACX,IAAA,oCAAgB,GAAE;;2CACe;AAOlB;IALf,IAAA,4BAAU,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC;IACrC,IAAA,yBAAO,GAAE;IACT,IAAA,+BAAa,EAAC,EAAE,OAAO,EAAE,gDAAgD,EAAE,CAAC;IAC5E,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,IAAA,2CAAuB,GAAE;;2CACS;AAMnB;IAJf,IAAA,yBAAO,GAAE;IACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,IAAA,4BAAU,GAAE;IACZ,IAAA,2CAAuB,GAAE;;2CACS;AAMnB;IAJf,IAAA,yBAAO,GAAE;IACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,IAAA,4BAAU,GAAE;IACZ,IAAA,2CAAuB,GAAE;;kDACgB;AAK1B;IAHf,IAAA,2BAAS,GAAE;IACX,IAAA,4BAAU,GAAE;IACZ,IAAA,oCAAgB,GAAE;;+CACmB;AAKtB;IAHf,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;;0CACa"}
@@ -8,8 +8,9 @@ function configureAppWithCors(app) {
8
8
  logger.setContext('CORS');
9
9
  const corsConfig = app.get(cors_config_1.CorsConfig);
10
10
  if (corsConfig.enabled) {
11
+ // origins is guaranteed to be non-empty when enabled via @ValidateIf + @ArrayNotEmpty
11
12
  app.enableCors({
12
- origin: corsConfig.origins ?? ['http://localhost:3001', 'http://localhost:5173'],
13
+ origin: corsConfig.origins,
13
14
  methods: corsConfig.methods ?? ['GET', 'POST', 'DELETE', 'OPTIONS'],
14
15
  allowedHeaders: corsConfig.allowedHeaders ?? [
15
16
  'Content-Type',
@@ -1 +1 @@
1
- {"version":3,"file":"cors.factory.js","sourceRoot":"","sources":["../../../../api/src/cors/cors.factory.ts"],"names":[],"mappings":";;AAIA,oDAqBC;AAxBD,+CAA2C;AAC3C,8DAAoF;AAEpF,SAAgB,oBAAoB,CAAC,GAAqB;IACxD,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAqB,kCAAkB,CAAC,CAAC;IAC/D,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC1B,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CAAC,wBAAU,CAAC,CAAC;IAEvC,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;QACvB,GAAG,CAAC,UAAU,CAAC;YACb,MAAM,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,uBAAuB,EAAE,uBAAuB,CAAC;YAChF,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC;YACnE,cAAc,EAAE,UAAU,CAAC,cAAc,IAAI;gBAC3C,cAAc;gBACd,eAAe;gBACf,cAAc;aACf;YACD,WAAW,EAAE,UAAU,CAAC,WAAW,IAAI,IAAI;YAC3C,MAAM,EAAE,UAAU,CAAC,MAAM,IAAI,KAAK;SACnC,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IACjD,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAClC,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"cors.factory.js","sourceRoot":"","sources":["../../../../api/src/cors/cors.factory.ts"],"names":[],"mappings":";;AAIA,oDAsBC;AAzBD,+CAA2C;AAC3C,8DAAoF;AAEpF,SAAgB,oBAAoB,CAAC,GAAqB;IACxD,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAqB,kCAAkB,CAAC,CAAC;IAC/D,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC1B,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CAAC,wBAAU,CAAC,CAAC;IAEvC,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;QACvB,sFAAsF;QACtF,GAAG,CAAC,UAAU,CAAC;YACb,MAAM,EAAE,UAAU,CAAC,OAAQ;YAC3B,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC;YACnE,cAAc,EAAE,UAAU,CAAC,cAAc,IAAI;gBAC3C,cAAc;gBACd,eAAe;gBACf,cAAc;aACf;YACD,WAAW,EAAE,UAAU,CAAC,WAAW,IAAI,IAAI;YAC3C,MAAM,EAAE,UAAU,CAAC,MAAM,IAAI,KAAK;SACnC,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IACjD,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAClC,CAAC;AACH,CAAC"}