{"id":22253004,"url":"https://github.com/renartupits/node-fastify-mongoose-template","last_synced_at":"2026-04-05T23:35:57.168Z","repository":{"id":266137349,"uuid":"897493713","full_name":"renartupits/node-fastify-mongoose-template","owner":"renartupits","description":"A template project designed for building fast and efficient RESTful APIs with Node.js, TypeScript, Fastify, Mongoose, and Pino.","archived":false,"fork":false,"pushed_at":"2024-12-02T18:46:33.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-30T11:23:31.006Z","etag":null,"topics":["fastify","mongodb","mongoose","nodejs","pino","typescript"],"latest_commit_sha":null,"homepage":"","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/renartupits.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":"2024-12-02T18:17:24.000Z","updated_at":"2024-12-02T18:46:36.000Z","dependencies_parsed_at":"2024-12-02T19:44:33.337Z","dependency_job_id":"70098ddc-b272-4851-81b6-eb874bece633","html_url":"https://github.com/renartupits/node-fastify-mongoose-template","commit_stats":null,"previous_names":["renartupits/node-fastify-mongoose-template"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renartupits%2Fnode-fastify-mongoose-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renartupits%2Fnode-fastify-mongoose-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renartupits%2Fnode-fastify-mongoose-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renartupits%2Fnode-fastify-mongoose-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/renartupits","download_url":"https://codeload.github.com/renartupits/node-fastify-mongoose-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245459549,"owners_count":20618877,"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","mongodb","mongoose","nodejs","pino","typescript"],"created_at":"2024-12-03T07:15:32.159Z","updated_at":"2025-12-30T23:25:20.497Z","avatar_url":"https://github.com/renartupits.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node.js, TypeScript, Fastify, Mongoose, and Pino Template\n\nA template project designed for building fast and efficient RESTful APIs with **Node.js**, **TypeScript**, **Fastify**, **Mongoose**, and **Pino**. This project utilizes modern development tools and practices including **ESLint**, **pnpm** for package management, and **Docker** for running MongoDB locally.\n\n## 🛠️ Technologies Used\n- **Node.js** v22.0\n- **Typescript** v5.7\n- **Fastify** v5\n- **Mongoose** v8.8\n- **ESLint** v9.15\n- **Pino** for logging\n- **pnpm** as the package manager\n- **MongoDB** (running via Docker)\n\n## 🚀 Features\n- High-performance **Fastify** web server for building RESTful APIs\n- MongoDB integration using **Mongoose**\n- TypeScript for better development experience and code quality\n- Fastify plugins for **CORS** and **MongoDB** connection management\n- Generic MongoDB repository functions for cleaner code\n- **Pino** integrated for fast and structured logging\n- Pre-configured Docker setup for MongoDB\n- Linting and code quality with **ESLint**\n- Scalable and easy-to-understand project structure\n\n## 📦 Project Structure\n```bash\n/src\n    ├── controllers          # API route handlers\n    ├── fetcher              # Helper functions for fetching data\n    ├── interfaces           # TypeScript interfaces for data models\n    ├── middlewares          # Custom middlewares for the Fastify app\n    ├── persistence\n    │    ├── models          # MongoDB document definitions (Mongoose schemas)\n    │    ├── repository      # Custom MongoDB query functions\n    │    ├── BaseRepository.ts # Generic base functions for MongoDB communication\n    ├── plugins              # Fastify plugins for middleware setup\n    │    ├── cors            # CORS setup for Fastify\n    │    ├── mongodb         # MongoDB connection plugin\n    ├── routes               # API route definitions\n    ├── service              # Business logic layer\n    ├── app.ts               # Application initialization, plugins, routes, and middlewares\n    ├── server.ts            # The starting point for the application\n````\n\n## 💿 Installation\n### Prerequisites\n- Node.js (v22.9 or higher)\n- Docker (for MongoDB container)\n\n\n```bash\ngit clone https://github.com/renartupits/node-fastify-mongoose-template.git\ncd node-fastify-mongoose-template\n```\n\n### Install dependencies using pnpm\nMake sure you have pnpm installed. If not, you can install it globally using:\n```bash\nnpm install -g pnpm\n```\nNow, install the project dependencies:\n```bash\npnpm install\n```\n\n### Setup MongoDB with Docker\nThis project uses **MongoDB** for data storage. You can use the included docker-compose.yml to start a local MongoDB container:\n```bash\ndocker-compose up -d\n```\nThis will pull the MongoDB image and start the database on the default port 27017.\n\n### Environment Configuration\nCreate a .env file in the root directory with the following content:\n```bash\nDATABASE_URL=mongodb://root:example@localhost:27017/template_mongo?authSource=admin\n```\nEnsure that the MongoDB instance is running before starting the application.\n\n## 🎬 Running the application\n### Run the Development Server\n\nTo start the Fastify server in development mode, use the following command:\n```bash\npnpm dev\n```\nThis will start the server at http://localhost:3000.\n\n### Run Tests\nIf you have tests set up, you can run them using:\n```bash\npnpm test\n```\n\n## 📁 Fastify API Structure\n- **Controllers:** Define route handlers and API logic.\n- **Services:** Contains the business logic for your application.\n- **Repositories:** Abstract MongoDB operations with Mongoose for better data handling and scalability.\n- **Middlewares:** Custom logic to run before or after requests.\n- **Plugins:** Fastify-specific plugins such as CORS and MongoDB connection setup.\n\n## License\nThis project is licensed under the MIT License - see the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenartupits%2Fnode-fastify-mongoose-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frenartupits%2Fnode-fastify-mongoose-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenartupits%2Fnode-fastify-mongoose-template/lists"}