REST boilerplate to build APIs / microservices using the NestJS framework
MIT License
NestJS is a great Framework to start building very robust server-side applications. There are many great templates available on GitHub; however, I didn't find one that really suited my needs so I created this very opinionated one. I wanted a boilerplate that would integrate many of the great features Nest has to offer, out-of-the-box, with the minimun configuration effort to start bootstraping an application right away.
Here's why:
Of course, no one template will serve all projects since your needs may be different, but here's for everyone who find it helpful.
Every time I start building an API, a REST microservice, a server-side app; there's always a set of features that I end up reusing over and over given the utility they provide. That's the main reason I have decided to create this project to bootstrap as much of this core functionality as possible.
Let's list a few of the features provided on this project:
/health
route.HTTP
routes (Thanks to NestJS CLI plugin).HTTP
requests are logged by default with their metadata.GET
HTTP
requests.environment
variables through DI.Following the Nest way of things, I ended up up with a module-based approach when it came to structuring the code. That being said, the project comes with a series of folders and modules that you can reuse and extend to fit your needs, let's talk a bit about it.
config
Like its name implies is a folder to place all sort of configurations for your app. cache
, env
, configurations live here. You can also and include more modules in it.config/otel-tracer
Open Telemetry SDK and configuration file.config/db
Quite self explanatory, this is your DB module, the folder to place all your configs and ORM layer.config/logs
Module where you can place the log driver used by your app. Comes with Pino and Winston out of the box.core
This is it, the source of providers
Folder to place external third-party SDKs or libraries (AWS, Sendgrid, etc).resources
Interfaces and endpoints with the bussiness logic of your app should be placed here. Modules, Controllers, Services and entities related to the solution you're building.resources/healthcheck
This exposes the healthcheck functionality of your app to the HTTP
transport layer.transporters
Meant for all the microservices and interfaces other than HTTP
used in your app. Kafka, Redis, NATS, etc.To get a local copy up and running follow these simple example steps.
npm install npm@latest -g
npm i -g @nestjs/cli
git clone https://github.com/your_username_/Project-Name.git
npm install
npm run start
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. Don't forget to give the project a star! Thanks again!
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)Distributed under the MIT License. See LICENSE.md
for more information.