Skip to content

Commit 202c2c8

Browse files
committed
fix: fixed issue with #7 when there is no cors middleware
1 parent 279ce11 commit 202c2c8

File tree

5 files changed

+1601
-1505
lines changed

5 files changed

+1601
-1505
lines changed

example-app/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
"test:e2e": "jest --config ./test/jest-e2e.json"
1919
},
2020
"dependencies": {
21-
"@admin-bro/express": "^3.0.0-beta.3",
22-
"@admin-bro/mongoose": "^1.0.0-beta.3",
23-
"@admin-bro/nestjs": "^1.0.0-beta.2",
21+
"@admin-bro/express": "^3.0.1",
22+
"@admin-bro/mongoose": "^1.1.0",
2423
"@nestjs/common": "^6.7.2",
2524
"@nestjs/core": "^6.7.2",
2625
"@nestjs/mongoose": "^7.0.2",
2726
"@nestjs/platform-express": "^6.7.2",
28-
"admin-bro": "^3.0.0-beta.12",
27+
"admin-bro": "^3.3.1",
28+
"class-transformer": "^0.3.1",
29+
"class-validator": "^0.12.2",
2930
"express": "^4.17.1",
3031
"express-formidable": "^1.2.0",
3132
"express-session": "^1.17.1",

example-app/src/app.controller.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
import { Controller, Get } from '@nestjs/common';
2-
import mongoose from 'mongoose';
1+
import { Body, Controller, Get, Post } from '@nestjs/common';
2+
import { IsString } from 'class-validator';
3+
import { Expose } from 'class-transformer';
34

45
import { AppService } from './app.service';
56

7+
export class Hello {
8+
@Expose()
9+
@IsString()
10+
public hello!: string
11+
}
12+
613
@Controller()
714
export class AppController {
815
constructor(private readonly appService: AppService) {}
@@ -11,4 +18,9 @@ export class AppController {
1118
public getHello(): string {
1219
return this.appService.getHello();
1320
}
21+
22+
@Post()
23+
public postHello(@Body() testBody: Hello): string {
24+
return testBody.hello;
25+
}
1426
}

example-app/src/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
import AdminBro from 'admin-bro';
22
import AdminBroMongoose from '@admin-bro/mongoose';
33
import { NestFactory } from '@nestjs/core';
4+
import { ValidationPipe } from '@nestjs/common';
45

56
import { AppModule } from './app.module';
67

78
AdminBro.registerAdapter(AdminBroMongoose);
89

910
const bootstrap = async () => {
1011
const app = await NestFactory.create(AppModule);
12+
app.useGlobalPipes(new ValidationPipe({
13+
transform: true,
14+
whitelist: true,
15+
}))
1116
await app.listen(3000);
1217
}
1318
bootstrap();

0 commit comments

Comments
 (0)