To install an extension you can run Command Pallete using the command Ctrl + Shift + P or Cmd + Shift + P, type Install Extensions and finally give anEnter, done that search by BelleEpoque and you will find the extension
es6-nodejs-snippets.
To install an extension locally, you can run the ** Command Pallete ** using Ctrl + Shift + P or Cmd + Shift + P, typing Preferences: Configure User Snippets + New Global Snippets File OR New snippets for local project Create the files and copy the snippets.json AND ts-snippets.json. As shown in the gif below.
- JavaScript (.js)
- TypeScript (.ts)
Every space inside { } and ( ) means that this is pushed into next line :)
$ represent each step after tab.
TypeScript has own components and own snippets. Use search or just type ts before every component snippet.
I.E. tsrcc
| Prefix | Method |
|---|---|
imp→ |
import moduleName from 'module' |
imn→ |
import 'module' |
imd→ |
import { destructuredModule } from 'module' |
ime→ |
import * as alias from 'module' |
ima→ |
import { originalName as aliasName} from 'module' |
exp→ |
export default moduleName |
exd→ |
export { destructuredModule } from 'module' |
exa→ |
export { originalName as aliasName} from 'module' |
enf→ |
export const functionName = (params) => { } |
edf→ |
export default (params) => { } |
fre> |
array.forEach(currentItem => {}) |
fof→ |
for(const item of object) {} |
fin→ |
for(const item in object) {} |
anfn→ |
(params) => {} |
nfn→ |
const add = (params) => {} |
dar→ |
const [first, second] = [1,2] |
dob→ |
const {rename} = fs |
sti→ |
setInterval(() => {}); |
sto→ |
setTimeout(() => {}); |
prom→ |
return new Promise((resolve, reject) => {}); |
thenc→ |
.then((res) => {}).catch((err) => {}); |
met→ |
${1:methodName}(${1:params}) {$3}; |
met→ |
methodName = (params) => { } |
amet→ |
async method(params) {} |
constructor |
constructor() {} |
| Prefix | Method |
|---|---|
clg→ |
console.log(object) |
clo→ |
console.log("object", object) |
ctm→ |
console.time("timeId") |
cte→ |
console.timeEnd("timeId") |
cas→ |
console.assert(expression,object) |
ccl→ |
console.clear() |
cco→ |
console.count(label) |
cdi→ |
console.dir |
cer→ |
console.error(object) |
cgr→ |
console.group(label) |
cge→ |
console.groupEnd() |
ctr→ |
console.trace(object) |
cwa→ |
console.warn |
cin→ |
console.info |
| Prefix | Method |
|---|---|
cms→ |
Create a Sequelize model |
ccms→ |
${1:columns}: Sequelize.${2:STRING}$3, |
ccmss→ |
${1:column}: Sequelize.STRING$2 |
ccmsi→ |
${1:column}: Sequelize.INTERGER$2 |
ccmsf→ |
${1:column}: Sequelize.FLOAT$2 |
ccmse→ |
${1:column}: Sequelize.ENUM$2 |
| Prefix | Method |
|---|---|
cfmoo→ |
Create a Moongoose model |
| Prefix | Method |
|---|---|
cfne→ |
Creates a basic express file |
tcfne→ |
Creates a basic express file TS |
fcc→ |
create file of class |
fcce→ |
create a file of class with extends |
fccd→ |
create a file of class destruct |
fgr→ |
Creates routes.js |
fgrd→ |
Creates destruct routes.js |
gr→ |
${1:routes}.${2:get}('/${3:rotas}', ${4:Rota}Controller.${5:index}); |
grp→ |
${1:routes}.${2:get}('/${3:rotas}/:${4:id}', ${5:Rota}Controller.${6:index}); |
grpm→ |
${1:routes}.${2:get}('/${3:rotas}/:${4:id}', ${5:midware} , ${6:Rota}Controller.${7:index}); |
grm→ |
${1:routes}.${2:get}('/${3:rotas}', ${4:middlewares} ${5:Rota}Controller.${6:index}); |
constructor() {}new Promise((resolve, reject) => {,
let condition = false;
if(condition) {
resolve('data')
} else {
reject('error')
}
})const express = require('express');
const ${1:server} = express();,
${1:server}.use(express.json());,
const port = 3000;,
${1:server}.get('/', (req, res) => json({message: 'Hello World!'}));,
${1:server}.listen(port);import { Router } from 'express';
const ${1:routes} = new Router();
export default ${1:routes};${1:app}.${2:get}('/${3:rotas}', (req, res) => {
res.json({});
});${1:app}.${2:get}('/${3:rotas}', ${4:middleware} , (req, res) => {
res.json({});
});${1:app}.${2:get}('/${3:rotas}/:${4:id}', (req, res) => {
res.json({});
});${1:app}.${2:get}('/${3:rotas}/:${5:id}', ${4:middleware}, (req, res) => {
res.json({});
});class $TM_FILENAME_BASE {}
export default new $TM_FILENAME_BASE();class $TM_FILENAME_BASE extends ${1:Class} {
}
export default new $TM_FILENAME_BASE();import Sequelize, { Model } from 'sequelize';
class $TM_FILENAME_BASE extends Model {
static init(sequelize) {
super.init(
{
$1
},
{ sequelize }
);
return this;
}
}
export default $TM_FILENAME_BASE;import mongoose from 'mongoose';
const ${1:ExemploSchema} = new mongoose.Schema({});
export default mongoose.model(' $TM_FILENAME_BASE', ${1:ExemploSchema});${1:server}.use(req, res, next) => {
next();
});${1:app}.use(function(err, req, res, next) {
console.error(err.stack);
res.status(500).send('Algo Errado :/!');
});function ${1:functionName} (req, res, next) => {
next();
});function ${1:functionName} (req, res, next) => {
next();
}); interface Interface {
label: string;
} export interface Interface {
label: value;
}
export interface IterfaceMethod {
IterfaceMethod(paramether): IterfaceMethod<IterfaceMethod>;
}app.get('/rotas', (request: Request, response: Response) => {
response.json({});
});app.get('/rotas/:id', (request: Request, response: Response) => {
response.json({});
});app.get('/rotas/:id', [middleware], (request: Request, response: Response) => {
response.json({});
}); app.get('/rotas', [middleware] , (request: Request, response: Response) => {
response.json({});
});
}); class name implements Class {}
export default new name();class name implements Class {}
export { name };- Make the fork of the project (https://github.com/lucaslamar/es6-nodejs-snippets/fork)
- Create a branch for your modification (
git checkout -b feature/fooBar) - Make commit (
git commit -m 'feat: estrutura inicial do projeto') - Push (
git push origin feature/fooBar) - Create a new Pull Request
Distributed under the MIT license. See LICENSE for more information.
Lucas Lamar - Github - [email protected]
