{"id":16590652,"url":"https://github.com/shyam-chen/fastify-starter","last_synced_at":"2025-04-07T10:24:21.919Z","repository":{"id":40944954,"uuid":"122425025","full_name":"Shyam-Chen/Fastify-Starter","owner":"Shyam-Chen","description":":leopard: A boilerplate for server applications with Fastify and Mongo using TypeScript on Vite.","archived":false,"fork":false,"pushed_at":"2025-02-07T02:59:31.000Z","size":2019,"stargazers_count":83,"open_issues_count":0,"forks_count":20,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-31T09:07:20.822Z","etag":null,"topics":["fastify","nodejs","render","typescript","vite","vitest"],"latest_commit_sha":null,"homepage":"https://fastify-starter-8b6o.onrender.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Shyam-Chen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-22T03:15:59.000Z","updated_at":"2025-03-04T16:17:40.000Z","dependencies_parsed_at":"2023-10-11T19:08:22.114Z","dependency_job_id":"347437f7-4aad-402e-85dc-61dfa31e2a0f","html_url":"https://github.com/Shyam-Chen/Fastify-Starter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shyam-Chen%2FFastify-Starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shyam-Chen%2FFastify-Starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shyam-Chen%2FFastify-Starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shyam-Chen%2FFastify-Starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shyam-Chen","download_url":"https://codeload.github.com/Shyam-Chen/Fastify-Starter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247632980,"owners_count":20970251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastify","nodejs","render","typescript","vite","vitest"],"created_at":"2024-10-11T23:13:52.132Z","updated_at":"2025-04-07T10:24:21.905Z","avatar_url":"https://github.com/Shyam-Chen.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fastify Starter\n\n:leopard: A boilerplate for server applications with Fastify and Mongo using TypeScript on Vite.\n\n:rainbow: View Demo: [Live](https://vue-starter-6fa6.onrender.com) | Windows | macOS | Android | iOS\n\n:octocat: Source Code: [Web-side](https://github.com/Shyam-Chen/Vue-Starter) | [Native-side](https://github.com/Shyam-Chen/Tauri-Starter) | [Server-side](https://github.com/Shyam-Chen/Fastify-Starter) | [Cloud-side](https://github.com/Shyam-Chen/Pulumi-Starter)\n\n## Table of Contents\n\n- [Getting Started](#getting-started)\n- [Project Setup](#project-setup)\n- [Key Features](#key-features)\n- [Configuration](#configuration)\n- [Directory Structure](#directory-structure)\n\n## Getting Started\n\nPrerequisites:\n\n- Node.js v22\n- PNPM v10\n- Docker v4 (Optional)\n\nGet started with Fastify Starter.\n\n```sh\n# (optional)\n# If you already have the MONGODB_URL and REDIS_URL connections,\n# you can directly replace them.\n\n# mongo server\n$ docker compose up -d local-mongo\n\n# redis server\n$ docker compose up -d local-redis\n```\n\n```sh\n# install dependencies\n$ pnpm install\n\n# dev server (in one terminal)\n$ pnpm dev\n\n# (negligible)\n# The current demo doesn't make any calls to third-party or internal APIs.\n# mock server (in another terminal)\n$ pnpm mock\n```\n\nOr use barebones scaffolding for your new Fastify app\n\n```sh\n$ pnpm dlx degit Shyam-Chen/Barebones-Templates/fastify my-fastify-app\n```\n\n## Project Setup\n\nFollow steps to execute this boilerplate.\n\n### Install dependencies\n\n```sh\n$ pnpm install\n```\n\n### Compiles and hot-reloads for development\n\n```sh\n$ pnpm dev\n```\n\n### Mock third-party/private APIs during development\n\n```sh\n$ pnpm mock\n```\n\n### Compiles and minifies for production\n\n```sh\n$ pnpm build\n```\n\n### Locally preview the production build\n\n```sh\n# Before running the `preview` command, make sure to run the following commands.\n$ pnpm build\n\n$ pnpm preview\n```\n\n### Lints and fixes files\n\nFiles: `**/*.{js,ts}`\n\n```sh\n$ pnpm lint\n```\n\n### Check types\n\nFiles: `app/src/**/*.ts`\n\n```sh\n$ pnpm check\n```\n\n### Runs unit tests\n\nFiles: `app/src/**/*.test.ts`\n\n```sh\n$ pnpm test\n```\n\n### Runs end-to-end tests\n\nFiles: `e2e/src/**/*.test.ts`\n\n```sh\n# Before running the `e2e` command, make sure to run the following commands.\n$ pnpm build\n$ pnpm preview\n\n$ pnpm e2e\n```\n\n## Key Features\n\nThis seed repository provides the following features:\n\n- ---------- **Essentials** ----------\n- [x] [Fastify](https://github.com/fastify/fastify) - Web Application Framework\n- [x] [Routes](https://github.com/Vanilla-IceCream/vite-plugin-fastify-routes) - File-based Routing\n- [x] [MongoDB](https://github.com/fastify/fastify-mongodb) - Document Database\n- [x] [JWT](https://github.com/fastify/fastify-jwt) - Authentication\n- [x] [PBKDF2](https://github.com/Vanilla-IceCream/pbkdf2-passworder) - Hash Passwords\n- [x] [OTP](https://github.com/yeojz/otplib) - Authenticator\n- [x] [Cloudinary](https://github.com/Vanilla-IceCream/fastify-cloudinary) - Asset Management\n- [x] [I18n](https://github.com/Vanilla-IceCream/fastify-i18n) - Internationalization and Localization\n- [x] [Redis](https://github.com/fastify/fastify-redis) - In-memory Data Structure Store\n- [x] [BullMQ](https://github.com/taskforcesh/bullmq) - Message Queue\n- [x] [WebSocket](https://github.com/fastify/fastify-websocket) - Two-way Interactive Communication Session\n- [x] [EventSource](https://github.com/nodefactoryio/fastify-sse-v2) - Server-sent Events\n- [x] [Mailer](https://github.com/nodemailer/nodemailer) - Email Sending\n- [x] [MJML](https://github.com/Shyam-Chen/MJML-Starter) - Email Builder\n- [x] [Nunjucks](https://github.com/mozilla/nunjucks) - Email Rendering\n- [x] [LangChain](https://github.com/langchain-ai/langchainjs) - Vector Embeddings\n- [x] [OpenAI](https://github.com/openai/openai-node) - Large Language Model\n- [x] [MongoDB Vector Search](https://github.com/fastify/fastify-mongodb) - Vector Store\n- ---------- **Tools** ----------\n- [x] [Vite](https://github.com/vitejs/vite) - Bundler\n- [x] [TypeScript](https://github.com/microsoft/TypeScript) - JavaScript with Syntax for Types\n- [x] [Biome](https://github.com/biomejs/biome) - Formatter and Linter\n- [x] [Vitest](https://github.com/vitest-dev/vitest) - Test Runner\n- [x] [Playwright](https://github.com/microsoft/playwright) - Test Automation\n- ---------- **Environments** ----------\n- [x] [Node.js](https://nodejs.org/en/) - JavaScript Runtime Environment\n- [x] [PNPM](https://pnpm.io/) - Package Manager\n- [x] [Caddy](https://caddyserver.com/) - Web Server\n- [x] [Docker](https://www.docker.com/) - Containerized Application Development\n- [x] [GitHub Actions](https://github.com/features/actions) - Continuous Integration and Delivery\n- [x] [Render](https://render.com/) - Cloud Application Hosting\n\n### Tiny examples\n\n- [x] [Hello World](./app/src/routes/hello-world/+handler.ts)\n- [x] [CRUD Operations](./app/src/routes/todos)\n- [x] [JWT Authentication](./app/src/routes/auth/+handler.ts)\n- [x] [One-time Password](./app/src/routes/auth/otp/+handler.ts)\n- [x] [File Uploads](./app/src/routes/file-uploads/+handler.ts)\n- [x] [Real-time Data](./app/src/routes/echo/+handler.ts)\n- [x] [Real-time Updates](./app/src/routes/sse/+handler.ts)\n- [x] [Sending Emails](./app/src/routes/email/+handler.ts)\n- [x] [Internationalization](./app/src/routes/hello-i18n)\n- [x] [Caching (Includes Redis Store)](./app/src/routes/hello-world/caching/+handler.ts)\n- [x] [Cache Deduplication](./app/src/routes/hello-world/caching-dedupe/[id]-memory/+handler.ts) (Or use [Redis Store](./app/src/routes/hello-world/caching-dedupe/[id]-redis/+handler.ts))\n- [x] [Background Workers](./app/src/jobs) (Or use [Redis Store](./app/src/routes/queues/+handler.ts))\n- [x] [Cron Jobs](./app/src/jobs) (Or use [Redis Store](./app/src/routes/queues/cron/+handler.ts))\n- [x] [Delayed jobs](./app/src/jobs) (Or use [Redis Store](./app/src/routes/queues/delay/+handler.ts))\n- [x] [Streaming LLM Output](./app/src/routes/sse/model/+handler.ts)\n- [x] [LLM Conversational Q\u0026A Chatbot](./app/src/routes/conversation/+handler.ts)\n\n## Configuration\n\nControl the environment.\n\n### Default environments\n\nSet your local environment variables.\n\n```ts\n// app/vite.config.ts\n  define: envify({\n    NODE_ENV: process.env.NODE_ENV || 'development',\n\n    HOST: process.env.HOST || '127.0.0.1',\n    PORT: process.env.PORT || 3000,\n\n    SITE_URL: process.env.SITE_URL || 'http://127.0.0.1:5173',\n\n    MONGODB_URL: process.env.MONGODB_URL || 'mongodb://root:rootpasswd@127.0.0.1:27017/mydb',\n    REDIS_URL: process.env.REDIS_URL || 'redis://127.0.0.1:6379',\n    CLOUDINARY_URL: process.env.CLOUDINARY_URL || 'cloudinary://apikey:apisecret@cloudname',\n    SMTP_URL: process.env.SMTP_URL || `smtp://${user}:${pass}@smtp.ethereal.email:587`,\n    OPENAI_API_KEY: process.env.OPENAI_API_KEY,\n\n    SECRET_KEY: process.env.SECRET_KEY || 'jbmpHPLoaV8N0nEpuLxlpT95FYakMPiu',\n\n    MONGOMS_VERSION: process.env.MONGOMS_VERSION || '7.0.11',\n  }),\n```\n\n### Continuous integration environments\n\nAdd environment secrets to the GitHub Actions workflow.\n\n```sh\nDEPLOY_HOOK=xxx\n```\n\n### Continuous delivery environments\n\nAdd environment variables to the Render build.\n\n```sh\nSITE_URL=xxx\n\nMONGODB_URL=xxx\nREDIS_URL=xxx\nCLOUDINARY_URL=xxx\nSMTP_URL=xxx\nOPENAI_API_KEY=xxx\n```\n\n## Directory Structure\n\nThe structure follows the LIFT Guidelines.\n\n```coffee\n.\n├── .github\n├── app\n│   ├── public\n│   ├── src\n│   │   ├── assets\n│   │   ├── components\n│   │   ├── composables\n│   │   ├── jobs\n│   │   ├── locales\n│   │   ├── middleware\n│   │   ├── plugins\n│   │   ├── routes\n│   │   ├── templates\n│   │   ├── utilities\n│   │   ├── app.ts\n│   │   ├── main.ts\n│   │   ├── shims.d.ts\n│   │   └── worker.ts\n│   ├── package.json\n│   ├── tsconfig.json\n│   └── vite.config.ts\n├── db -\u003e Set up local data for initializing and testing the database\n│   ├── src\n│   ├── mongo-init.js\n│   └── package.json\n├── e2e -\u003e API End-to-end testing\n│   ├── src\n│   ├── package.json\n│   ├── playwright.config.ts\n│   └── tsconfig.json\n├── mock -\u003e Mocking third-party or private API calls\n│   ├── src\n│   ├── package.json\n│   ├── tsconfig.json\n│   └── vite.config.ts\n├── .dockerignore\n├── .editorconfig\n├── .gitignore\n├── biome.json\n├── Caddyfile\n├── compose.yaml\n├── Dockerfile\n├── package.json\n├── pnpm-lock.yaml\n├── pnpm-workspace.yaml\n├── README.md\n└── render.yaml\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshyam-chen%2Ffastify-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshyam-chen%2Ffastify-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshyam-chen%2Ffastify-starter/lists"}