Skip to content

adevinwild/micro-express

Repository files navigation

μ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

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 :

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 :
docker-compose up --build
  • Apply migrations :
npm run migration:up

4. Run Application:

  • Development :
npm run dev
  • Production :
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! 🎉