/node-joker

Node JS Boilerplate for building APIs with TypeScript, Vitest, Supertest and BiomeJS following best practices for code organization and testing.

Primary LanguageTypeScript

Node Joker Boilerplate

Joker

The starting point for your best Node.js API!

A modern Node.js boilerplate for building APIs with TypeScript, Vitest, Supertest and BiomeJS following best practices for code organization and testing.

Features

  • ๐Ÿš€ Modern Node.js & TypeScript: Built with Node.js and TypeScript, utilizing the latest features and type safety
  • ๐Ÿงฉ Colocated Code: Following Kent C. Dodds' article on colocation, keeping related code together
  • ๐Ÿงน Code Quality:
    • Biome for linting and formatting
    • Pre-commit hooks with lefthook
    • Commit message validation with commitlint
  • ๐Ÿงช Testing:
    • Vitest for unit testing
    • Vitest UI for visual test feedback
    • Test files colocated with source files

Project Structure

src/
โ”œโ”€โ”€ api/                    # API routes and controllers
โ”‚   โ””โ”€โ”€ item/              # Item-related features
โ”‚       โ”œโ”€โ”€ item.controller.ts  # Business logic
โ”‚       โ”œโ”€โ”€ item.model.ts       # Data models
โ”‚       โ”œโ”€โ”€ item.router.ts      # Route definitions
โ”‚       โ””โ”€โ”€ __tests__/
โ”‚           โ””โ”€โ”€ item.test.ts  # Tests for item feature
โ”œโ”€โ”€ config/                # Configuration files
โ”œโ”€โ”€ testHelpers/          # Test utilities
โ””โ”€โ”€ app.ts                # Application entry point

Development Setup and Commands

  1. Install Dependencies

    yarn install
  2. Development Server

    yarn dev
  3. Testing

    # Run tests in CLI
    yarn test
    
    # Run tests with UI
    yarn test:ui
  4. Code Quality

    # Lint
    yarn lint
    
    # Format
    yarn format
    
    # Type checking
    yarn typecheck

Path Aliases

The project uses path aliases for cleaner imports:

import { something } from '#src/something'
import { testHelper } from '#testHelpers/testHelper'
import { config } from '#config/config'

Contributing

  1. Create a feature branch
  2. Make your changes
  3. Run tests and linting
  4. Commit with a conventional commit message
  5. Push and create a pull request

License

MIT