Skip to content

BossHogg97/fastify-ver-5

Repository files navigation

fastify-esbuild-mongodb

Commitizen friendly

Opinionated boilerplate to build a Fastify app and Mongodb with better DX.


fastify-esbuild-mongodb-land-image

Introduction

This is a fork of fastify-esbuild , a great work from David Peng Thank's David.

This code is born after reading the articles on Better Backend DX: Fastify + ESBuild = ⚡️

In addition this project have these features :

  • Complete MongoDB collections management with node-mongo package to simplify Mongodb usage. It is used the official Node.js driver (Mongoose is not used)
  • Full test suite using Vitest
  • Configuration using dotenv environments
  • CRUD complete for the boards sample collection.

Feel to free enhancements, proposal, (errors).


Original article

https://davipon.hashnode.dev/better-backend-dx-fastify-esbuild)

Features

  • Use @fastify/autoload for filesystem-based routes & plugins.
  • Use esbuild-kit/tsx to reduce feedback loop during devlopment.
  • Use esbuild to bundle production code.
  • Use Conventional Commits & SemVer standards, e.g. commitlint, commitizen, standard-version.
  • Use eslint, prettier, lint-staged.
  • Use husky git hooks helper to run formatter & linter.

How to start?

# Install dependencies
pnpm i

# Activate git hooks
pnpm prepare

# Start development
pnpm dev

# Build production code
pnpm build

# Run production code
pnpm start

Avatar dimension

The suggested dimension for avatar is 60x60 pixels

keycloak Authorization

For authorize an API request is necessary to check if Bearer token passed in header has the right to execute the action

Enforcer

Is the preHandler function inside core folder used by each route that has to be protected. If the [enforce] function finish without reply and error or status code mean that the request can be executed. Otherwise it will be reply the error and status code and the request will be aborted

Configuration object

Inside route definition is necessary to define a configuration object with the following shape

config: { resource: 'resourceName', scope: '[read-write-delete]' },

The object properties must be the same with the one defined inside keycloak console administration under **Client -> Authservice -> Authorization -> resources alt text

preHandler

Is a fastify hook that will be executed before route handler

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published