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
The backend is a well structured, modular monolyth using CLEAN & MVC-like architecture (Module / Controller / Service).
The API is secured using JWT token which is generated by Supabase Authentication and passed along other requests by the client of the API.
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.
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 have been implemented for:
- Products controller and service
To run tests locally:
npm run test
CI is implemented using a Github Action, defined at .github/workflows/main.yml.
It has 2 jobs:
- Tests
- Apply Database Migration
A swagger is available at http://localhost:3001/api