Categories
Docker and Kubernetes Full Stack Development Typescript

NestJS Template for APIs

Save time and start using a NestJS template for secure API backends today. Just following the instructions on this article.

Bootstrap your secure API development with a standard GitHub NestJS template

GitHub has the concept of template repositories. This allows us to invest the time in creating a skeleton project only once and then to create GitHub repositories out of this template. In this brief post I’m sharing a GitHub template for NestJS API Backend applications.

As the rush to total digitisation compels us to write ever more APIs, it’s useful to have a template that provides the key features each of our API backends needs.

I therefore decided to invest the time and created such template, available on GitHub.

This NestJS template offers the following boilerplate capabilities:

  • A Configuration Service ready to go. This allows us to create a .env file for environment variables and have such properties available anywhere in the app.
  • A JWT service based on Passport and Auth0
  • A Permissions Guard which protects APIs with the roles contained in the JWT token passed within the request
  • A Shared Service for common functionality
  • A pagination skeleton, to handle paginated data
  • A boilerplate controller, with one open and one secure endpoint
  • A boilerplate service that the controller can invoke
  • Typeorm dependencies
  • A boilerplate Docker configuration

For details on how to build and run the application and create a Docker image if you want, please refer to the GitHub documentation.

The API security configuration is centred around Auth0, an Identity As A Service product.

If you want to know more about how to configure a NestJS API Backend with Auth0, please refer to these articles:

Setting up Auth0 for your full-stack Angular SPA

Feedback Pal Nest JS API Backend

Hope you’ll find this useful.

By Marco Tedone

I lead the API, Integration and Microservices (AIM) Practice for a world’s leading international bank. My team is in charge of defining and maintaining standards, best practices and accelerators for everything that relates to APIs, Integration and Microservices. We also act as an internal consultancy helping other teams with AIM adoption, architecture reviews, pair programming and technology choices. We are chief problem solvers. I also specialise in building high performing technology teams. I have experience and a passion for Lean Enterprise transformations with the goal of helping organisations to deliver business value faster by looking at product delivery as business value delivery and as a system flow, where BDD, Agile, DevOps, Testing Automation, Portfolio and Budget Management, Regulatory and Compliance, Security and NFRs are all parts of a single journey. My favourite execution tool for Lean Enterprise transformations is the Improvement/Coaching Kata, by Mike Rother. I’m well versed in Followership, Leadership and Coaching.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.