@metapic/nestjs-utils 1.0.1 → 1.0.2
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 +20 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/nestjs.d.ts +10 -0
- package/dist/nestjs.d.ts.map +1 -0
- package/dist/nestjs.js +15 -0
- package/dist/nestjs.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typeorm.js +3 -3
- package/dist/typeorm.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
# nestjs-utils
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Utility helpers for [Nest.js](https://nestjs.com/) projects. Comes with opinionated defaults for [TypeORM](https://typeorm.io/), [Swagger](https://docs.nestjs.com/openapi/introduction) and serialisation:
|
|
4
|
+
|
|
5
|
+
- Symbols (e.g. DTO property names) always **camelCase**.
|
|
6
|
+
- API JSON payload property names always **snake_case**.
|
|
7
|
+
- Database column names always **snake_case**.
|
|
8
|
+
|
|
9
|
+
See the [example app](./example) for a fully wired showcase of all features.
|
|
10
|
+
|
|
11
|
+
**Important**: Serialisation uses [class-transformer](https://github.com/typestack/class-transformer)/[class-validator](https://github.com/typestack/class-validator) (see [Nest.js docs](https://docs.nestjs.com/techniques/serialization)). You can use the following helpers for easy setup (see also [`example/src/app.module.ts`](./example/src/app.module.ts))
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { Module } from '@nestjs/common'
|
|
15
|
+
import { SERIALIZATION_INTERCEPTOR, VALIDATION_PIPE } from '@metapic/nestjs-utils'
|
|
16
|
+
|
|
17
|
+
@Module({
|
|
18
|
+
providers: [SERIALIZATION_INTERCEPTOR, VALIDATION_PIPE],
|
|
19
|
+
})
|
|
20
|
+
export class AppModule {}
|
|
21
|
+
```
|
|
4
22
|
|
|
5
23
|
## Testing
|
|
6
24
|
|
|
7
|
-
All testing
|
|
25
|
+
All testing runs through the example app’s e2e suite: [example/test](example/test).
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,cAAc,CAAA"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,cAAc,CAAA"}
|
package/dist/nestjs.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ClassSerializerInterceptor, ValidationPipe } from '@nestjs/common';
|
|
2
|
+
export declare const SERIALIZATION_INTERCEPTOR: {
|
|
3
|
+
provide: string;
|
|
4
|
+
useClass: typeof ClassSerializerInterceptor;
|
|
5
|
+
};
|
|
6
|
+
export declare const VALIDATION_PIPE: {
|
|
7
|
+
provide: string;
|
|
8
|
+
useValue: ValidationPipe;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=nestjs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestjs.d.ts","sourceRoot":"","sources":["../src/nestjs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAc,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAGvF,eAAO,MAAM,yBAAyB;;;CAGrC,CAAA;AAED,eAAO,MAAM,eAAe;;;CAO3B,CAAA"}
|
package/dist/nestjs.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ClassSerializerInterceptor, HttpStatus, ValidationPipe } from '@nestjs/common';
|
|
2
|
+
import { APP_INTERCEPTOR, APP_PIPE } from '@nestjs/core';
|
|
3
|
+
export const SERIALIZATION_INTERCEPTOR = {
|
|
4
|
+
provide: APP_INTERCEPTOR,
|
|
5
|
+
useClass: ClassSerializerInterceptor,
|
|
6
|
+
};
|
|
7
|
+
export const VALIDATION_PIPE = {
|
|
8
|
+
provide: APP_PIPE,
|
|
9
|
+
useValue: new ValidationPipe({
|
|
10
|
+
transform: true,
|
|
11
|
+
transformOptions: { enableImplicitConversion: true },
|
|
12
|
+
errorHttpStatusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=nestjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestjs.js","sourceRoot":"","sources":["../src/nestjs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACvF,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAExD,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,OAAO,EAAE,eAAe;IACxB,QAAQ,EAAE,0BAA0B;CACrC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,IAAI,cAAc,CAAC;QAC3B,SAAS,EAAE,IAAI;QACf,gBAAgB,EAAE,EAAE,wBAAwB,EAAE,IAAI,EAAE;QACpD,mBAAmB,EAAE,UAAU,CAAC,oBAAoB;KACrD,CAAC;CACH,CAAA"}
|