Boilerplate for typescript server programing

Here are some recommended boilerplates and frameworks for TypeScript server programming, depending on your requirements:


NestJS is a progressive Node.js framework built with TypeScript. It provides an opinionated structure and is excellent for building scalable and maintainable server-side applications.

  • Features:

    • Dependency injection
    • Modular architecture
    • Built-in support for WebSockets, GraphQL, REST APIs
    • Easy integration with tools like Swagger, TypeORM, and Mongoose
  • Getting Started: Install Nest CLI:

    npm i -g @nestjs/cli
    nest new project-name
    

    Boilerplate is automatically generated with ready-to-use configurations for controllers, services, and modules.

  • Website: https://nestjs.com/


2. Express with TypeScript

Express.js is lightweight and minimal, making it ideal for developers who prefer flexibility over opinionated frameworks.

  • Boilerplate:
    You can start with an official or community-maintained TypeScript boilerplate like express-generator-typescript.

    npx express-generator-typescript my-app
    cd my-app
    npm install
    npm run dev
    
  • Features:

    • Basic TypeScript setup
    • Preconfigured ESLint and Prettier
    • Folder structure for routes, controllers, and middleware

3. Fastify with TypeScript

Fastify is a modern, lightweight web framework for Node.js, known for its performance.

  • Boilerplate:
    Use the Fastify TypeScript Starter.

    npx degit fastify/fastify-typescript my-app
    cd my-app
    npm install
    npm run dev
    
  • Features:

    • Performance-oriented
    • Built-in schema validation with JSON Schema
    • Flexible plugin-based architecture

4. Koa with TypeScript

Koa.js is a minimalist framework like Express but designed to use async/await out of the box.

  • Boilerplate:
    Use the koa-ts-boilerplate.

    git clone https://github.com/RobinBuschmann/koa-ts-boilerplate.git my-app
    cd my-app
    npm install
    npm run dev
    
  • Features:

    • Simple middleware handling
    • Fully customizable

5. GraphQL with Apollo Server (TypeScript)

For APIs that need GraphQL, Apollo Server is a great choice with excellent TypeScript support.

  • Boilerplate:
    Use the Apollo TypeScript Starter.

    git clone https://github.com/Urigo/apollo-starter-kit.git
    cd apollo-starter-kit
    npm install
    npm start
    
  • Features:

    • Built-in support for GraphQL
    • Integrates seamlessly with frontend frameworks

6. Hapi with TypeScript

Hapi.js is a rich framework for building RESTful APIs with robust configuration options.

  • Boilerplate:
    Use the hapi-typescript-boilerplate.

    git clone https://github.com/JKHeadley/hapi-typescript-boilerplate.git my-app
    cd my-app
    npm install
    npm run dev
    
  • Features:

    • High configuration capabilities
    • Plugin system

7. AdonisJS (TypeScript First)

AdonisJS is a full-stack framework that comes with TypeScript support out of the box.

  • Boilerplate:
    Adonis CLI generates a preconfigured TypeScript project.

    npm init adonis-ts-app@latest my-app
    cd my-app
    node ace serve --watch
    
  • Features:

    • Opinionated full-stack framework
    • Built-in ORM (Lucid)
  • Website: https://adonisjs.com/


8. FeatherJS with TypeScript

FeatherJS is a lightweight framework for REST and real-time APIs with TypeScript support.

  • Boilerplate:
    Use the official CLI for a TypeScript project.

    npx @feathersjs/cli generate app
    
  • Features:

    • Built-in WebSocket and REST support
    • Focused on microservices

General Tools for TypeScript Server Development

  • Linting and Formatting:
    • ESLint and Prettier are essential for maintaining code quality.
    • Add TypeScript rules for ESLint:
      npm install eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin --save-dev
      
  • Testing Frameworks:

    • Mocha, Chai, Jest, or Supertest for API testing.
  • Build Tools:

    • Use tsc for TypeScript compilation and nodemon for hot reloading during development:
      npm install --save-dev typescript ts-node nodemon
      

Choose the boilerplate or framework based on the size, complexity, and specific requirements of your project. Let me know if you want help setting one up!

댓글

이 블로그의 인기 게시물

CDPEvents in puppeteer

Using the MinIO API via curl

How to split a list into chunks of 100 items in JavaScript, 자바스크립트 리스트 쪼개기

Declaration of custom object or type in Node.js

HTML Inline divisions at one row by Tailwind

How to checkout branch of remote git, 깃 리모트 브랜치 체크아웃

Gradle multi-module project

가속도 & 속도

Sparse encoder