β’ Request validation with schema Typebox
β’ Prisma as ORM
β’ Efficient error handling and logger
β’ Routes guard with middleware equivalent
A comprehensive template. Followed strict and REST guidelines
πΌ Ready for production:Built-in GitHub Actions script to check linter and deploy. Dockerfile already configurated. See below how to use secrets.
π Opensource:Available under the APLv2 license.
- Execution environment : Node 16 with ESM and Yarn
- Framework : Fastify
- Language : TypeScript 5.3
- ORM : Prisma
- Schema validator : Typebox
- Security : jsonwebtoken and bcrypt
- Format : Prettier to enforce consistent code style
- Linter : ESLint with good practices of clean code
- GIT Helper : Husky + Commitlint + Commitizen
- CI/CD : GitHub Actions + Docker
The project required Node.js v16 or later.
To clone the repository, use the following commands:
git clone https://github.com/Cyril-Deschamps/fastify-typescript-prisma-boilerplate.git
mv fastify-typescript-prisma-boilerplate your-project-name
cd your-project-name
yarn install
watch
- start project in dev mode with hot reload,start
- start JS Project,build
- transpile TypeScript to ES6,prepare
- to install husky hooks,migrate
- migrate Prisma schema to remote database,npm-run-all lint-check:\*
- Process eslint and prettier checks,npm-run-all lint-fix:\*
- Process eslint, prettier checks and try to resolve,
Secrets are stored in github secrets. For a local environment, you can use the .env
file to store the secret (see .env.example).
Variable | Description | Exemple |
---|---|---|
APP_SECRET |
The secret used for the cookies (32 chars recommended) | UΒ£,rGtD~Fm;1TY9!Zmpz&R7q&0Sdz@2H |
APP_CORS_ORIGIN |
List of the CORS in the shape | http://localhost,https://cyrildeschamps.fr |
Variable | Description | Example |
---|---|---|
DEVELOPMENT_APP_BACKEND_PUBLIC_URL |
HTTP API address | https://boilerplate.cyrildeschamps.fr |
DEVELOPMENT_APP_FRONTEND_PUBLIC_URL |
Web application address | https://boilerplate.cyrildeschamps.fr |
DEVELOPMENT_APP_DATABASE_URL |
Database URL | mysql://user:password@hostname:ip/dbname?schema=public |
DEVELOPMENT_HOST |
Deployment server IP | 66.254.114.41 |
DEVELOPMENT_PORT |
Deployment server SSH port | 22 |
DEVELOPMENT_SSHKEY |
SSH key for connecting to the server | See server's .ssh/id_... file |
DEVELOPMENT_USERNAME |
Username for connecting to the server | debian |
DEVELOPMENT_DOCKER_IMAGES_PATH |
Name of the folder where the project is stored on the server | /home/debian/docker-container-images |
DEVELOPMENT_DOCKER_LOCAL_IP |
Local IP (nginx) of the container | 172.0.0.18 |
Variable | Description | Example |
---|---|---|
PRODUCTION_APP_BACKEND_PUBLIC_URL |
HTTP API address | https://cyrildeschamps.fr |
PRODUCTION_APP_FRONTEND_PUBLIC_URL |
Web application address | https://cyrildeschamps.fr |
PRODUCTION_APP_DATABASE_URL |
Database URL | mysql://user:password@hostname:ip/dbname?schema=public |
PRODUCTION_HOST |
Deployment server IP | 66.254.114.41 |
PRODUCTION_PORT |
Deployment server SSH port | 22 |
PRODUCTION_SSHKEY |
SSH key for connecting to the server | See server's .ssh/id_... file |
PRODUCTION_USERNAME |
Username for connecting to the server | debian |
PRODUCTION_DOCKER_IMAGES_PATH |
Name of the folder where the project is stored on the server | /home/debian/docker-container-images |
PRODUCTION_DOCKER_LOCAL_IP |
Local IP (nginx) of the container | 172.0.0.19 |
You can support this project by contributing to it, by posting issues and proposing pull request.
Licensed under the APLv2. See the LICENSE file for details.
- Use github environment to store secrets and maybe reduce the number of secrets
- Add testing with Jest or other
- Auto-tagging with semantic-release
- Manage migration file between tags or environment)
- And, all others improvements are welcome...