A starter kit for building REST APIs using Node.js, Express.js, and TypeScript.
- Introduction
- Prerequisites
- Installation
- Usage
- Scripts
- Project Structure
- Configuration
- Environment Variables
- Contributing
- License
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.
- Node.js ^18.18.1
- npm ^9.8.1
-
Clone the repository:
git clone https://github.com/mapleDevJS/nodejs-expressjs-ts-starter-kit.git
-
Navigate to the project directory:
cd nodejs-expressjs-ts-starter-kit
-
Install dependencies:
npm install
To start the development server with hot-reloading:
npm run start:dev
To build the project:
npm run build
To clean the dist
directory:
npm run clean
After building the project, you can start the production server:
npm run start
To start the mock server using json-server
:
npm run mock:server
start
: Builds the project and starts the production server.start:dev
: Starts the development server with hot-reloading.build
: Cleans thedist
directory and compiles TypeScript to JavaScript.clean
: Removes thedist
directory.compile
: Compiles TypeScript files usingtsc
.lint
: Lints thesrc
directory using ESLint.lint:fix
: Automatically fixes linting issues in thesrc
directory.format
: Checks code formatting using Prettier.format:fix
: Fixes code formatting issues using Prettier.ts
: Runsts-node
.cli
: Runs the CLI application.mock:server
: Starts a mock server usingjson-server
.
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
- ESLint:
.eslintrc.js
- Prettier:
.prettierrc
- TypeScript:
tsconfig.json
- NPM:
package.json
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
Contributions are welcome! Please open an issue or submit a pull request for any bugs, enhancements, or features.
This project is licensed under the MIT License. See the LICENSE file for more details.