Skip to content

A basic starter for an Express.js API with TypeScript.

License

Notifications You must be signed in to change notification settings

bakiwebdev/express-js-starter

Repository files navigation

Express API Starter with TypeScript

A basic starter for an Express.js API with TypeScript.

Installation

Before you begin, ensure that you have Node.js and npm (Node Package Manager) installed on your machine.

  1. Clone the repository:
git clone https://github.com/bakiwebdev/express-js-starter.git
  1. Navigate to the project directory:
cd express-js-starter
  1. Install the dependencies:
npm install

Usage

The following npm scripts are available:

  • start: Builds and runs the production version of the API.
  • dev: Runs the API in development mode using nodemon, which automatically restarts the server when changes are detected.
  • build: Lints the code and compiles TypeScript into JavaScript.
  • lint: Lints the code using ESLint with the Airbnb TypeScript style guide.
  • test: Runs the test suite using Jest.

To execute a script, run the following command:

npm run <script-name>

Configuration

The configuration for the Express API can be modified through environment variables. Create a .env file in the project root directory and add your configuration variables there. Here's an example:

PORT=3000

Folder Structure

├── dist/               # Compiled JavaScript files
├── src/                # Source code
│   ├── api/            # Request handlers
│   ├── interfaces/     # Type Interface
│   ├── middlewares.ts  # Middleware functions
│   ├── app.ts          # Express application setup
│   └── index.ts        # Entry point
├── .eslintrc           # ESLint configuration
├── .gitignore          # Git ignore rules
├── package.json        # Project metadata and dependencies
└── tsconfig.json       # TypeScript configuration

Dependencies

  • cors: ^2.8.5
  • dotenv: ^16.3.0
  • express: ^4.18.2
  • helmet: ^6.2.0
  • morgan: ^1.10.0

License

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

Author

Biruk Endris

Links

About

A basic starter for an Express.js API with TypeScript.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published