@dismissible/nestjs-api 1.0.1 → 1.0.3-alpha.064e57a.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/README.md +499 -0
- package/bin/dismissible-storage-setup.js +22 -0
- package/config/.env.development.yaml +33 -0
- package/config/.env.yaml +13 -3
- package/package.json +34 -26
- package/src/app-test.factory.js +4 -3
- package/src/app-test.factory.js.map +1 -1
- package/src/app.module.js +9 -10
- package/src/app.module.js.map +1 -1
- package/src/config/app.config.d.ts +2 -2
- package/src/config/app.config.js +7 -4
- package/src/config/app.config.js.map +1 -1
- package/src/config/config.module.js +1 -0
- package/src/config/config.module.js.map +1 -1
- package/src/storage/dynamic-storage.module.d.ts +8 -0
- package/src/storage/dynamic-storage.module.js +33 -0
- package/src/storage/dynamic-storage.module.js.map +1 -0
- package/src/storage/storage.config.d.ts +12 -0
- package/src/storage/storage.config.js +45 -0
- package/src/storage/storage.config.js.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://dismissible.io" target="_blank"><img src="../docs/images/dismissible_logo.png" width="120" alt="Dismissible" /></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">Never Show The Same Thing Twice!</p>
|
|
6
|
+
<p align="center">
|
|
7
|
+
<a href="https://www.npmjs.com/package/@dismissible/nestjs-api" target="_blank"><img src="https://img.shields.io/npm/v/@dismissible/nestjs-api.svg" alt="NPM Version" /></a>
|
|
8
|
+
<a href="https://github.com/dismissibleio/dismissible-api/blob/main/LICENSE" target="_blank"><img src="https://img.shields.io/npm/l/@dismissible/nestjs-api.svg" alt="Package License" /></a>
|
|
9
|
+
<a href="https://www.npmjs.com/package/@dismissible/nestjs-api" target="_blank"><img src="https://img.shields.io/npm/dm/@dismissible/nestjs-api.svg" alt="NPM Downloads" /></a>
|
|
10
|
+
<a href="https://github.com/dismissibleio/dismissible-api" target="_blank"><img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/dismissibleio/dismissible-api/release.yml"></a>
|
|
11
|
+
<a href="https://paypal.me/joshstuartx" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
Dismissible manages the state of your UI elements across sessions, so your users see what matters, once! No more onboarding messages reappearing on every tab, no more notifications haunting users across devices. Dismissible syncs dismissal state everywhere, so every message is intentional, never repetitive.
|
|
15
|
+
|
|
16
|
+
**Visit [dismissible.io](https://dismissible.io)** for documentation, help, and support.
|
|
17
|
+
|
|
18
|
+
## Overview
|
|
19
|
+
|
|
20
|
+
The NestJS Dismissible API module:
|
|
21
|
+
|
|
22
|
+
- Maintains all the dismissal state for dismissible items
|
|
23
|
+
- Provides a REST API for managing dismissible items (get, dismiss, restore)
|
|
24
|
+
- Supports JWT authentication via OIDC-compliant identity providers
|
|
25
|
+
- Supports multiple storage backends (PostgreSQL, DynamoDB, memory)
|
|
26
|
+
- Includes comprehensive security features (Helmet, CORS, validation)
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install @dismissible/nestjs-api
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
### Standalone Application
|
|
37
|
+
|
|
38
|
+
This contains all the bells and whistles out of the box. You create an entry point that uses the `DismissibleNestFactory` to create a new NestJS application:
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
// src/main.ts
|
|
42
|
+
import { DismissibleNestFactory } from '@dismissible/nestjs-api';
|
|
43
|
+
import { CustomModule } from './custom.module';
|
|
44
|
+
|
|
45
|
+
async function bootstrap() {
|
|
46
|
+
const app = await DismissibleNestFactory.create({
|
|
47
|
+
imports: [CustomModule],
|
|
48
|
+
});
|
|
49
|
+
// The app returned is an extended version of the INestApplication app.
|
|
50
|
+
// So you can use it in all the ways NestJS provides.
|
|
51
|
+
await app.start();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
bootstrap();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This is an extension of `NestFactory.create()`, but also wires up all our config, swagger, storage, security and much more.
|
|
58
|
+
|
|
59
|
+
#### DismissibleNestFactory Config
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
interface IDismissibleNestFactoryOptions {
|
|
63
|
+
configPath?: string; // Path to config files
|
|
64
|
+
schema?: new () => DefaultAppConfig; // Config validation schema
|
|
65
|
+
logger?: Type<IDismissibleLogger>; // Custom logger implementation
|
|
66
|
+
imports?: DynamicModule[]; // Additional modules to import
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### NestJS Module
|
|
71
|
+
|
|
72
|
+
Import the DismissibleModule into your existing NestJS application:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { Module } from '@nestjs/common';
|
|
76
|
+
import { DismissibleModule } from '@dismissible/nestjs-api';
|
|
77
|
+
import { PostgresStorageModule } from '@dismissible/nestjs-postgres-storage';
|
|
78
|
+
import { DynamoDbStorageModule } from '@dismissible/nestjs-dynamodb-storage';
|
|
79
|
+
import { MemoryStorageModule } from '@dismissible/nestjs-storage';
|
|
80
|
+
|
|
81
|
+
@Module({
|
|
82
|
+
imports: [
|
|
83
|
+
// PostgreSQL Storage
|
|
84
|
+
DismissibleModule.forRoot({
|
|
85
|
+
storage: PostgresStorageModule.forRoot({
|
|
86
|
+
connectionString: process.env.DATABASE_URL,
|
|
87
|
+
}),
|
|
88
|
+
}),
|
|
89
|
+
|
|
90
|
+
// Or DynamoDB Storage
|
|
91
|
+
DismissibleModule.forRoot({
|
|
92
|
+
storage: DynamoDbStorageModule.forRoot({
|
|
93
|
+
tableName: process.env.DYNAMODB_TABLE,
|
|
94
|
+
region: process.env.AWS_REGION,
|
|
95
|
+
accessKeyId:
|
|
96
|
+
}),
|
|
97
|
+
}),
|
|
98
|
+
|
|
99
|
+
// Or In-Memory Storage
|
|
100
|
+
DismissibleModule.forRoot({
|
|
101
|
+
storage: MemoryStorageModule.forRoot(),
|
|
102
|
+
}),
|
|
103
|
+
],
|
|
104
|
+
})
|
|
105
|
+
export class AppModule {}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## API Endpoints
|
|
109
|
+
|
|
110
|
+
The API provides the following REST endpoints:
|
|
111
|
+
|
|
112
|
+
| Endpoint | Method | Description |
|
|
113
|
+
| ----------------------------------- | ------ | ----------------------------------- |
|
|
114
|
+
| `/health` | GET | Health check endpoint |
|
|
115
|
+
| `/v1/users/{userId}/items/{itemId}` | GET | Get or create a dismissible item |
|
|
116
|
+
| `/v1/users/{userId}/items/{itemId}` | DELETE | Dismiss an item |
|
|
117
|
+
| `/v1/users/{userId}/items/{itemId}` | POST | Restore a previously dismissed item |
|
|
118
|
+
|
|
119
|
+
Enable Swagger documentation by setting `DISMISSIBLE_SWAGGER_ENABLED=true` and visit `/docs` for interactive API docs.
|
|
120
|
+
|
|
121
|
+
## Configuration
|
|
122
|
+
|
|
123
|
+
### Core Settings
|
|
124
|
+
|
|
125
|
+
| Variable | Description | Default |
|
|
126
|
+
| ------------------------------- | ------------------------------------------------------------------------- | ---------- |
|
|
127
|
+
| `DISMISSIBLE_PORT` | Port the API listens on | `3001` |
|
|
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` |
|
|
130
|
+
|
|
131
|
+
### Storage Settings
|
|
132
|
+
|
|
133
|
+
#### PostgreSQL
|
|
134
|
+
|
|
135
|
+
PostgreSQL is a fantastic open-source relational database. It's highly performant and the majority of cloud providers and hosting companies provide a managed services. To enable PostgreSQL, set `DISMISSIBLE_STORAGE_TYPE=postgres` and provide a connection string.
|
|
136
|
+
|
|
137
|
+
| Variable | Description | Default |
|
|
138
|
+
| ------------------------------------------------ | ---------------------------- | ---------- |
|
|
139
|
+
| `DISMISSIBLE_STORAGE_POSTGRES_CONNECTION_STRING` | PostgreSQL connection string | _required_ |
|
|
140
|
+
|
|
141
|
+
> [!TIP]
|
|
142
|
+
> An example connection string is: `postgresql://user:password@domain.com:port/database-name` eg. `postgresql://postgres:postgres@localhost:5432/dismissible`
|
|
143
|
+
|
|
144
|
+
#### DynamoDB
|
|
145
|
+
|
|
146
|
+
DynamoDB is an infintely scalable document store as a service provided by AWS. It's perfect if you do not want to manage infrastructure or need to run at scale. To enable DynamoDB, set `DISMISSIBLE_STORAGE_TYPE=dynamodb` and pass in the following:
|
|
147
|
+
|
|
148
|
+
| Variable | Description | Default |
|
|
149
|
+
| ---------------------------------------------------- | -------------------------------------- | ------------------- |
|
|
150
|
+
| `DISMISSIBLE_STORAGE_DYNAMODB_TABLE_NAME` | DynamoDB table name | `dismissible-items` |
|
|
151
|
+
| `DISMISSIBLE_STORAGE_DYNAMODB_AWS_REGION` | AWS region | `us-east-1` |
|
|
152
|
+
| `DISMISSIBLE_STORAGE_DYNAMODB_AWS_ACCESS_KEY_ID` | AWS access key ID | - |
|
|
153
|
+
| `DISMISSIBLE_STORAGE_DYNAMODB_AWS_SECRET_ACCESS_KEY` | AWS secret access key | - |
|
|
154
|
+
| `DISMISSIBLE_STORAGE_DYNAMODB_AWS_SESSION_TOKEN` | AWS session token | - |
|
|
155
|
+
| `DISMISSIBLE_STORAGE_DYNAMODB_ENDPOINT` | LocalStack/DynamoDB Local endpoint URL | - |
|
|
156
|
+
|
|
157
|
+
Depending how your IAMs is configured will depend what config you need to pass. Review the official [AWS documentation](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/getting-your-credentials.html) to determine the config you need to pass.
|
|
158
|
+
|
|
159
|
+
#### In-Memory
|
|
160
|
+
|
|
161
|
+
No configuration required. This storage backend is intended for testing and development purposes only.
|
|
162
|
+
|
|
163
|
+
### Swagger
|
|
164
|
+
|
|
165
|
+
When enabled, Swagger documentation is published to the path specified by `DISMISSIBLE_SWAGGER_PATH` (defaults to `/docs`). The OpenAPI schema is available at `${PATH}-json` (JSON format) and `${PATH}-yaml` (YAML format). For example:
|
|
166
|
+
|
|
167
|
+
- `DISMISSIBLE_SWAGGER_PATH` default is `docs`: `/docs`, `/docs-json`, `/docs-yaml`
|
|
168
|
+
- `swagger`: `/swagger`, `/swagger-json`, `/swagger-yaml`
|
|
169
|
+
- `swagger/docs`: `/swagger/docs`, `/swagger/docs-json`, `/swagger/docs-yaml`
|
|
170
|
+
|
|
171
|
+
| Variable | Description | Default |
|
|
172
|
+
| ----------------------------- | ------------------------------------------------------------------------- | -------- |
|
|
173
|
+
| `DISMISSIBLE_SWAGGER_ENABLED` | Enable Swagger API docs at the path defined in `DISMISSIBLE_SWAGGER_PATH` | `false` |
|
|
174
|
+
| `DISMISSIBLE_SWAGGER_PATH` | Path for Swagger docs eg. `/docs` | `"docs"` |
|
|
175
|
+
|
|
176
|
+
### JWT Authentication
|
|
177
|
+
|
|
178
|
+
You can secure your API with any OIDC-compliant provider (Auth0, Okta, Keycloak, etc.). This ensures that no one can fill your dismissible service with junk.
|
|
179
|
+
|
|
180
|
+
| Variable | Description | Default |
|
|
181
|
+
| ------------------------------------------ | ------------------------------------ | --------------------- |
|
|
182
|
+
| `DISMISSIBLE_JWT_AUTH_ENABLED` | Enable JWT authentication | `false` |
|
|
183
|
+
| `DISMISSIBLE_JWT_AUTH_WELL_KNOWN_URL` | OIDC discovery URL | _required_ if enabled |
|
|
184
|
+
| `DISMISSIBLE_JWT_AUTH_ISSUER` | Expected JWT issuer | _-_ |
|
|
185
|
+
| `DISMISSIBLE_JWT_AUTH_AUDIENCE` | Expected JWT audience | _-_ |
|
|
186
|
+
| `DISMISSIBLE_JWT_AUTH_ALGORITHMS` | Allowed algorithms (comma-separated) | `RS256` |
|
|
187
|
+
| `DISMISSIBLE_JWT_AUTH_JWKS_CACHE_DURATION` | JWKS cache duration (ms) | `600000` |
|
|
188
|
+
| `DISMISSIBLE_JWT_AUTH_REQUEST_TIMEOUT` | Request timeout (ms) | `30000` |
|
|
189
|
+
| `DISMISSIBLE_JWT_AUTH_PRIORITY` | Hook priority (lower runs first) | `-100` |
|
|
190
|
+
|
|
191
|
+
### CORS Settings
|
|
192
|
+
|
|
193
|
+
Cross-Origin Resource Sharing (CORS) controls which domains can access your API resources from browser-based clients. By default, only requests from `localhost:3000` are allowed, which is only helpful for local testing.
|
|
194
|
+
|
|
195
|
+
> [!TIP]
|
|
196
|
+
> Configure `DISMISSIBLE_CORS_ORIGINS` with the domains your frontend applications run on. Be careful with wildcard origins (`*`) as they may expose your API to unauthorized cross-origin requests, especially when credentials are enabled.
|
|
197
|
+
|
|
198
|
+
| Variable | Description | Default |
|
|
199
|
+
| ---------------------------------- | ---------------------------------- | ----------------------------------------- |
|
|
200
|
+
| `DISMISSIBLE_CORS_ENABLED` | Enable CORS | `true` |
|
|
201
|
+
| `DISMISSIBLE_CORS_ORIGINS` | Allowed origins (comma-separated) | `http://localhost:3000` |
|
|
202
|
+
| `DISMISSIBLE_CORS_METHODS` | Allowed HTTP methods | `GET,POST,DELETE,OPTIONS` |
|
|
203
|
+
| `DISMISSIBLE_CORS_ALLOWED_HEADERS` | Allowed headers | `Content-Type,Authorization,x-request-id` |
|
|
204
|
+
| `DISMISSIBLE_CORS_CREDENTIALS` | Allow credentials | `true` |
|
|
205
|
+
| `DISMISSIBLE_CORS_MAX_AGE` | Preflight cache duration (seconds) | `86400` |
|
|
206
|
+
|
|
207
|
+
### Security Headers (Helmet)
|
|
208
|
+
|
|
209
|
+
Helmet is a collection of middleware functions that set security-related HTTP headers. These headers help protect your API against common vulnerabilities like cross-site scripting (XSS), clickjacking, and other attacks by instructing browsers to enforce security policies. For most production deployments, keeping Helmet enabled is recommended. You may disable it if you have specific requirements for custom headers or are behind a separate security layer (e.g., a CDN or WAF that handles these protections).
|
|
210
|
+
|
|
211
|
+
| Variable | Description | Default |
|
|
212
|
+
| -------------------------------------------- | ----------------------------------- | ---------- |
|
|
213
|
+
| `DISMISSIBLE_HELMET_ENABLED` | Enable Helmet security headers | `true` |
|
|
214
|
+
| `DISMISSIBLE_HELMET_CSP` | Enable Content Security Policy | `true` |
|
|
215
|
+
| `DISMISSIBLE_HELMET_COEP` | Enable Cross-Origin Embedder Policy | `true` |
|
|
216
|
+
| `DISMISSIBLE_HELMET_HSTS_MAX_AGE` | HSTS max age (seconds) | `31536000` |
|
|
217
|
+
| `DISMISSIBLE_HELMET_HSTS_INCLUDE_SUBDOMAINS` | Include subdomains in HSTS | `true` |
|
|
218
|
+
| `DISMISSIBLE_HELMET_HSTS_PRELOAD` | Enable HSTS preload | `false` |
|
|
219
|
+
|
|
220
|
+
### Validation Settings
|
|
221
|
+
|
|
222
|
+
This config prevents internal error messages from leaking out. In production environements, these should all be set to `true`, but in lower environements they can be set to `false` to help with debugging.
|
|
223
|
+
|
|
224
|
+
| Variable | Description | Default |
|
|
225
|
+
| ----------------------------------------------- | ------------------------------- | ------- |
|
|
226
|
+
| `DISMISSIBLE_VALIDATION_DISABLE_ERROR_MESSAGES` | Hide detailed validation errors | `true` |
|
|
227
|
+
| `DISMISSIBLE_VALIDATION_WHITELIST` | Strip unknown properties | `true` |
|
|
228
|
+
| `DISMISSIBLE_VALIDATION_FORBID_NON_WHITELISTED` | Reject unknown properties | `true` |
|
|
229
|
+
| `DISMISSIBLE_VALIDATION_TRANSFORM` | Auto-transform payloads to DTOs | `true` |
|
|
230
|
+
|
|
231
|
+
## NestJS API Module Configuration
|
|
232
|
+
|
|
233
|
+
The [Dismissible NestJS Module API library](https://www.npmjs.com/package/@dismissible/nestjs-api) has an alternative way to set configuration by using a `.env.yaml` file eg. [`api/config/.env.yaml`](api/config/.env.yaml)
|
|
234
|
+
|
|
235
|
+
### Example YAML file
|
|
236
|
+
|
|
237
|
+
Below is the default config file which contains both default values and a way to interpolate the [environment variables](#all-configuration-options) defined above.
|
|
238
|
+
|
|
239
|
+
```yaml
|
|
240
|
+
server:
|
|
241
|
+
port: ${DISMISSIBLE_PORT:-3001}
|
|
242
|
+
|
|
243
|
+
swagger:
|
|
244
|
+
enabled: ${DISMISSIBLE_SWAGGER_ENABLED:-true}
|
|
245
|
+
path: ${DISMISSIBLE_SWAGGER_PATH:-docs}
|
|
246
|
+
|
|
247
|
+
helmet:
|
|
248
|
+
enabled: ${DISMISSIBLE_HELMET_ENABLED:-true}
|
|
249
|
+
contentSecurityPolicy: ${DISMISSIBLE_HELMET_CSP:-false}
|
|
250
|
+
crossOriginEmbedderPolicy: ${DISMISSIBLE_HELMET_COEP:-false}
|
|
251
|
+
hstsMaxAge: ${DISMISSIBLE_HELMET_HSTS_MAX_AGE:-31536000}
|
|
252
|
+
hstsIncludeSubDomains: ${DISMISSIBLE_HELMET_HSTS_INCLUDE_SUBDOMAINS:-true}
|
|
253
|
+
hstsPreload: ${DISMISSIBLE_HELMET_HSTS_PRELOAD:-false}
|
|
254
|
+
|
|
255
|
+
cors:
|
|
256
|
+
enabled: ${DISMISSIBLE_CORS_ENABLED:-true}
|
|
257
|
+
origins: ${DISMISSIBLE_CORS_ORIGINS:-http://localhost:3001,http://localhost:5173}
|
|
258
|
+
methods: ${DISMISSIBLE_CORS_METHODS:-GET,POST,DELETE,OPTIONS}
|
|
259
|
+
allowedHeaders: ${DISMISSIBLE_CORS_ALLOWED_HEADERS:-Content-Type,Authorization,x-request-id}
|
|
260
|
+
credentials: ${DISMISSIBLE_CORS_CREDENTIALS:-true}
|
|
261
|
+
maxAge: ${DISMISSIBLE_CORS_MAX_AGE:-86400}
|
|
262
|
+
|
|
263
|
+
storage:
|
|
264
|
+
# postgres | dynamodb | memory
|
|
265
|
+
type: ${DISMISSIBLE_STORAGE_TYPE:-postgres}
|
|
266
|
+
postgres:
|
|
267
|
+
connectionString: ${DISMISSIBLE_STORAGE_POSTGRES_CONNECTION_STRING:-postgresql://postgres:postgres@localhost:5432/dismissible}
|
|
268
|
+
dynamodb:
|
|
269
|
+
tableName: ${DISMISSIBLE_STORAGE_DYNAMODB_TABLE_NAME:-dismissible-items}
|
|
270
|
+
region: ${DISMISSIBLE_STORAGE_DYNAMODB_AWS_REGION:-us-east-1}
|
|
271
|
+
endpoint: ${DISMISSIBLE_STORAGE_DYNAMODB_ENDPOINT:-}
|
|
272
|
+
accessKeyId: ${DISMISSIBLE_STORAGE_DYNAMODB_AWS_ACCESS_KEY_ID:-}
|
|
273
|
+
secretAccessKey: ${DISMISSIBLE_STORAGE_DYNAMODB_AWS_SECRET_ACCESS_KEY:-}
|
|
274
|
+
sessionToken: ${DISMISSIBLE_STORAGE_DYNAMODB_AWS_SESSION_TOKEN:-}
|
|
275
|
+
|
|
276
|
+
jwtAuth:
|
|
277
|
+
enabled: ${DISMISSIBLE_JWT_AUTH_ENABLED:-false}
|
|
278
|
+
wellKnownUrl: ${DISMISSIBLE_JWT_AUTH_WELL_KNOWN_URL:-}
|
|
279
|
+
issuer: ${DISMISSIBLE_JWT_AUTH_ISSUER:-}
|
|
280
|
+
audience: ${DISMISSIBLE_JWT_AUTH_AUDIENCE:-}
|
|
281
|
+
algorithms:
|
|
282
|
+
- ${DISMISSIBLE_JWT_AUTH_ALGORITHMS:-RS256}
|
|
283
|
+
jwksCacheDuration: ${DISMISSIBLE_JWT_AUTH_JWKS_CACHE_DURATION:-600000}
|
|
284
|
+
requestTimeout: ${DISMISSIBLE_JWT_AUTH_REQUEST_TIMEOUT:-30000}
|
|
285
|
+
priority: ${DISMISSIBLE_JWT_AUTH_PRIORITY:--100}
|
|
286
|
+
|
|
287
|
+
validation:
|
|
288
|
+
disableErrorMessages: ${DISMISSIBLE_VALIDATION_DISABLE_ERROR_MESSAGES:-true}
|
|
289
|
+
whitelist: ${DISMISSIBLE_VALIDATION_WHITELIST:-true}
|
|
290
|
+
forbidNonWhitelisted: ${DISMISSIBLE_VALIDATION_FORBID_NON_WHITELISTED:-true}
|
|
291
|
+
transform: ${DISMISSIBLE_VALIDATION_TRANSFORM:-true}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Usage
|
|
295
|
+
|
|
296
|
+
When creating your application, you can specify the directory that contains your YAML config files eg.
|
|
297
|
+
|
|
298
|
+
If we have a structure like:
|
|
299
|
+
|
|
300
|
+
```
|
|
301
|
+
config/
|
|
302
|
+
└── .env.yaml
|
|
303
|
+
src/
|
|
304
|
+
├── main.ts
|
|
305
|
+
└── custom.module.ts
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
And our `main.ts` file is:
|
|
309
|
+
|
|
310
|
+
```typescript
|
|
311
|
+
import { DismissibleNestFactory } from '@dismissible/nestjs-api';
|
|
312
|
+
import { CustomModule } from './custom.module';
|
|
313
|
+
|
|
314
|
+
const configPath = join(__dirname, '../config');
|
|
315
|
+
|
|
316
|
+
async function bootstrap() {
|
|
317
|
+
const app = await DismissibleNestFactory.create({
|
|
318
|
+
imports: [CustomModule],
|
|
319
|
+
configPath,
|
|
320
|
+
});
|
|
321
|
+
await app.start();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
bootstrap();
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Environment Aware
|
|
328
|
+
|
|
329
|
+
You can maintain multiple config files which are controlled by `NODE_ENV`. The format needs to follow:
|
|
330
|
+
|
|
331
|
+
`.env.{NODE_ENV}.yaml`
|
|
332
|
+
|
|
333
|
+
eg. If we have the following files:
|
|
334
|
+
|
|
335
|
+
```
|
|
336
|
+
config/
|
|
337
|
+
└── .env.yaml
|
|
338
|
+
└── .env.dev.yaml
|
|
339
|
+
└── .env.staging.yaml
|
|
340
|
+
└── .env.production.yaml
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Then if we pass `NODE_ENV=production`, the `.env.production.yaml` file will be loaded automaticall. This is super handy to maintain separate config files per environment.
|
|
344
|
+
|
|
345
|
+
### Environment Variable Interpolation
|
|
346
|
+
|
|
347
|
+
You can specify environment variables within the YAML file, including a default, and they will be interpolated at run time.
|
|
348
|
+
|
|
349
|
+
The fomat needs to follow: `${ENV_VAR:-default-value}`.
|
|
350
|
+
|
|
351
|
+
> [!WARNING]
|
|
352
|
+
> If you don't specify a `default-value`, and only `${ENV_VAR}`, then if the config is required but not present, and error will be thrown.
|
|
353
|
+
|
|
354
|
+
> [!TIP]
|
|
355
|
+
> Use interpolation of environment variables for sensitive config like secrets and connection strings.
|
|
356
|
+
|
|
357
|
+
### Extending the Configuration
|
|
358
|
+
|
|
359
|
+
You can extend the default `AppConfig` with additional configuration options by creating your own config schema and passing it via the `schema` option. This is useful when you need custom settings beyond what's provided by default.
|
|
360
|
+
|
|
361
|
+
```typescript
|
|
362
|
+
// custom.config.ts
|
|
363
|
+
import { AppConfig } from '@dismissible/nestjs-api';
|
|
364
|
+
import { IsString, IsOptional } from 'class-validator';
|
|
365
|
+
|
|
366
|
+
export class CustomConfig extends AppConfig {
|
|
367
|
+
@IsString()
|
|
368
|
+
@IsOptional()
|
|
369
|
+
myCustomSetting?: string;
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
```typescript
|
|
374
|
+
// src/main.ts
|
|
375
|
+
import { DismissibleNestFactory } from '@dismissible/nestjs-api';
|
|
376
|
+
import { CustomConfig } from './custom.config';
|
|
377
|
+
|
|
378
|
+
async function bootstrap() {
|
|
379
|
+
const app = await DismissibleNestFactory.create({
|
|
380
|
+
configPath: './config',
|
|
381
|
+
schema: CustomConfig, // Pass your extended config schema
|
|
382
|
+
});
|
|
383
|
+
await app.start();
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
bootstrap();
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
Then add your custom settings to the YAML file:
|
|
390
|
+
|
|
391
|
+
```yaml
|
|
392
|
+
# @api/config/.env.yaml
|
|
393
|
+
server:
|
|
394
|
+
port: 3001
|
|
395
|
+
myCustomSetting: 'custom-value'
|
|
396
|
+
# ... rest of default config
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
The nest-typed-config library will automatically merge your custom config with the defaults, and your custom config class will be available for injection throughout your NestJS application.
|
|
400
|
+
|
|
401
|
+
## Running the Application
|
|
402
|
+
|
|
403
|
+
### Development
|
|
404
|
+
|
|
405
|
+
```bash
|
|
406
|
+
# Start the API
|
|
407
|
+
npm run start
|
|
408
|
+
|
|
409
|
+
# Start with hot reload
|
|
410
|
+
npm run start:dev
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### Docker
|
|
414
|
+
|
|
415
|
+
The fastest way to get started:
|
|
416
|
+
|
|
417
|
+
```bash
|
|
418
|
+
# PostgreSQL (default)
|
|
419
|
+
docker run -p 3001:3001 \
|
|
420
|
+
-e DISMISSIBLE_STORAGE_TYPE=postgres \
|
|
421
|
+
-e DISMISSIBLE_RUN_STORAGE_SETUP=true \
|
|
422
|
+
-e DISMISSIBLE_STORAGE_POSTGRES_CONNECTION_STRING="postgresql://user:password@host:5432/dismissible" \
|
|
423
|
+
dismissibleio/dismissible-api:latest
|
|
424
|
+
|
|
425
|
+
# DynamoDB
|
|
426
|
+
docker run -p 3001:3001 \
|
|
427
|
+
-e DISMISSIBLE_STORAGE_TYPE=dynamodb \
|
|
428
|
+
-e DISMISSIBLE_STORAGE_DYNAMODB_TABLE_NAME="items" \
|
|
429
|
+
-e DISMISSIBLE_STORAGE_DYNAMODB_REGION="us-east-1" \
|
|
430
|
+
dismissibleio/dismissible-api:latest
|
|
431
|
+
|
|
432
|
+
# In-Memory (development/testing)
|
|
433
|
+
docker run -p 3001:3001 \
|
|
434
|
+
-e DISMISSIBLE_STORAGE_TYPE=memory \
|
|
435
|
+
dismissibleio/dismissible-api:latest
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
See [docs/DOCKER.md](../docs/DOCKER.md) for complete deployment instructions.
|
|
439
|
+
|
|
440
|
+
## Storage Setup
|
|
441
|
+
|
|
442
|
+
**CRITICAL**: The storage schema must be initialized before starting the API. The setup process depends on your chosen storage backend.
|
|
443
|
+
|
|
444
|
+
### PostgreSQL Setup
|
|
445
|
+
|
|
446
|
+
```bash
|
|
447
|
+
# Generate Prisma client
|
|
448
|
+
npm run storage:init
|
|
449
|
+
|
|
450
|
+
# Run migrations (development)
|
|
451
|
+
npm run prisma:migrate:dev
|
|
452
|
+
|
|
453
|
+
# Deploy migrations (production)
|
|
454
|
+
npm run prisma:migrate:deploy
|
|
455
|
+
|
|
456
|
+
# Push schema (development only)
|
|
457
|
+
npm run prisma:db:push
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
### DynamoDB Setup
|
|
461
|
+
|
|
462
|
+
```bash
|
|
463
|
+
# Create the DynamoDB table
|
|
464
|
+
npm run storage:init
|
|
465
|
+
npm run dynamodb:setup
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
The DynamoDB table will be created with the following schema:
|
|
469
|
+
|
|
470
|
+
- Partition key: `userId` (String)
|
|
471
|
+
- Sort key: `itemId` (String)
|
|
472
|
+
|
|
473
|
+
### In-Memory Setup
|
|
474
|
+
|
|
475
|
+
No setup required. The storage is ready to use immediately.
|
|
476
|
+
|
|
477
|
+
## Features
|
|
478
|
+
|
|
479
|
+
- **REST API**: Clean, simple endpoints for managing dismissible items
|
|
480
|
+
- **JWT Authentication**: Secure your API with OIDC-compliant identity providers (Auth0, Okta, Keycloak)
|
|
481
|
+
- **Multiple Storage Backends**: PostgreSQL, DynamoDB, or memory storage
|
|
482
|
+
- **Swagger Documentation**: Interactive API docs when enabled
|
|
483
|
+
- **Security**: Helmet for security headers, CORS configuration, request validation
|
|
484
|
+
- **TypeScript**: Full TypeScript support with type safety
|
|
485
|
+
- **Docker Ready**: Multi-stage Dockerfile for production deployments
|
|
486
|
+
|
|
487
|
+
## Related Packages
|
|
488
|
+
|
|
489
|
+
- `@dismissible/nestjs-core` - Main dismissible code service and logic
|
|
490
|
+
- `@dismissible/nestjs-postgres-storage` - PostgreSQL storage adapter
|
|
491
|
+
- `@dismissible/nestjs-dynamodb-storage` - DynamoDB storage adapter
|
|
492
|
+
- `@dismissible/nestjs-storage` - Storage interface definition
|
|
493
|
+
- `@dismissible/nestjs-logger` - Logging abstraction
|
|
494
|
+
- `@dismissible/nestjs-jwt-auth-hook` - JWT authentication hook
|
|
495
|
+
- `@dismissible/react-client` - React client for the Dismissible system
|
|
496
|
+
|
|
497
|
+
## License
|
|
498
|
+
|
|
499
|
+
MIT
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { execSync } = require('child_process');
|
|
3
|
+
|
|
4
|
+
const storageType = process.env.DISMISSIBLE_STORAGE_TYPE || '';
|
|
5
|
+
|
|
6
|
+
switch (storageType) {
|
|
7
|
+
case 'postgres':
|
|
8
|
+
console.log('Running Postgres storage setup...');
|
|
9
|
+
execSync('npm run storage:setup:postgres', { stdio: 'inherit' });
|
|
10
|
+
break;
|
|
11
|
+
case 'dynamodb':
|
|
12
|
+
console.log('Running DynamoDB storage setup...');
|
|
13
|
+
execSync('npm run storage:setup:dynamodb', { stdio: 'inherit' });
|
|
14
|
+
break;
|
|
15
|
+
default:
|
|
16
|
+
if (storageType) {
|
|
17
|
+
console.log(`Warning: Unknown storage type '${storageType}'. Skipping storage setup.`);
|
|
18
|
+
} else {
|
|
19
|
+
console.log('DISMISSIBLE_STORAGE_TYPE not set. Skipping storage setup.');
|
|
20
|
+
}
|
|
21
|
+
process.exit(0);
|
|
22
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
server:
|
|
2
|
+
port: 3001
|
|
3
|
+
|
|
4
|
+
swagger:
|
|
5
|
+
enabled: true
|
|
6
|
+
path: docs
|
|
7
|
+
|
|
8
|
+
helmet:
|
|
9
|
+
enabled: false
|
|
10
|
+
|
|
11
|
+
cors:
|
|
12
|
+
enabled: false
|
|
13
|
+
|
|
14
|
+
storage:
|
|
15
|
+
# postgres | dynamodb | memory
|
|
16
|
+
type: ${DISMISSIBLE_STORAGE_TYPE:-memory}
|
|
17
|
+
postgres:
|
|
18
|
+
connectionString: postgresql://postgres:postgres@localhost:5432/dismissible
|
|
19
|
+
dynamodb:
|
|
20
|
+
tableName: dismissible-items
|
|
21
|
+
region: us-east-1
|
|
22
|
+
endpoint: http://localhost:4566
|
|
23
|
+
accessKeyId: test
|
|
24
|
+
secretAccessKey: test
|
|
25
|
+
|
|
26
|
+
jwtAuth:
|
|
27
|
+
enabled: false
|
|
28
|
+
|
|
29
|
+
validation:
|
|
30
|
+
disableErrorMessages: false
|
|
31
|
+
whitelist: false
|
|
32
|
+
forbidNonWhitelisted: false
|
|
33
|
+
transform: false
|
package/config/.env.yaml
CHANGED
|
@@ -15,14 +15,24 @@ helmet:
|
|
|
15
15
|
|
|
16
16
|
cors:
|
|
17
17
|
enabled: ${DISMISSIBLE_CORS_ENABLED:-true}
|
|
18
|
-
origins: ${DISMISSIBLE_CORS_ORIGINS:-
|
|
18
|
+
origins: ${DISMISSIBLE_CORS_ORIGINS:-}
|
|
19
19
|
methods: ${DISMISSIBLE_CORS_METHODS:-GET,POST,DELETE,OPTIONS}
|
|
20
20
|
allowedHeaders: ${DISMISSIBLE_CORS_ALLOWED_HEADERS:-Content-Type,Authorization,x-request-id}
|
|
21
21
|
credentials: ${DISMISSIBLE_CORS_CREDENTIALS:-true}
|
|
22
22
|
maxAge: ${DISMISSIBLE_CORS_MAX_AGE:-86400}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
storage:
|
|
25
|
+
# postgres | dynamodb | memory
|
|
26
|
+
type: ${DISMISSIBLE_STORAGE_TYPE:-memory}
|
|
27
|
+
postgres:
|
|
28
|
+
connectionString: ${DISMISSIBLE_STORAGE_POSTGRES_CONNECTION_STRING:-}
|
|
29
|
+
dynamodb:
|
|
30
|
+
tableName: ${DISMISSIBLE_STORAGE_DYNAMODB_TABLE_NAME:-dismissible-items}
|
|
31
|
+
region: ${DISMISSIBLE_STORAGE_DYNAMODB_AWS_REGION:-us-east-1}
|
|
32
|
+
endpoint: ${DISMISSIBLE_STORAGE_DYNAMODB_ENDPOINT:-}
|
|
33
|
+
accessKeyId: ${DISMISSIBLE_STORAGE_DYNAMODB_AWS_ACCESS_KEY_ID:-}
|
|
34
|
+
secretAccessKey: ${DISMISSIBLE_STORAGE_DYNAMODB_AWS_SECRET_ACCESS_KEY:-}
|
|
35
|
+
sessionToken: ${DISMISSIBLE_STORAGE_DYNAMODB_AWS_SESSION_TOKEN:-}
|
|
26
36
|
|
|
27
37
|
jwtAuth:
|
|
28
38
|
enabled: ${DISMISSIBLE_JWT_AUTH_ENABLED:-false}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dismissible/nestjs-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3-alpha.064e57a.0",
|
|
4
4
|
"description": "Dismissible API application",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -11,36 +11,44 @@
|
|
|
11
11
|
"types": "./src/index.d.ts"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
+
"files": [
|
|
15
|
+
"src",
|
|
16
|
+
"bin",
|
|
17
|
+
"config",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
14
20
|
"bin": {
|
|
15
|
-
"dismissible-api": "./src/main.js"
|
|
21
|
+
"dismissible-api": "./src/main.js",
|
|
22
|
+
"dismissible-storage-setup": "./bin/dismissible-storage-setup.js"
|
|
16
23
|
},
|
|
17
24
|
"scripts": {
|
|
18
25
|
"start": "node src/main.js",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
26
|
+
"storage:init": "npm run storage:postgres:init",
|
|
27
|
+
"storage:postgres:init": "npx dismissible-prisma generate",
|
|
28
|
+
"storage:setup": "npm run storage:setup:postgres && npm run storage:setup:dynamodb",
|
|
29
|
+
"storage:setup:postgres": "npx dismissible-prisma migrate deploy",
|
|
30
|
+
"storage:setup:dynamodb": "npx dismissible-dynamodb-setup"
|
|
24
31
|
},
|
|
25
32
|
"dependencies": {
|
|
26
|
-
"@dismissible/nestjs-
|
|
27
|
-
"@dismissible/nestjs-
|
|
28
|
-
"@dismissible/nestjs-jwt-auth-hook": "
|
|
29
|
-
"@dismissible/nestjs-storage": "
|
|
30
|
-
"@dismissible/nestjs-postgres-storage": "
|
|
31
|
-
"@dismissible/nestjs-
|
|
32
|
-
"@nestjs
|
|
33
|
-
"@nestjs/
|
|
34
|
-
"@nestjs/
|
|
35
|
-
"fastify": "
|
|
36
|
-
"
|
|
37
|
-
"@fastify/
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
40
|
-
"class-
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
33
|
+
"@dismissible/nestjs-core": "1.0.3-alpha.064e57a.0",
|
|
34
|
+
"@dismissible/nestjs-item": "1.0.3-alpha.064e57a.0",
|
|
35
|
+
"@dismissible/nestjs-jwt-auth-hook": "1.0.3-alpha.064e57a.0",
|
|
36
|
+
"@dismissible/nestjs-storage": "1.0.3-alpha.064e57a.0",
|
|
37
|
+
"@dismissible/nestjs-postgres-storage": "1.0.3-alpha.064e57a.0",
|
|
38
|
+
"@dismissible/nestjs-dynamodb-storage": "1.0.2",
|
|
39
|
+
"@dismissible/nestjs-logger": "1.0.3-alpha.064e57a.0",
|
|
40
|
+
"@nestjs/common": "11.1.10",
|
|
41
|
+
"@nestjs/core": "11.1.10",
|
|
42
|
+
"@nestjs/platform-fastify": "11.1.10",
|
|
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"
|
|
44
52
|
},
|
|
45
53
|
"keywords": [
|
|
46
54
|
"nestjs",
|
|
@@ -56,4 +64,4 @@
|
|
|
56
64
|
"access": "public"
|
|
57
65
|
},
|
|
58
66
|
"type": "commonjs"
|
|
59
|
-
}
|
|
67
|
+
}
|
package/src/app-test.factory.js
CHANGED
|
@@ -6,7 +6,7 @@ const testing_1 = require("@nestjs/testing");
|
|
|
6
6
|
const platform_fastify_1 = require("@nestjs/platform-fastify");
|
|
7
7
|
const app_module_1 = require("./app.module");
|
|
8
8
|
const app_setup_1 = require("./app.setup");
|
|
9
|
-
const
|
|
9
|
+
const nestjs_storage_1 = require("@dismissible/nestjs-storage");
|
|
10
10
|
async function createTestApp(options) {
|
|
11
11
|
let builder = testing_1.Test.createTestingModule({
|
|
12
12
|
imports: [app_module_1.AppModule.forRoot(options?.moduleOptions)],
|
|
@@ -18,13 +18,14 @@ async function createTestApp(options) {
|
|
|
18
18
|
const app = moduleFixture.createNestApplication(new platform_fastify_1.FastifyAdapter({
|
|
19
19
|
bodyLimit: 10 * 1024, // 10kb
|
|
20
20
|
}));
|
|
21
|
+
app.useLogger(false);
|
|
21
22
|
await (0, app_setup_1.configureApp)(app);
|
|
22
23
|
await app.init();
|
|
23
24
|
await app.getHttpAdapter().getInstance().ready();
|
|
24
25
|
return app;
|
|
25
26
|
}
|
|
26
27
|
async function cleanupTestData(app) {
|
|
27
|
-
const
|
|
28
|
-
await
|
|
28
|
+
const storage = app.get(nestjs_storage_1.DISMISSIBLE_STORAGE_ADAPTER);
|
|
29
|
+
await storage.deleteAll();
|
|
29
30
|
}
|
|
30
31
|
//# sourceMappingURL=app-test.factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-test.factory.js","sourceRoot":"","sources":["../../../api/src/app-test.factory.ts"],"names":[],"mappings":";;AAYA,
|
|
1
|
+
{"version":3,"file":"app-test.factory.js","sourceRoot":"","sources":["../../../api/src/app-test.factory.ts"],"names":[],"mappings":";;AAYA,sCAwBC;AAED,0CAGC;AAzCD,6CAA6D;AAE7D,+DAAkF;AAClF,6CAA2D;AAC3D,2CAA2C;AAC3C,gEAA+F;AAOxF,KAAK,UAAU,aAAa,CAAC,OAAwB;IAC1D,IAAI,OAAO,GAAG,cAAI,CAAC,mBAAmB,CAAC;QACrC,OAAO,EAAE,CAAC,sBAAS,CAAC,OAAO,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;KACrD,CAAC,CAAC;IAEH,IAAI,OAAO,EAAE,SAAS,EAAE,CAAC;QACvB,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;IAC9C,MAAM,GAAG,GAAG,aAAa,CAAC,qBAAqB,CAC7C,IAAI,iCAAc,CAAC;QACjB,SAAS,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO;KAC9B,CAAC,CACH,CAAC;IAEF,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAErB,MAAM,IAAA,wBAAY,EAAC,GAAG,CAAC,CAAC;IACxB,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAEjB,MAAM,GAAG,CAAC,cAAc,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,CAAC;IAEjD,OAAO,GAAG,CAAC;AACb,CAAC;AAEM,KAAK,UAAU,eAAe,CAAC,GAAqB;IACzD,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAsB,4CAA2B,CAAC,CAAC;IAC1E,MAAM,OAAO,CAAC,SAAS,EAAE,CAAC;AAC5B,CAAC"}
|
package/src/app.module.js
CHANGED
|
@@ -8,8 +8,8 @@ const health_1 = require("./health");
|
|
|
8
8
|
const config_1 = require("./config");
|
|
9
9
|
const app_config_1 = require("./config/app.config");
|
|
10
10
|
const path_1 = require("path");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const nestjs_core_1 = require("@dismissible/nestjs-core");
|
|
12
|
+
const dynamic_storage_module_1 = require("./storage/dynamic-storage.module");
|
|
13
13
|
const nestjs_jwt_auth_hook_1 = require("@dismissible/nestjs-jwt-auth-hook");
|
|
14
14
|
let AppModule = AppModule_1 = class AppModule {
|
|
15
15
|
static forRoot(options) {
|
|
@@ -31,16 +31,15 @@ let AppModule = AppModule_1 = class AppModule {
|
|
|
31
31
|
useFactory: (config) => config,
|
|
32
32
|
inject: [nestjs_jwt_auth_hook_1.JwtAuthHookConfig],
|
|
33
33
|
}),
|
|
34
|
-
|
|
34
|
+
nestjs_core_1.DismissibleModule.forRoot({
|
|
35
35
|
logger: options?.logger,
|
|
36
36
|
hooks: [nestjs_jwt_auth_hook_1.JwtAuthHook],
|
|
37
|
-
storage:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
inject: [nestjs_postgres_storage_1.PostgresStorageConfig],
|
|
37
|
+
storage: dynamic_storage_module_1.DynamicStorageModule.forRootAsync({
|
|
38
|
+
// TODO: nestjs doesn't support optional dynamic modules.
|
|
39
|
+
// So instead, we are just using the env vars to switch between modules.
|
|
40
|
+
// This isn't ideal, but there's not a great option. I will look to see
|
|
41
|
+
// if we can raise an issue similar to this: https://github.com/nestjs/nest/issues/9868
|
|
42
|
+
storage: process.env.DISMISSIBLE_STORAGE_TYPE,
|
|
44
43
|
}),
|
|
45
44
|
}),
|
|
46
45
|
],
|
package/src/app.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../../api/src/app.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAA6E;AAC7E,qCAAwC;AACxC,qCAAwC;AACxC,oDAAgD;AAChD,+BAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../../api/src/app.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAA6E;AAC7E,qCAAwC;AACxC,qCAAwC;AACxC,oDAAgD;AAChD,+BAA4B;AAC5B,0DAA6D;AAG7D,6EAAwE;AACxE,4EAI2C;AAWpC,IAAM,SAAS,iBAAf,MAAM,SAAS;IACpB,MAAM,CAAC,OAAO,CAAC,OAA0B;QACvC,OAAO;YACL,MAAM,EAAE,WAAS;YACjB,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC;SACnC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,OAA0B;QACjD,OAAO;YACL,OAAO,EAAE;gBACP,qBAAY,CAAC,OAAO,CAAC;oBACnB,IAAI,EAAE,OAAO,EAAE,UAAU,IAAI,IAAA,WAAI,EAAC,SAAS,EAAE,WAAW,CAAC;oBACzD,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,sBAAS;iBACrC,CAAC;gBACF,qBAAY;gBACZ,GAAG,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC;gBAC3B,wCAAiB,CAAC,YAAY,CAAC;oBAC7B,UAAU,EAAE,CAAC,MAAyB,EAAE,EAAE,CAAC,MAAM;oBACjD,MAAM,EAAE,CAAC,wCAAiB,CAAC;iBAC5B,CAAC;gBACF,+BAAiB,CAAC,OAAO,CAAC;oBACxB,MAAM,EAAE,OAAO,EAAE,MAAM;oBACvB,KAAK,EAAE,CAAC,kCAAW,CAAC;oBACpB,OAAO,EAAE,6CAAoB,CAAC,YAAY,CAAC;wBACzC,yDAAyD;wBACzD,0EAA0E;wBAC1E,yEAAyE;wBACzE,yFAAyF;wBACzF,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAuC;qBAC7D,CAAC;iBACH,CAAC;aACH;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAnCY,8BAAS;oBAAT,SAAS;IADrB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,SAAS,CAmCrB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SwaggerConfig } from '../swagger';
|
|
2
2
|
import { DefaultAppConfig } from './default-app.config';
|
|
3
|
-
import { PostgresStorageConfig } from '@dismissible/nestjs-postgres-storage';
|
|
4
3
|
import { JwtAuthHookConfig } from '@dismissible/nestjs-jwt-auth-hook';
|
|
4
|
+
import { StorageConfig } from '../storage/storage.config';
|
|
5
5
|
export declare class AppConfig extends DefaultAppConfig {
|
|
6
6
|
readonly swagger: SwaggerConfig;
|
|
7
|
-
readonly
|
|
7
|
+
readonly storage: StorageConfig;
|
|
8
8
|
readonly jwtAuth: JwtAuthHookConfig;
|
|
9
9
|
}
|
package/src/config/app.config.js
CHANGED
|
@@ -6,23 +6,26 @@ const class_validator_1 = require("class-validator");
|
|
|
6
6
|
const class_transformer_1 = require("class-transformer");
|
|
7
7
|
const swagger_1 = require("../swagger");
|
|
8
8
|
const default_app_config_1 = require("./default-app.config");
|
|
9
|
-
const nestjs_postgres_storage_1 = require("@dismissible/nestjs-postgres-storage");
|
|
10
9
|
const nestjs_jwt_auth_hook_1 = require("@dismissible/nestjs-jwt-auth-hook");
|
|
10
|
+
const storage_config_1 = require("../storage/storage.config");
|
|
11
11
|
class AppConfig extends default_app_config_1.DefaultAppConfig {
|
|
12
12
|
}
|
|
13
13
|
exports.AppConfig = AppConfig;
|
|
14
14
|
tslib_1.__decorate([
|
|
15
15
|
(0, class_validator_1.ValidateNested)(),
|
|
16
|
+
(0, class_validator_1.IsDefined)(),
|
|
16
17
|
(0, class_transformer_1.Type)(() => swagger_1.SwaggerConfig),
|
|
17
18
|
tslib_1.__metadata("design:type", swagger_1.SwaggerConfig)
|
|
18
19
|
], AppConfig.prototype, "swagger", void 0);
|
|
19
20
|
tslib_1.__decorate([
|
|
20
21
|
(0, class_validator_1.ValidateNested)(),
|
|
21
|
-
(0,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
(0, class_validator_1.IsDefined)(),
|
|
23
|
+
(0, class_transformer_1.Type)(() => storage_config_1.StorageConfig),
|
|
24
|
+
tslib_1.__metadata("design:type", storage_config_1.StorageConfig)
|
|
25
|
+
], AppConfig.prototype, "storage", void 0);
|
|
24
26
|
tslib_1.__decorate([
|
|
25
27
|
(0, class_validator_1.ValidateNested)(),
|
|
28
|
+
(0, class_validator_1.IsDefined)(),
|
|
26
29
|
(0, class_transformer_1.Type)(() => nestjs_jwt_auth_hook_1.JwtAuthHookConfig),
|
|
27
30
|
tslib_1.__metadata("design:type", nestjs_jwt_auth_hook_1.JwtAuthHookConfig)
|
|
28
31
|
], AppConfig.prototype, "jwtAuth", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.config.js","sourceRoot":"","sources":["../../../../api/src/config/app.config.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"app.config.js","sourceRoot":"","sources":["../../../../api/src/config/app.config.ts"],"names":[],"mappings":";;;;AAAA,qDAA4D;AAC5D,yDAAyC;AACzC,wCAA2C;AAC3C,6DAAwD;AACxD,4EAAsE;AACtE,8DAA0D;AAE1D,MAAa,SAAU,SAAQ,qCAAgB;CAe9C;AAfD,8BAeC;AAXiB;IAHf,IAAA,gCAAc,GAAE;IAChB,IAAA,2BAAS,GAAE;IACX,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,uBAAa,CAAC;sCACA,uBAAa;0CAAC;AAKxB;IAHf,IAAA,gCAAc,GAAE;IAChB,IAAA,2BAAS,GAAE;IACX,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,8BAAa,CAAC;sCACA,8BAAa;0CAAC;AAKxB;IAHf,IAAA,gCAAc,GAAE;IAChB,IAAA,2BAAS,GAAE;IACX,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,wCAAiB,CAAC;sCACJ,wCAAiB;0CAAC"}
|
|
@@ -22,6 +22,7 @@ let ConfigModule = ConfigModule_1 = class ConfigModule {
|
|
|
22
22
|
schema: options.schema,
|
|
23
23
|
load: [
|
|
24
24
|
(0, nest_typed_config_1.fileLoader)({
|
|
25
|
+
basename: process.env.NODE_ENV ? '.env' : `.env.${process.env.NODE_ENV}`,
|
|
25
26
|
searchFrom: configPath,
|
|
26
27
|
ignoreEnvironmentVariableSubstitution: ignoreEnvSubstitution,
|
|
27
28
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.module.js","sourceRoot":"","sources":["../../../../api/src/config/config.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAA+D;AAC/D,yDAAkE;AAClE,+BAA4B;AAqBrB,IAAM,YAAY,oBAAlB,MAAM,YAAY;IACvB;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAmB,OAAgC;QAC/D,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,IAAA,WAAI,EAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QACnE,MAAM,qBAAqB,GAAG,OAAO,CAAC,qCAAqC,IAAI,KAAK,CAAC;QAErF,OAAO;YACL,MAAM,EAAE,cAAY;YACpB,OAAO,EAAE;gBACP,qCAAiB,CAAC,OAAO,CAAC;oBACxB,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,IAAI,EAAE;wBACJ,IAAA,8BAAU,EAAC;4BACT,UAAU,EAAE,UAAU;4BACtB,qCAAqC,EAAE,qBAAqB;yBAC7D,CAAC;qBACH;iBACF,CAAC;aACH;YACD,OAAO,EAAE,CAAC,qCAAiB,CAAC;SAC7B,CAAC;IACJ,CAAC;CACF,CAAA;
|
|
1
|
+
{"version":3,"file":"config.module.js","sourceRoot":"","sources":["../../../../api/src/config/config.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAA+D;AAC/D,yDAAkE;AAClE,+BAA4B;AAqBrB,IAAM,YAAY,oBAAlB,MAAM,YAAY;IACvB;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAmB,OAAgC;QAC/D,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,IAAA,WAAI,EAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QACnE,MAAM,qBAAqB,GAAG,OAAO,CAAC,qCAAqC,IAAI,KAAK,CAAC;QAErF,OAAO;YACL,MAAM,EAAE,cAAY;YACpB,OAAO,EAAE;gBACP,qCAAiB,CAAC,OAAO,CAAC;oBACxB,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,IAAI,EAAE;wBACJ,IAAA,8BAAU,EAAC;4BACT,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE;4BACxE,UAAU,EAAE,UAAU;4BACtB,qCAAqC,EAAE,qBAAqB;yBAC7D,CAAC;qBACH;iBACF,CAAC;aACH;YACD,OAAO,EAAE,CAAC,qCAAiB,CAAC;SAC7B,CAAC;IACJ,CAAC;CACF,CAAA;AA3BY,oCAAY;uBAAZ,YAAY;IAFxB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,YAAY,CA2BxB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { StorageType } from './storage.config';
|
|
3
|
+
export type DynamicStorageModuleOptions = {
|
|
4
|
+
storage?: StorageType;
|
|
5
|
+
};
|
|
6
|
+
export declare class DynamicStorageModule {
|
|
7
|
+
static forRootAsync({ storage }: DynamicStorageModuleOptions): DynamicModule;
|
|
8
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamicStorageModule = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const nestjs_postgres_storage_1 = require("@dismissible/nestjs-postgres-storage");
|
|
7
|
+
const storage_config_1 = require("./storage.config");
|
|
8
|
+
const nestjs_dynamodb_storage_1 = require("@dismissible/nestjs-dynamodb-storage");
|
|
9
|
+
const nestjs_storage_1 = require("@dismissible/nestjs-storage");
|
|
10
|
+
let DynamicStorageModule = class DynamicStorageModule {
|
|
11
|
+
static forRootAsync({ storage }) {
|
|
12
|
+
switch (storage) {
|
|
13
|
+
case storage_config_1.StorageType.DYNAMODB:
|
|
14
|
+
return nestjs_dynamodb_storage_1.DynamoDBStorageModule.forRootAsync({
|
|
15
|
+
useFactory: (config) => config.dynamodb,
|
|
16
|
+
inject: [storage_config_1.StorageConfig],
|
|
17
|
+
});
|
|
18
|
+
case storage_config_1.StorageType.POSTGRES:
|
|
19
|
+
return nestjs_postgres_storage_1.PostgresStorageModule.forRootAsync({
|
|
20
|
+
useFactory: (config) => config.postgres,
|
|
21
|
+
inject: [storage_config_1.StorageConfig],
|
|
22
|
+
});
|
|
23
|
+
case storage_config_1.StorageType.MEMORY:
|
|
24
|
+
default:
|
|
25
|
+
return nestjs_storage_1.MemoryStorageModule.forRoot();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.DynamicStorageModule = DynamicStorageModule;
|
|
30
|
+
exports.DynamicStorageModule = DynamicStorageModule = tslib_1.__decorate([
|
|
31
|
+
(0, common_1.Module)({})
|
|
32
|
+
], DynamicStorageModule);
|
|
33
|
+
//# sourceMappingURL=dynamic-storage.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-storage.module.js","sourceRoot":"","sources":["../../../../api/src/storage/dynamic-storage.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAuD;AACvD,kFAA6E;AAC7E,qDAA8D;AAC9D,kFAA6E;AAC7E,gEAAkE;AAO3D,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B,MAAM,CAAC,YAAY,CAAC,EAAE,OAAO,EAA+B;QAC1D,QAAQ,OAAO,EAAE,CAAC;YAChB,KAAK,4BAAW,CAAC,QAAQ;gBACvB,OAAO,+CAAqB,CAAC,YAAY,CAAC;oBACxC,UAAU,EAAE,CAAC,MAAqB,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ;oBACtD,MAAM,EAAE,CAAC,8BAAa,CAAC;iBACxB,CAAC,CAAC;YACL,KAAK,4BAAW,CAAC,QAAQ;gBACvB,OAAO,+CAAqB,CAAC,YAAY,CAAC;oBACxC,UAAU,EAAE,CAAC,MAAqB,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ;oBACtD,MAAM,EAAE,CAAC,8BAAa,CAAC;iBACxB,CAAC,CAAC;YACL,KAAK,4BAAW,CAAC,MAAM,CAAC;YACxB;gBACE,OAAO,oCAAmB,CAAC,OAAO,EAAE,CAAC;QACzC,CAAC;IACH,CAAC;CACF,CAAA;AAlBY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,oBAAoB,CAkBhC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PostgresStorageConfig } from '@dismissible/nestjs-postgres-storage';
|
|
2
|
+
import { DynamoDBStorageConfig } from '@dismissible/nestjs-dynamodb-storage';
|
|
3
|
+
export declare enum StorageType {
|
|
4
|
+
MEMORY = "memory",
|
|
5
|
+
POSTGRES = "postgres",
|
|
6
|
+
DYNAMODB = "dynamodb"
|
|
7
|
+
}
|
|
8
|
+
export declare class StorageConfig {
|
|
9
|
+
readonly type: StorageType;
|
|
10
|
+
readonly postgres: PostgresStorageConfig;
|
|
11
|
+
readonly dynamodb: DynamoDBStorageConfig;
|
|
12
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StorageConfig = exports.StorageType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const class_validator_1 = require("class-validator");
|
|
6
|
+
const class_transformer_1 = require("class-transformer");
|
|
7
|
+
const nestjs_postgres_storage_1 = require("@dismissible/nestjs-postgres-storage");
|
|
8
|
+
const nestjs_dynamodb_storage_1 = require("@dismissible/nestjs-dynamodb-storage");
|
|
9
|
+
var StorageType;
|
|
10
|
+
(function (StorageType) {
|
|
11
|
+
StorageType["MEMORY"] = "memory";
|
|
12
|
+
StorageType["POSTGRES"] = "postgres";
|
|
13
|
+
StorageType["DYNAMODB"] = "dynamodb";
|
|
14
|
+
})(StorageType || (exports.StorageType = StorageType = {}));
|
|
15
|
+
class StorageConfig {
|
|
16
|
+
}
|
|
17
|
+
exports.StorageConfig = StorageConfig;
|
|
18
|
+
tslib_1.__decorate([
|
|
19
|
+
(0, class_validator_1.IsDefined)(),
|
|
20
|
+
(0, class_validator_1.IsEnum)(StorageType),
|
|
21
|
+
(0, class_transformer_1.Transform)(({ value }) => {
|
|
22
|
+
if (!value)
|
|
23
|
+
return value;
|
|
24
|
+
if (Object.values(StorageType).includes(value)) {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
return StorageType[value] || value;
|
|
28
|
+
}),
|
|
29
|
+
tslib_1.__metadata("design:type", String)
|
|
30
|
+
], StorageConfig.prototype, "type", void 0);
|
|
31
|
+
tslib_1.__decorate([
|
|
32
|
+
(0, class_validator_1.ValidateIf)((o) => o.type === StorageType.POSTGRES),
|
|
33
|
+
(0, class_validator_1.IsDefined)(),
|
|
34
|
+
(0, class_validator_1.ValidateNested)(),
|
|
35
|
+
(0, class_transformer_1.Type)(() => nestjs_postgres_storage_1.PostgresStorageConfig),
|
|
36
|
+
tslib_1.__metadata("design:type", nestjs_postgres_storage_1.PostgresStorageConfig)
|
|
37
|
+
], StorageConfig.prototype, "postgres", void 0);
|
|
38
|
+
tslib_1.__decorate([
|
|
39
|
+
(0, class_validator_1.ValidateIf)((o) => o.type === StorageType.DYNAMODB),
|
|
40
|
+
(0, class_validator_1.IsDefined)(),
|
|
41
|
+
(0, class_validator_1.ValidateNested)(),
|
|
42
|
+
(0, class_transformer_1.Type)(() => nestjs_dynamodb_storage_1.DynamoDBStorageConfig),
|
|
43
|
+
tslib_1.__metadata("design:type", nestjs_dynamodb_storage_1.DynamoDBStorageConfig)
|
|
44
|
+
], StorageConfig.prototype, "dynamodb", void 0);
|
|
45
|
+
//# sourceMappingURL=storage.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.config.js","sourceRoot":"","sources":["../../../../api/src/storage/storage.config.ts"],"names":[],"mappings":";;;;AAAA,qDAAgF;AAChF,yDAAoD;AACpD,kFAA6E;AAC7E,kFAA6E;AAE7E,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,oCAAqB,CAAA;IACrB,oCAAqB,CAAA;AACvB,CAAC,EAJW,WAAW,2BAAX,WAAW,QAItB;AAED,MAAa,aAAa;CAuBzB;AAvBD,sCAuBC;AAbiB;IATf,IAAA,2BAAS,GAAE;IACX,IAAA,wBAAM,EAAC,WAAW,CAAC;IACnB,IAAA,6BAAS,EAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;QACvB,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QACzB,IAAI,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,KAAoB,CAAC,EAAE,CAAC;YAC9D,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,WAAW,CAAC,KAAiC,CAAC,IAAI,KAAK,CAAC;IACjE,CAAC,CAAC;;2CACiC;AAMnB;IAJf,IAAA,4BAAU,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,QAAQ,CAAC;IAClD,IAAA,2BAAS,GAAE;IACX,IAAA,gCAAc,GAAE;IAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,+CAAqB,CAAC;sCACP,+CAAqB;+CAAC;AAMjC;IAJf,IAAA,4BAAU,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,QAAQ,CAAC;IAClD,IAAA,2BAAS,GAAE;IACX,IAAA,gCAAc,GAAE;IAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,+CAAqB,CAAC;sCACP,+CAAqB;+CAAC"}
|