Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { CrudConfigService } from '@nestjsx/crud';
import { USER_REQUEST_KEY } from './constants';
// Important: load config before (!!!) you import AppModule
// https://github.com/nestjsx/crud/wiki/Controllers#global-options
CrudConfigService.load({
auth: {
property: USER_REQUEST_KEY,
},
routes: {
// exclude: ['createManyBase'],
},
});
import { HttpExceptionFilter } from '../shared/https-exception.filter';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe());
app.useGlobalFilters(new HttpExceptionFilter());
import { CrudConfigService } from '@nestjsx/crud';
/**
* Configure CRUD defaults
*/
CrudConfigService.load({
query: {
limit: 25,
maxLimit: 250,
},
routes: {
// exclude /bulk
exclude: ['createManyBase'],
},
params: {
id: {
field: 'id',
type: 'uuid',
primary: true,
},
},
});
import { Controller } from '@nestjs/common';
import { Crud } from '@nestjsx/crud';
import { ROUTE } from '../../config/constants';
import { UserAddress } from './address/address.entity';
import { AddressService } from './address/address.service';
import { BaseAddressController } from './address/address.base.controller';
/**
* User/address relation controller
* /customers/:userId/addresses
*/
@Crud({
model: {
type: UserAddress,
},
params: {
userId: {
field: 'userId',
type: 'uuid',
},
},
})
@Controller(`/${ROUTE.USERS}/:userId/${ROUTE.ADDRESSES}`)
export class UserAddressController extends BaseAddressController {
constructor(public service: AddressService) {
super(service);
}
}
import { Controller } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Crud } from '@nestjsx/crud';
import { Device } from './device.entity';
import { DevicesService } from './devices.service';
import { serialize } from './response';
@Crud({
model: { type: Device },
serialize,
params: {
deviceKey: {
field: 'deviceKey',
type: 'uuid',
primary: true,
},
},
routes: {
deleteOneBase: {
returnDeleted: true,
},
},
})
@ApiTags('devices')
import { Controller } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Crud, CrudAuth } from '@nestjsx/crud';
import { User } from '../users/user.entity';
import { UserProject } from './user-project.entity';
import { UserProjectsService } from './user-projects.service';
@Crud({
model: {
type: UserProject,
},
params: {
projectId: {
field: 'projectId',
type: 'number',
primary: true,
},
},
query: {
join: {
project: {
eager: true,
},
},
import { Controller } from '@nestjs/common';
import { Crud } from '@nestjsx/crud';
import { CrudType } from '@devon4node/common/serializer';
import { Employee } from '../model';
import { EmployeeCrudService } from '../services';
import { ApiUseTags } from '@nestjs/swagger';
@Crud({
model: {
type: Employee,
},
})
@CrudType(Employee)
@Controller('employee/employees')
@ApiUseTags('employee')
export class EmployeeCrudController {
constructor(public service: EmployeeCrudService) {}
}
import { Controller } from '@nestjs/common';
import { ApiUseTags } from '@nestjs/swagger';
import { Crud, CrudController, RestfulOptions } from '@nestjsx/crud';
import { User } from './user.entity';
import { UsersService } from './users.service';
@Crud(User, {
options: {
exclude: ['password'],
join: {
profile: {
allow: ['firstName', 'lastName'],
},
},
maxLimit: 10,
cache: 3000,
},
params: ['companyId'],
validation: {
validationError: {
target: false,
value: false,
},
import { Controller, Body } from '@nestjs/common';
import { Crud, CrudController, RestfulOptions, Feature } from '@nestjsx/crud';
import { Hero } from './hero.entity';
import { HeroesService } from './heroes.service';
@Crud(Hero)
@Controller('heroes')
export class HeroesCrudController implements CrudController {
paramsFilter = [];
options: RestfulOptions = {};
constructor(public service: HeroesService) {}
get base(): CrudController {
return this;
}
}
CrudController,
CrudOptions,
Override,
ParsedQuery,
ParsedOptions,
ParsedParams,
ParsedBody,
EntitiesBulk,
UsePathInterceptors,
RestfulParamsDto,
} from '@nestjsx/crud';
import { Company } from './company.entity';
import { CompaniesService } from './companies.service';
@Crud(Company, {
params: {},
routes: {},
options: {
join: {
users: {
exclude: ['password'],
},
},
sort: [{ field: 'id', order: 'DESC' }],
maxLimit: 5,
cache: 10000,
},
})
@ApiUseTags('companies')
@Controller('companies')
export class CompaniesController {
import { Controller } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Crud } from '@nestjsx/crud';
import { Company } from './company.entity';
import { CompaniesService } from './companies.service';
import { dto } from './dto';
import { serialize } from './response';
@Crud({
model: {
type: Company,
},
dto,
serialize,
query: {
alwaysPaginate: true,
join: {
users: {},
projects: {},
},
},
})
@ApiTags('companies')
@Controller('companies')
export class CompaniesController {