Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/adevinwild/micro-express

Opinionated micro Express.js template to build robust REST APIs.
https://github.com/adevinwild/micro-express

awilix boilerplate demo example express-js jest micro-express nodemon nodemon-express postgres postgresql repository-pattern robust template typeorm typescript winston

Last synced: about 1 month ago
JSON representation

Opinionated micro Express.js template to build robust REST APIs.

Awesome Lists containing this project

README

        




ΞΌExpress


Oppinionated micro Express.js template to build robust REST APIs.

ΞΌExpress is a streamlined Express.js template tailored for crafting robust REST APIs. With a curated set of tools and libraries, it accelerates development while offering flexibility for project-specific adjustments.

## 🌟 Highlights

- **TypeScript Integration**: Benefit from static type checking and enhanced code intelligence.
- **Code Quality**: Enforced with ESLint and Prettier.
- **Express.js**: Utilizing the minimalist and fast Express.js framework.
- **Rich Logging**: With Winston.
- **CORS Ready**: Using the CORS middleware.
- **Request Parsing**: Via Body Parser.
- **Database & ORM**: TypeORM with Postgres support, containerized with Docker.
- **Testing**: Dependency injection with Awilix and testing via Jest.

## πŸ“‚ Project Structure

```bash
src/
β”œβ”€β”€ api/ # API endpoints, middlewares, and routes.
β”‚ β”œβ”€β”€ middlewares/
β”‚ └── routes/
β”œβ”€β”€ loaders/ # Global logic: API routes, middlewares, DB, and Awilix container.
β”œβ”€β”€ migrations/ # Database migrations.
β”œβ”€β”€ models/ # TypeORM entities.
β”œβ”€β”€ repositories/ # Data access layers.
β”œβ”€β”€ services/ # Business logic.
β”œβ”€β”€ types/ # TypeScript type definitions.
└── utils/ # Utility functions.
```

## πŸš€ Getting Started

#### 1. Clone :

```bash
git clone https://github.com/adevinwild/micro-express.git
```

#### 2. Install Dependencies:

```
npm install
```

#### 3. Database Setup:

> For this demo, we have already one migration file that creates a `dummy` table with an `id` column.

- Start with Docker :

```bash
docker-compose up --build
```

- Apply migrations :

```bash
npm run migration:up
```

#### 4. Run Application:

- Development :

```bash
npm run dev
```

- Production :

```bash
npm run build && npm start
```

## πŸ› οΈ Scripts Overview

- `build`: Transpile TypeScript code.
- `start`: Launch the built application.
- `dev`: Development server with nodemon.
- `format`: Beautify code with ESLint & Prettier.
- `lint`: Check code quality with ESLint.
- `test`: Execute tests using Jest.

## Happy coding! πŸŽ‰