Nest JS Snippets
Simple snippets pack to increase your productivity when developing with nestjs
Created by Manu Codes
Installation
The snippets is available in the VS Code marketplace. Search NestJS Snippets, install and go!
Usage
Prefix |
Method |
nestcon→ |
Create new simple nest controller |
nestcrud→ |
Create new CRUD controller |
nestdel→ |
Create a Delete method |
nestget→ |
Create a Get method |
nestgetparam→ |
Create a Get method with url param |
nestpost→ |
Create a Post method |
nestput→ |
Create a Put method |
nestmid→ |
Create a middleware class |
nestguard→ |
Create a guard class |
nestschema→ |
Create new mongodb schema |
nestcron→ |
Create new shcedule class to use crons |
Examples
This is the result of typing nestcon
and press enter on your nest .ts file:
import { Controller } from '@nestjs/common';
@Controller('utl')
export class MyController {
constructor() {}
}
This is the result of typing nestgetparam
and press enter on your nest .ts file:
@Get('/:param')
async name(@Param('param') param: any, @Req() req: any, @Res() res: Response){
// Put your magic here
}
This is the result of typing nestschema
and press enter on your nest .ts file:
import { Prop, Schema, SchemaFactoryx} from '@nestjs/mongoose';
import { Document } from 'mongoose';
export type MySchemaDocument = MySchema & Document;
@Schema({
// timestamp: true
})
export class MySchema {
@Prop()
propName: string;
// More props here
}
export const MySchemaSchema = SchemaFactory.createForClass(MySchema);