add constraint
This commit is contained in:
parent
e71f08a3de
commit
a08964bd4a
@ -2,6 +2,8 @@ import { NestFactory } from '@nestjs/core';
|
|||||||
|
|
||||||
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
|
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
|
||||||
|
|
||||||
|
import { useContainer } from 'class-validator';
|
||||||
|
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
@ -10,6 +12,7 @@ async function bootstrap() {
|
|||||||
logger: ['error', 'warn'],
|
logger: ['error', 'warn'],
|
||||||
});
|
});
|
||||||
app.setGlobalPrefix('api');
|
app.setGlobalPrefix('api');
|
||||||
|
useContainer(app.select(AppModule), { fallbackOnErrors: true });
|
||||||
await app.listen(process.env.PORT ?? 3000, () => {
|
await app.listen(process.env.PORT ?? 3000, () => {
|
||||||
console.log('api: http://localhost:3000');
|
console.log('api: http://localhost:3000');
|
||||||
});
|
});
|
||||||
|
@ -5,6 +5,8 @@ import { DataSource, ObjectType } from 'typeorm';
|
|||||||
|
|
||||||
import { CUSTOM_REPOSITORY_METADATA } from '@/modules/database/constants';
|
import { CUSTOM_REPOSITORY_METADATA } from '@/modules/database/constants';
|
||||||
|
|
||||||
|
import { DataExistConstraint } from '../core/constraints/data.exist.constraint';
|
||||||
|
|
||||||
@Module({})
|
@Module({})
|
||||||
export class DatabaseModule {
|
export class DatabaseModule {
|
||||||
static forRoot(configRegister: () => TypeOrmModuleOptions): DynamicModule {
|
static forRoot(configRegister: () => TypeOrmModuleOptions): DynamicModule {
|
||||||
@ -12,6 +14,7 @@ export class DatabaseModule {
|
|||||||
global: true,
|
global: true,
|
||||||
module: DatabaseModule,
|
module: DatabaseModule,
|
||||||
imports: [TypeOrmModule.forRoot(configRegister())],
|
imports: [TypeOrmModule.forRoot(configRegister())],
|
||||||
|
providers: [DataExistConstraint],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
static forRepository<T extends Type<any>>(
|
static forRepository<T extends Type<any>>(
|
||||||
|
Loading…
Reference in New Issue
Block a user