Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mafifa/express-ts-template

Starter template for building Express.js applications with TypeScript. Includes Socket.io, Prettier, ESLint, and hot-reloading. Perfect for avoiding boilerplate and quickly getting started with a clean and scalable setup
https://github.com/mafifa/express-ts-template

boilerplate boilerplate-template express express-js nodejs scaffolded template typescript

Last synced: 5 days ago
JSON representation

Starter template for building Express.js applications with TypeScript. Includes Socket.io, Prettier, ESLint, and hot-reloading. Perfect for avoiding boilerplate and quickly getting started with a clean and scalable setup

Awesome Lists containing this project

README

        

# Express TS Template Starter

A simple and efficient template for building **Express.js** applications with **TypeScript** using MCV architecture. This project comes pre-configured with **ESLint**, **Prettier**, and **TypeScript**, saving you time and effort when starting a new project.

## Features

- **TypeScript**: Strongly typed JavaScript for a better development experience.
- **Express.js**: Web framework for building server-side applications.
- **Socket.io**: Real-time communication support via WebSockets.
- **Prettier**: Automatic code formatting to maintain consistency.
- **ESLint**: Ensures cleaner and more maintainable code.
- **Dotenv**: Simple environment variable management.

## Why Use This Template?

This template handles all the setup you need when starting a new **Express** and **TypeScript** project. It eliminates the need to configure **Prettier**, **ESLint**, or **Socket.io**, letting you focus directly on writing your application logic.

### Tech Stack

- **Express.js**: Fast, minimalist web framework for Node.js.
- **TypeScript**: Typed superset of JavaScript that compiles to plain JavaScript.
- **Socket.io**: Enables real-time, bidirectional communication between clients and servers.
- **Prettier & ESLint**: Ensures a consistent code style and catches potential issues.

## API Routes EXAMPLES

The API uses the prefix `/api/` for all routes. Example CRUD routes for user management:

- **GET** `/api/users`: Retrieve all users.
- **GET** `/api/users/:id`: Retrieve a user by their ID.
- **POST** `/api/users`: Create a new user.
- **PUT** `/api/users/:id`: Update a user by their ID.
- **DELETE** `/api/users/:id`: Delete a user by their ID.

These routes are set up in `src/routes/userRoutes.ts` and can be easily extended as needed.

## Mock Data

The `mock/` folder contains a JSON file (`users.json`) that is used as example data throughout the project. The file includes mock user data for testing purposes:

```json
[
{
"id": 1,
"name": "John Doe",
"email": "[email protected]",
"age": 30
},
{
"id": 2,
"name": "Jane Smith",
"email": "[email protected]",
"age": 25
}
]
```