Experiments with NextJS API framework
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
@Get()
findAll(@Req() request: Request, @Res() response): string {
console.log(request);
return response.status(200).send('Total users list');
}
@Post('/create')
@HttpCode(200)
createUser(@Req() request, @Res() response) {
console.log(request);
if(request && request._body && request.body.name) {
return response.send(`Successfully created ${request.body.name}!`);
}
else return "User created successfully!"
}
Add the MogooseModule in app.module.ts imports
imports: [ MongooseModule.forRoot('mongodb://localhost:27017'), UsersModule ]
MongooseModule.forFeature([ { name: Movies.name, schema: MoviesSchema } ])
Refer users.module.ts file for more information to link with service and controller for the APIs
- Author - Nagendra Badiganti
This project is MIT licensed.