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.
-
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.
Ensure you have the following installed:
-
Node.js ๐ฆ
-
npm/Yarn ๐งถ
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!
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.
Run tests using the following command:
npm test
This executes all Jest tests, ensuring your components work as expected.
Contributions are welcome! ๐ Follow these steps:
- Fork the repository.
- Create your feature branch (
git checkout -b feature/AmazingFeature
). - Commit your changes (
git commit -m 'Add some AmazingFeature'
). - Push to the branch (
git push origin feature/AmazingFeature
). - Open a pull request.
Please make sure your code adheres to the project's standards and passes all tests.
This project is under the MIT License.
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/