CtrlK
BlogDocsLog inGet started
Tessl Logo
SkillPublic

nodejs-best-practices

Node.js best practices e patterns

Quality

61%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Passed

No findings from the security scan

Fix and improve this skill with Tessl

tessl review fix ./skills/backend/nodejs/SKILL.md
SKILL.md
Quality
Evals
Security

Node.js Best Practices

Convenções baseadas em nodebestpractices e frameworks populares.


Framework Recomendado

Express (Leve e Flexível)

Para APIs simples e microserviços:

const express = require('express');
const app = express();

app.use(express.json());

app.get('/api/users', async (req, res) => {
  const users = await getUsers();
  res.json(users);
});

NestJS (Estruturado e TypeScript)

Para projetos maiores com arquitetura em módulos:

import { Module, Controller, Get } from '@nestjs/common';

@Controller('users')
export class UsersController {
  @Get()
  findAll() {
    return this.usersService.findAll();
  }
}

Estrutura de Projeto

Express

project/
├── src/
│   ├── routes/
│   ├── controllers/
│   ├── services/
│   ├── models/
│   ├── middleware/
│   └── app.js
├── tests/
└── package.json

NestJS

project/
├── src/
│   ├── users/
│   │   ├── users.module.ts
│   │   ├── users.controller.ts
│   │   ├── users.service.ts
│   │   └── users.entity.ts
│   └── app.module.ts
└── package.json

Error Handling

// Express
app.use((err, req, res, next) => {
  console.error(err.stack);
  res.status(500).json({ error: 'Internal Server Error' });
});

// NestJS
@Catch()
export class AllExceptionsFilter implements ExceptionFilter {
  catch(exception: unknown, host: ArgumentsHost) {
    // Handle error
  }
}

Environment Variables

SEMPRE usar variáveis de ambiente:

require('dotenv').config();

const config = {
  port: process.env.PORT || 3000,
  dbUrl: process.env.DATABASE_URL,
  jwtSecret: process.env.JWT_SECRET,
};

Checklist

  • Error handling implementado
  • Variáveis de ambiente configuradas
  • Estrutura de projeto organizada
  • TypeScript (quando usar NestJS)
  • Testes configurados
Repository

fernandezbaptiste/cursor-multiagent-system

Path

skills/backend/nodejs/SKILL.md

Last updated
First committed

Is this your skill?

If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.