/express-typescript-skeleton

🔰🦸 Template to start developing a REST API with Node.js (Express), TypeScript, ESLint, Prettier, Husky, Prisma, etc.

Primary LanguageTypeScriptMIT LicenseMIT

Node.js, Typescript and Express template

GitHub package.json version GitHub CI Workflow Status GitHub CD Workflow Status GitHub LICENSE

🔰🦸 Production-ready template for backends created with Node.js, Typescript and Express

ℹ️ About📋 Features 🤝 Contributing 🛣️ Roadmap🎯 Credits🚩 License


ℹ️ About

The main goal of this project is to provide a base template for the generation of a production-ready REST API made with Node.js, Express and Typescript. The idea is to avoid having to configure all the tools involved in a project every time it is started and thus be able to focus on the definition and implementation of the business logic.

📣 This is an opinionated template. The architecture of the code base and the configuration of the different tools used has been based on best practices and personal preferences.

🚀 Quick start

  • Start project in development mode:

    npm run dev
  • Start project in production mode:

    npm run start

📋 Features

  • Built using Typescript
  • Built using Express Framework: Fast, unopinionated, minimalist web framework for node.
  • Built using Prisma: Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite & MongoDB
  • Built using Routing Controllers: Allows to create controller classes with methods as actions that handle requests
  • JWT authentication and role based authorization using custom middleware
  • OpenAPI definition
  • Fully configured logger with Winston and Morgan
  • Unit, Integration and E2E tests using Jest and Supertest
  • Linting with ESLint
  • Formatting with Prettier
  • Spell check
  • Git hooks with Husky and lint-staged
  • Containerised using Docker and Docker Compose
  • Path aliases support
  • Commit messages must meet conventional commits format
  • GitHub Actions
  • Makefile as project entrypoint
  • A lot of emojis 🛸

🐐 Makefile rules

The main actions on this project are managed using a Makefile as an entrypoint.

  • deps: Validate if the project dependencies are installed
  • build/dev: Build the project image for the development environment
  • build/prod: Build the project image for the production environment
  • start/dev: Start the project in development mode using Docker
  • start/prod: Start the project in production mode using Docker
  • start/db: Start database container
  • test/dev: Run the project tests using Docker
  • stop/dev: Stop dev application container
  • stop/prod: Stop prod application container
  • stop/db: Stop database container
  • clean/dev: Removes dev application container and associated resources
  • clean/prod: Removes prod application container and associated resources

⚡ Scripts

package.json scripts:

  • dev: Start project in development mode
  • build: Build project and generate final build
  • start: Start project in production mode
  • check:types: Check if project types are correct
  • check:format: Check if project is formatted correctly
  • check:lint: Check if project is linted correctly
  • check:spelling: Check if project is spelled correctly
  • fix:format: Fix project format issues
  • fix:lint: Fix project lint issues
  • fix:staged: Check and fix staged files
  • test: Run all tests
  • test:unit: Run unit tests
  • test:int: Run integration tests
  • test:e2e: Run e2e tests
  • test:watch: Run tests in watch mode
  • test:coverage: Run tests with coverage
  • coverage:view: Show coverage information
  • commit: Help to commit changes using conventional commits
  • version: Generate new project version
  • reset-hard: Reset git repository to a clean state
  • prepare-release: Prepare the project for a release and generates a new release
  • update-deps: Update the project dependencies

🤝 Contributing

Just fork and open a pull request. All contributions are welcome 🤗

🛣️ Roadmap

Please, check TODO for the current roadmap.

🎯 Credits

To implement this project I have based myself on many similar projects. There were countless of them and I gave them all a star.

🙏 Thank you very much for these wonderful creations.

⭐ Stargazers

Stargazers repo roster for @borjapazr/express-typescript-skeleton

🚩 License

MIT @ borjapazr. Please see License for more information.