{"id":13598484,"url":"https://github.com/Saluki/nestjs-template","last_synced_at":"2025-04-10T09:31:21.396Z","repository":{"id":39568690,"uuid":"131748683","full_name":"Saluki/nestjs-template","owner":"Saluki","description":"Scaffold quickly your next TypeScript API with this opinionated NestJS template crafted for Docker environments","archived":false,"fork":false,"pushed_at":"2024-06-16T09:52:47.000Z","size":1420,"stargazers_count":553,"open_issues_count":4,"forks_count":175,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-04T02:51:12.499Z","etag":null,"topics":["docker","jest","joi","nestjs","prisma","swagger","template","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Saluki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-05-01T18:31:27.000Z","updated_at":"2025-04-02T08:12:37.000Z","dependencies_parsed_at":"2023-02-13T19:31:43.377Z","dependency_job_id":"4d32aca7-31f9-47b5-b27e-bf0f5ae7dd4a","html_url":"https://github.com/Saluki/nestjs-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saluki%2Fnestjs-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saluki%2Fnestjs-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saluki%2Fnestjs-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saluki%2Fnestjs-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Saluki","download_url":"https://codeload.github.com/Saluki/nestjs-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248191691,"owners_count":21062553,"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":["docker","jest","joi","nestjs","prisma","swagger","template","typescript"],"created_at":"2024-08-01T17:00:53.035Z","updated_at":"2025-04-10T09:31:16.384Z","avatar_url":"https://github.com/Saluki.png","language":"TypeScript","funding_links":[],"categories":["Resources","资源","TypeScript"],"sub_categories":[],"readme":"\n# NestJS 10 API project template\n\n[![License](https://img.shields.io/github/license/saluki/nestjs-template.svg)](https://github.com/saluki/nestjs-template/blob/master/LICENSE)\n\nScaffold quickly your next [NestJS 10](https://nestjs.com/) API project with \n❤️ using this template\n\n- Crafted for Docker environments (Dockerfile support and environment variables)\n- REST API with [Prisma](https://www.prisma.io/) support \n- Swagger documentation, [Joi](https://github.com/hapijs/joi) validation, Winston logger, ...\n- Folder structure, code samples and best practices\n- Fast HTTP server with [Fastify](https://fastify.dev/)\n\n## 1. Getting started\n\n### 1.1 Requirements\n\nBefore starting, make sure you have at least those components on your workstation:\n\n- An up-to-date release of [NodeJS](https://nodejs.org/) such as 20.x and NPM\n- A database such as PostgreSQL. You may use the provided `docker-compose.yml` file.\n\n[Docker](https://www.docker.com/) may also be useful for advanced testing and image building, although it is not required for development.\n\n### 1.2 Project configuration\n\nStart by cloning this project on your workstation or click on [\"Use this template\"](https://github.com/new?template_name=nestjs-template\u0026template_owner=Saluki) in Github.\n\n``` sh\ngit clone https://github.com/saluki/nestjs-template my-project\n```\n\nThe next thing will be to install all the dependencies of the project.\n\n```sh\ncd ./my-project\nnpm install\n```\n\nOnce the dependencies are installed, you can now configure your project by creating a new `.env` file containing the environment variables used for development.\n\n```\ncp .env.example .env\nvi .env\n```\n\nFor a standard development configuration, you can leave the default values for `API_PORT`, `API_PREFIX` and `API_CORS` under the `Api configuration` section. The `SWAGGER_ENABLE` rule allows you to control the Swagger documentation module for NestJS. Leave it to `1` when starting this example.\n\nNext comes to the Prisma configuration: change the DATABASE_URL according to your own database setup.\n\nLast but not least, define a `JWT_SECRET` to sign the JWT tokens or leave the default value in a development environment. Update the `JWT_ISSUER` to the correct value as set in the JWT. \n\n### 1.3 Launch and discover\n\nYou are now ready to launch the NestJS application using the command below.\n\n```sh\n# For use in development environments only, performs a Prisma migration\nnpx prisma migrate dev\n\n# Launch the development server with TSNode\nnpm run dev\n```\n\nYou can now head to `http://localhost:3000/docs` and see your API Swagger docs. The example passenger API is located at the `http://localhost:3000/api/v1/passengers` endpoint.\n\nFor restricted routes, for testing you can use the below JWT\n\n```\neyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJERUZBVUxUX0lTU1VFUiIsImlhdCI6MTYzMTEwNDMzNCwicm9sZSI6InJlc3RyaWN0ZWQifQ.o2HcQBBpx-EJMcUFiqmAiD_jZ5J92gRDOyhybT9FakE\n```\n\n\u003e The sample JWT above does not have an expiry, remember to use a valid JWT and enforce the required claims in production\n\n## 2. Project structure\n\nThis template was made with a well-defined directory structure.\n\n```sh\nsrc/\n├── modules\n│   ├── app.module.ts\n│   ├── common/  # The common module contains pipes, guards, service and provider used in the whole application\n│   ├── passenger/  # A module example that manages \"passenger\" resources\n│   │   ├── controller/\n│   │   │   └── passenger.controller.ts\n│   │   ├── flow/  # The \"flow\" directory contains the pipes, interceptors and everything that may change the request or response flow\n│   │   │   └── passenger.pipe.ts\n│   │   ├── model/\n│   │   │   ├── passenger.data.ts  # The model that will be returned in the response\n│   │   │   └── passenger.input.ts  # The model that is used in the request\n│   │   ├── passenger.module.ts\n│   │   ├── service/\n│   │   │   └── passenger.service.ts\n│   │   └── spec/\n│   └── tokens.ts\n└── server.ts\n```\n\n## 3. Default NPM commands\n\nThe NPM commands below are already included with this template and can be used to quickly run, build and test your project.\n\n```sh\n# Start the application using the transpiled NodeJS\nnpm run start\n\n# Run the application using \"ts-node\"\nnpm run dev\n\n# Transpile the TypeScript files\nnpm run build\n\n# Run the project' functional tests\nnpm run test\n\n# Lint the project files using TSLint\nnpm run lint\n```\n\n## 5. Healtcheck support\n\nA healthcheck API is a REST endpoint that can be used to validate the status of the service along with its dependencies. The healthcheck API endpoint internally triggers an overall health check of the service. This can include database connection checks, system properties, disk availability and memory availability.\n\nThe example healthcheck endpoint can be request with the token located in the `HEALTH_TOKEN` environment variable.\n\n```sh\ncurl -H 'Authorization: Bearer ThisMustBeChanged' http://localhost:3000/api/v1/health\n```\n\n## 6. Project goals\n\nThe goal of this project is to provide a clean and up-to-date \"starter pack\" for REST API projects that are built with NestJS.\n\n## 7. Contributing\n\nFeel free to suggest an improvement, report a bug, or ask something: [https://github.com/saluki/nestjs-template/issues](https://github.com/saluki/nestjs-template/issues)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSaluki%2Fnestjs-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSaluki%2Fnestjs-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSaluki%2Fnestjs-template/lists"}