Skip to content

invokify/nest-api

Repository files navigation

A Nest.js Rest API

An example of how I implemented a Rest API backend using Nest.js and Supabase

To run the application on http:localhost:3001:

npm i
npm run dev

Architecture

The backend is a well structured, modular monolyth using CLEAN & MVC-like architecture (Module / Controller / Service).

Authentication

The API is secured using JWT token which is generated by Supabase Authentication and passed along other requests by the client of the API.

Database

Data is persisted to a Supabase database. Supabase CLI allow us to generate a schema migration that can be applied either to the local database (Docker), either to the production one.

Access Rights

Thanks to Supabase RLS, policies have been implemented for the products the following way:

  • Allow read access to everyone
  • Allow authenticated users to insert products
  • Allow owners to update their products
  • Allow owners to delete their products
  • Allow admin to modify products

Tests

Tests have been implemented for:

  • Products controller and service

To run tests locally:

npm run test

Continuous Integration

CI is implemented using a Github Action, defined at .github/workflows/main.yml.

It has 2 jobs:

  • Tests
  • Apply Database Migration

Documentation

A swagger is available at http://localhost:3001/api

About

A Nest.js REST API backed by Supabase

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published