π A boilerplate for Node.js, Fastify, TypeScript, Vite, Playwright, and Render.
π Live Demo - The client application is here.
Get started with Fastify Starter.
# dev server
$ pnpm install
$ pnpm dev
# mock server
$ cd mock/requests && pnpm install && cd ../..
$ pnpm mock
Follow steps to execute this boilerplate.
$ pnpm install
$ pnpm dev
$ pnpm build
Files: src/**/*.ts
$ pnpm lint
Files: src/**/*.spec.ts
$ pnpm unit
Files: e2e/**/*.spec.ts
# Before running the `e2e` command, make sure to run the following commands.
$ pnpm build
$ pnpm preview
# If it's not installed, run it.
$ cd e2e && pnpm install && cd ..
$ pnpm e2e
Files: benchmark/**/*.spec.ts
# If it's not installed, run it.
$ cd benchmark && pnpm install && cd ..
$ pnpm bench
# If it's not installed, run it.
$ cd mock/requests && pnpm install && cd ../..
$ pnpm mock
Files: docs/**/*.md
# If it's not installed, run it.
$ cd docs && pnpm install && cd ..
$ pnpm doc
This seed repository provides the following features:
- ---------- Essentials ----------
- Fastify - Web Application Framework
- MongoDB - Document Database
- JWT - Authentication
- PBKDF2 - Hash Passwords
- OTP - Authenticator
- Cloudinary - Asset Management
- I18n - Internationalization and Localization
- Redis - In-memory Data Structure Store
- WebSocket - Two-way Interactive Communication Session
- EventSource - Server-sent Events
- Mailer - Email Sending
- Email - Email Builder
- Nunjucks - Email Rendering
- Sheets - Spreadsheet Data Toolkit
- BullMQ - Message Queue
- ---------- Tools ----------
- Vite - Bundler
- TypeScript - JavaScript with Syntax for Types
- ESLint - Linter
- Prettier - Formatter
- Vitest - Test Runner
- Playwright - Test Automation
- Autocannon - Measure Performance
- VitePress - Documentation
- ---------- Environments ----------
- Node.js - JavaScript Runtime Environment
- Pnpm - Package Manager
- PM2 - Process Manager
- Caddy - Web Server
- Docker - Containerized Application Development
- CircleCI - Continuous Integration and Delivery
- Render - Cloud Application Hosting
Control the environment.
Set your local environment variables.
// env.ts
export default {
NODE_ENV: process.env.NODE_ENV || 'development',
HOST: process.env.HOST || '127.0.0.1',
PORT: process.env.PORT || 3000,
SITE_URL: process.env.SITE_URL || 'http://127.0.0.1:5173',
MONGODB_URL: process.env.MONGODB_URL || 'xxx',
REDIS_URL: process.env.REDIS_URL || 'xxx',
CLOUDINARY_URL: process.env.CLOUDINARY_URL || 'xxx',
SMTP_URL: process.env.SMTP_URL || 'xxx',
SECRET_KEY: process.env.SECRET_KEY || 'xxx',
};
Add environment variables to the CircleCI build.
# production
DEPLOY_HOOK=xxx
# development
DEV_DEPLOY_HOOK=xxx
# staging
STAGE_DEPLOY_HOOK=xxx
Add environment variables to the Render build.
SITE_URL=xxx
MONGODB_URL=xxx
REDIS_URL=xxx
CLOUDINARY_URL=xxx
SMTP_URL=xxx
SECRET_KEY=xxx
The structure follows the LIFT Guidelines.
.
βββ .circleci
βββ benchmark
βββ docs
βββ e2e -> e2e testing (Caddy Server proxy api and proxy mock api)
βββ mock
β βββ requests -> mock api
β βββ responses -> mock data for mock api, unit testing, and e2e testing
βββ public -> not handled by vite, copy it to dist
βββ src
β βββ assets -> wasm
β βββ components -> shared module
β βββ composables -> shared module
β βββ locales -> core module
β βββ middleware -> core module
β βββ modules -> feature modules
β β βββ <FEATURE> -> feature module
β β βββ __tests__ -> unit testing
β β βββ _locales
β β βββ controller.ts
β β βββ registry.ts -> route component
β β βββ schema.ts
β β βββ service.ts
β β βββ types.ts
β βββ plugins -> root module
β βββ templates -> email templates with nunjucks
β βββ utilities -> shared module
β βββ app.ts
β βββ error.ts
β βββ main.ts
β βββ shims.d.ts
βββ .editorconfig
βββ .eslintrc
βββ .gitignore
βββ .prettierrc
βββ Caddyfile
βββ docker-compose.yml
βββ Dockerfile
βββ env.ts
βββ index.ts -> entrypoint
βββ LICENSE
βββ package.json
βββ pnpm-lock.yaml
βββ README.md
βββ render.yaml
βββ tsconfig.json
βββ vite.config.ts
A microservice architecture β a variant of the service-oriented architecture structural style β is an architectural pattern that arranges an application as a collection of loosely-coupled, fine-grained services, communicating through lightweight protocols.
See Micro-Fullstack's Micro Backends for instructions on how to create microservices from source code.
api.example.com
βββ /auth
β βββ auth.api.example.com
βββ /stats
β βββ stats.api.example.com
βββ /todoist
β βββ todoist.api.example.com
βββ /feature
β βββ feature.api.example.com
βββ /files
β βββ files.api.example.com
βββ /settings
βββ settings.api.example.com