Какие инструменты используешь для развития?
Комментарии (1)
Ответ сгенерирован нейросетью и может содержать ошибки
Инструменты для разработки Node.js Backend
Эффективность разработки зависит от правильного набора инструментов. Вот полный стек, который я использую в production проектах.
IDE и Редакторы
VS Code — основной выбор (с расширениями):
// .vscode/extensions.json
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"ms-vscode.vscode-typescript-next",
"ms-vscode-docker.remote-containers",
"eamodio.gitlens",
"orta.vscode-jest"
]
}
WebStorm — alternative (платная, но мощная для Node.js)
Package Manager
npm или pnpm — управление зависимостями:
# pnpm быстрее и экономнее
npm install -g pnpm
pnpm add express
pnpm install
# npm workspaces для монорепозитория
npm workspaces list
Build Tools и Bundlers
esbuild — самый быстрый JavaScript bundler:
// build.js
const esbuild = require('esbuild');
esbuild.buildSync({
entryPoints: ['src/index.ts'],
bundle: true,
outfile: 'dist/index.js',
minify: true,
format: 'cjs',
platform: 'node',
target: 'node18'
});
tsc (TypeScript Compiler) — для типизации
// tsconfig.json
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}
Linting и Formatting
ESLint — анализ кода и ошибок:
// .eslintrc.js
module.exports = {
parser: '@typescript-eslint/parser',
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
rules: {
'no-console': 'warn',
'no-unused-vars': 'error',
'@typescript-eslint/explicit-function-return-types': 'error',
'no-empty-function': 'error'
}
};
Prettier — форматирование кода:
// .prettierrc
{
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 100,
"tabWidth": 2
}
husky + lint-staged — pre-commit хуки:
// package.json
{
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.ts": ["eslint --fix", "prettier --write"]
}
}
Testing Framework
Jest — основной фреймворк:
// jest.config.js
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/__tests__/**/*.test.ts'],
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.d.ts',
'!src/index.ts'
],
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80
}
}
};
Vitest — альтернатива (быстрее, для нативного ESM):
pnpm add -D vitest
npm test -- --ui # UI режим
Supertest — HTTP тестирование:
const request = require('supertest');
const app = require('./app');
describe('GET /users/:id', () => {
it('returns user by id', async () => {
const response = await request(app)
.get('/users/123')
.expect(200)
.expect('Content-Type', /json/);
expect(response.body).toHaveProperty('id', 123);
});
});
API Development
Postman или Insomnia — тестирование API:
// postman-collection.json
{
"info": {
"name": "API Tests"
},
"item": [{
"name": "Get User",
"request": {
"method": "GET",
"url": "http://localhost:3000/api/users/{{userId}}",
"header": {
"Authorization": "Bearer {{token}}"
}
}
}]
}
REST Client extension (VS Code):
# requests.http
GET http://localhost:3000/api/users/123
Authorization: Bearer token123
###
POST http://localhost:3000/api/users
Content-Type: application/json
{
"name": "John",
"email": "john@example.com"
}
Database Tools
DataGrip или DBeaver — GUI для БД
psql — CLI для PostgreSQL:
psql -h localhost -U postgres -d mydb
\dt # List tables
\d users # Describe table
TypeORM CLI или Sequelize CLI — миграции:
sequelize db:migrate
sequelize db:seed:all
Debugging
Node.js Inspector — встроенный отладчик:
node --inspect server.js
# Откроется chrome://inspect
VS Code Debugger:
// .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/src/index.ts",
"preLaunchTask": "tsc: build",
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}
]
}
Logging и Monitoring
Winston — логирование:
const winston = require('winston');
const logger = winston.createLogger({
level: process.env.LOG_LEVEL || 'info',
format: winston.format.json(),
transports: [
new winston.transports.File({ filename: 'error.log', level: 'error' }),
new winston.transports.File({ filename: 'combined.log' })
]
});
logger.info('Server started', { port: 3000 });
logger.error('Database error', { error: err });
Prometheus + Grafana — метрики:
const promClient = require('prom-client');
const httpRequestDuration = new promClient.Histogram({
name: 'http_request_duration_ms',
help: 'HTTP request latency in milliseconds',
labelNames: ['method', 'route', 'status'],
buckets: [10, 30, 100, 300, 1000]
});
Docker и Containers
Docker Desktop — локальная разработка контейнеров
Docker Compose — мультиконтейнерные приложения:
# docker-compose.yml
version: '3.8'
services:
app:
build: .
ports:
- "3000:3000"
environment:
DATABASE_URL: postgres://user:pass@db:5432/mydb
depends_on:
- db
db:
image: postgres:15
environment:
POSTGRES_PASSWORD: password
POSTGRES_DB: mydb
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
Version Control
Git + GitHub или GitLab
Conventional Commits — стандартный формат:
git commit -m "feat: add user authentication"
git commit -m "fix: prevent race condition"
git commit -m "docs: update API documentation"
Performance Profiling
clinic.js — диагностика performance:
npm install -g clinic
clinic doctor -- node server.js
clinic flame -- node server.js # Flamegraph
CI/CD
GitHub Actions — автоматизация:
# .github/workflows/test.yml
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '18'
- run: npm ci
- run: npm run lint
- run: npm test
- run: npm run build
Документация
OpenAPI/Swagger — API документация:
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./swagger.json');
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
Summary
Минимальный стек:
- VS Code + ESLint + Prettier
- npm/pnpm
- TypeScript
- Jest
- Postman/Insomnia
- Docker
Production стек:
-
- Winston для логирования
-
- Prometheus для метрик
-
- GitHub Actions для CI/CD
-
- clinic.js для профилирования
-
- OpenAPI для документации
Правильные инструменты экономят часы разработки и предотвращают ошибки в production.