Code Monkey home page Code Monkey logo

nestjs-grpc-scaffold's Introduction


NestJS GRPC Scaffold

An awesome template to jumpstart your projects!
Explore the NestJS docs »

Table of Contents
  1. About The Project
  2. Features
  3. Folder Structure
  4. Getting Started
  5. Roadmap
  6. Contributing
  7. License

About The Project

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:

  • Your time should be focused on creating something amazing. A project that solves a problem and helps others
  • You shouldn't be doing the same tasks over and over; like integrating a DB layer, a microservice layer, etc.
  • You should implement DRY principles to the rest of your life as well :)

Of course, no one template will serve all projects since your needs may be different, but here's for everyone who find it helpful.

(back to top)

Built With

(back to top)

Features

Every time I start building an API, a 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:

  • Open Telemetry to instrument, generate, collect, and export telemetry data.
  • Terminus module for the healthcheck of your application exposed at /health route.
  • Global exception middleware so you can catch and customize any target exception to your likings.
  • Global request-logger middleware so all the incoming and outgoing calls are logged by default with their metadata.
  • Global Cache middleware to enhance the response time of all the GET calls.
  • A programmatic way to access environment variables through DI.
  • A database ORM to interact with multiple DB drivers using the great Prisma package.
  • A programmatic way to generate logs using DI upon the right context of your application.
  • Husky package with lint-staged bundled with pre-commit and pre-push hooks that running linter, formatter and tests

(back to top)

Folder Structure

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 and env configurations live here. You can also and include more modules in it, like your db for instance, or any other module that relies on environment variables or externals configurations.
  • config/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/logger 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 evil the base code. It's a module wrapping the minimun functionality that the app should have, again this is very opinionated of me, so you may choose to adjust it to fit your needs.
  • 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.

(back to top)

Getting Started

To get a local copy up and running follow these simple example steps.

Prerequisites

  • npm
    npm install npm@latest -g
  • Nest
    npm i -g @nestjs/cli

Installation and Usage

  1. Clone the repo
    git clone https://github.com/your_username_/Project-Name.git
  2. Install NPM packages
    npm install
  3. Run the application
    npm run start

(back to top)

Roadmap

  • [] Add unit tests

(back to top)

Contributing

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. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  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

(back to top)

License

Distributed under the MIT License. See LICENSE.md for more information.

(back to top)

nestjs-grpc-scaffold's People

Contributors

fer8a avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.