/express-typescript-boilerplate

Welcome to the API Starter Boilerplate! ๐ŸŒŸ It's my favorite toolkit for creating strong APIs and it's still growing. Built with Node.js, Express, TypeScript, and more, plus Winston for great logging. Perfect for starting new projects or learning API best practices.

Primary LanguageTypeScript

API Starter Boilerplate ๐Ÿš€

Introduction

Welcome to the API Starter Boilerplate! ๐ŸŒŸ Currently under development, this boilerplate is my go-to foundation for building robust APIs and has been a key part of my recent projects. It leverages the power of Node.js, Express, TypeScript, and includes a suite of tools for runtime type safety, security, structured routing, testing, and more. With the addition of Winston for comprehensive logging, this boilerplate is designed to set you up for success whether you're kickstarting a new backend project or learning the best practices for API development.

Features

  • Express & Node.js ๐ŸŒ: The backbone of our server, offering a fast, unopinionated framework for API development.

  • TypeScript ๐Ÿ“˜: Adds static types to JavaScript to improve developer productivity and code quality.

  • Zod ๐Ÿ”’: Enables runtime type checking and data validation, ensuring the integrity of API inputs and outputs.

  • Helmet ๐Ÿ›ก๏ธ: Secures your app by setting various HTTP headers to protect against common vulnerabilities.

  • Routing-Controllers ๐Ÿšฆ: Provides decorator-based routing to organize API endpoints in a clean, scalable manner.

  • Jest ๐Ÿงช: A delightful framework for testing JavaScript with simplicity and support for complex scenarios.

  • Babel ๐Ÿ : Transpiles ECMAScript 2015+ code into a backwards-compatible version of JavaScript for older environments.

  • TypeScript Aliases ๐Ÿท๏ธ: Simplifies imports, making code cleaner and more maintainable.

  • Custom Exception Handler ๐Ÿš‘: Centralizes error management, making the application more robust and easier to debug.

  • Environment Validator with Zod ๐ŸŒ: Validates environment variables to ensure the application runs flawlessly in any environment.

  • Winston Logger ๐Ÿ“: A versatile logging library for Node.js, providing comprehensive log management and flexibility in logging messages to various outputs.

  • Cron Jobs โฐ: Automates routine tasks with scheduled executions. This allows for regular maintenance tasks, data updates, and notifications, all running seamlessly in the background for operational efficiency and reliability.

Getting Started

Prerequisites

Ensure you have the following installed:

  • Node.js ๐Ÿ“ฆ

  • npm/Yarn ๐Ÿงถ

Installation

1. Clone the repository:

git clone https://github.com/dev3mike/express-typescript-boilerplate.git

2. Navigate to the project directory:

cd express-typescript-boilerplate

3. Install dependencies:

npm install

4. Set up your environment variables:

No need for now, check the environment.ts file in the configuration folder.

5. Run the development server:

npm run dev

Your API is now up at http://localhost:3000!

Usage

Detail how users can interact with your API, including endpoints and request examples. For enhanced clarity, consider using tools like cURL or Postman for demonstration.

Testing

Run tests using the following command:

npm test

This executes all Jest tests, ensuring your components work as expected.

Contributing

Contributions are welcome! ๐Ÿ™Œ Follow these steps:

  1. Fork the repository.
  2. Create your feature branch (git checkout -b feature/AmazingFeature).
  3. Commit your changes (git commit -m 'Add some AmazingFeature').
  4. Push to the branch (git push origin feature/AmazingFeature).
  5. Open a pull request.

Please make sure your code adheres to the project's standards and passes all tests.

License

This project is under the MIT License.

Contact me

Take a look at my website and let's connect: masoudb.com. Can't wait to hear from you! ๐ŸŒŸ

On linkedin: https://www.linkedin.com/in/masoudbanimahd/