Skip to content

A starter kit for building REST APIs using Node.js, Express.js, and TypeScript. This template provides a robust foundation with modern development tools and practices, including TypeScript, ESLint, Prettier, and more.

License

Notifications You must be signed in to change notification settings

mapleDevJS/nodejs-expressjs-ts-starter-kit

Repository files navigation

Node.js Express TypeScript Starter Kit

A starter kit for building REST APIs using Node.js, Express.js, and TypeScript.

Table of Contents

Introduction

This is a starter kit for building REST APIs using Node.js, Express.js, and TypeScript. It includes several essential tools and libraries to help you quickly set up and develop your API.

Prerequisites

  • Node.js ^18.18.1
  • npm ^9.8.1

Installation

  1. Clone the repository:

    git clone https://github.com/mapleDevJS/nodejs-expressjs-ts-starter-kit.git
  2. Navigate to the project directory:

    cd nodejs-expressjs-ts-starter-kit
  3. Install dependencies:

    npm install

Usage

Starting the Development Server

To start the development server with hot-reloading:

npm run start:dev

Building the Project

To build the project:

npm run build

Cleaning the Build Directory

To clean the dist directory:

npm run clean

Running the Production Server

After building the project, you can start the production server:

npm run start

Running the Mock Server

To start the mock server using json-server:

npm run mock:server

Scripts

  • start: Builds the project and starts the production server.
  • start:dev: Starts the development server with hot-reloading.
  • build: Cleans the dist directory and compiles TypeScript to JavaScript.
  • clean: Removes the dist directory.
  • compile: Compiles TypeScript files using tsc.
  • lint: Lints the src directory using ESLint.
  • lint:fix: Automatically fixes linting issues in the src directory.
  • format: Checks code formatting using Prettier.
  • format:fix: Fixes code formatting issues using Prettier.
  • ts: Runs ts-node.
  • cli: Runs the CLI application.
  • mock:server: Starts a mock server using json-server.

Project Structure

nodejs-expressjs-ts-starter-kit/
├── dist/                     # Compiled JavaScript files
├── src/                      # TypeScript source files
│   ├── controllers/          # Controllers
│   ├── models/               # Models
│   ├── routes/               # Express routes
│   ├── services/             # Services
│   ├── utils/                # Utility functions
│   └── main.ts               # Entry point of the application
├── mocks/                    # Mock data for JSON server
│   └── mock-server-data.json # Mock server data
├── .eslintrc.js              # ESLint configuration
├── .prettierrc               # Prettier configuration
├── tsconfig.json             # TypeScript configuration
├── package.json              # NPM configuration and scripts
└── README.md                 # Project documentation

Configuration

  • ESLint: .eslintrc.js
  • Prettier: .prettierrc
  • TypeScript: tsconfig.json
  • NPM: package.json

Environment Variables

To set up environment variables, create a .env file in the root of your project and add the required variables. For example:

DB_CONNECTION_STRING=your_database_connection_string

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any bugs, enhancements, or features.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

A starter kit for building REST APIs using Node.js, Express.js, and TypeScript. This template provides a robust foundation with modern development tools and practices, including TypeScript, ESLint, Prettier, and more.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks