{"id":29016737,"url":"https://github.com/caiohperlin/rest-api-express-template","last_synced_at":"2026-04-07T18:33:00.249Z","repository":{"id":282788342,"uuid":"948146526","full_name":"CaioHPerlin/rest-api-express-template","owner":"CaioHPerlin","description":"Simple development-ready Express + TypeScript REST API template!","archived":false,"fork":false,"pushed_at":"2025-06-18T19:54:51.000Z","size":159,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"development","last_synced_at":"2025-06-25T22:44:44.738Z","etag":null,"topics":["api","backend","boilerplate","commit-hooks","eslint","express","folder-structure","husky","jest","node","nodejs","rest","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CaioHPerlin.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":"2025-03-13T20:35:05.000Z","updated_at":"2025-06-18T19:54:55.000Z","dependencies_parsed_at":"2025-06-25T22:40:46.889Z","dependency_job_id":"89522069-e796-4146-b5df-489cd497ec2e","html_url":"https://github.com/CaioHPerlin/rest-api-express-template","commit_stats":null,"previous_names":["caiohperlin/express-ts-template"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/CaioHPerlin/rest-api-express-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaioHPerlin%2Frest-api-express-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaioHPerlin%2Frest-api-express-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaioHPerlin%2Frest-api-express-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaioHPerlin%2Frest-api-express-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CaioHPerlin","download_url":"https://codeload.github.com/CaioHPerlin/rest-api-express-template/tar.gz/refs/heads/development","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaioHPerlin%2Frest-api-express-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279010241,"owners_count":26084718,"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","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["api","backend","boilerplate","commit-hooks","eslint","express","folder-structure","husky","jest","node","nodejs","rest","template","typescript"],"created_at":"2025-06-25T22:40:20.195Z","updated_at":"2025-10-12T04:07:02.489Z","avatar_url":"https://github.com/CaioHPerlin.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Express + Typescript REST API Template\n\nThis repository provides a basic structure for building REST APIs using Express and TypeScript. It includes essential configurations and dependencies required to help you get started quickly and securely.\n\n## Features\n\n- Express server setup with TypeScript\n- Basic middleware configuration (CORS, JSON parsing, global error handler)\n- Zod for object validation (DTOs, etc.)\n- Support for custom API errors, including validation errors that are easily instantiated using errors thrown by Zod\n- Pre-configured ESLint and Prettier for code quality and formatting\n- Commit hooks that run ESLint and Prettier, configured using the Husky library\n- Environment management with `dotenv` and `config/env.ts`, which validates each environment variable\n- Testing with `jest`\n- Basic folder structure for organizing and versioning your API\n\n## Getting Started\n\n### Prerequisites\n\n- Node.js (v18 or higher)\n- pnpm (of course you can use whichever package manager you want, but pnpm is highly recommended)\n\n### Installation\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/caiohperlin/rest-api-express-template.git\ncd rest-api-express-template\n```\n\n2. Install dependencies:\n\n```bash\npnpm install\n```\n\n3. Create a `.env` file in the root directory and add your environment variables:\n\n```bash\nPORT=5000\nNODE_ENV=development\n```\n\n## Available Scripts\n\n### Development\n\n- **`pnpm dev`** - Start the development server with hot reload using `tsx`\n    - Watches for file changes and automatically restarts the server\n    - Runs directly from TypeScript source files\n\n### Production\n\n- **`pnpm start`** - Start the production server\n\n    - Runs the compiled JavaScript files from the `dist` directory\n    - Make sure to run `pnpm build` first\n\n- **`pnpm build`** - Build the project for production\n    - Compiles TypeScript to JavaScript using `tsc`\n    - Resolves path aliases using `tsc-alias`\n    - Output is generated in the `dist` directory\n\n### Code Quality\n\n- **`pnpm typecheck`** - Run TypeScript type checking without emitting files\n\n    - Useful for CI/CD pipelines or quick type validation\n    - Faster than full compilation\n\n- **`pnpm lint`** - Run ESLint on the source code\n\n    - Checks for code quality issues and potential bugs\n    - Covers `.ts` and `.js` files in the `src` directory\n\n- **`pnpm lint:fix`** - Run ESLint and automatically fix issues\n    - Same as `lint` but attempts to fix auto-fixable problems\n\n### Formatting\n\n- **`pnpm format`** - Format all files using Prettier\n\n    - Applies consistent code formatting across the project\n    - Modifies files in place\n\n- **`pnpm format:check`** - Check if files are properly formatted\n    - Useful for CI/CD to ensure code is formatted\n    - Exits with error code if formatting is needed\n\n### Testing\n\n- **`pnpm test`** - Run all tests using Jest\n\n    - Includes `--passWithNoTests` flag for projects without tests yet\n    - Runs once and exits\n\n- **`pnpm test:watch`** - Run tests in watch mode\n\n    - Automatically re-runs tests when files change\n    - Interactive mode for development\n\n- **`pnpm test:coverage`** - Run tests with coverage report\n    - Generates detailed coverage reports\n    - Useful for understanding test coverage metrics\n\n### Git Hooks\n\n- **`pnpm husky:prepare`** - Initialize Husky git hooks\n    - Sets up pre-commit hooks\n    - Automatically runs during `pnpm install`\n\n## Development Workflow\n\n1. **Start development**: `pnpm dev`\n2. **Make changes**: Edit files in the `src` directory\n3. **Run tests**: `pnpm test` or `pnpm test:watch`\n4. **Check code quality**: `pnpm lint` and `pnpm format:check`\n5. **Commit changes**: Git hooks will automatically run linting and formatting\n6. **Push changes**\n\n## Production Deployment\n\n1. **Build the project**: `pnpm build`\n2. **Start production server**: `pnpm start`\n3. **Environment variables**: Ensure all required environment variables are set in your production environment\n\n## Project Structure\n\n```\nrest-api-express-template/\n├── .husky/                # Git hooks configuration\n├── dist/                  # Compiled files (generated)\n├── node_modules/          # Node.js modules\n├── src/                   # Source files\n│   ├── api/               # API related files\n│   │   └── v1/            # Version 1 of the API\n│   │       ├── app/       # Example app module\n│   │       └── index.ts   # v1 Router\n│   ├── config/            # Configuration files\n│   │   └── env.ts         # Environment variables validation\n│   ├── errors/            # Custom error classes\n│   ├── middleware/        # Custom middleware\n│   ├── utils/             # Utility functions\n│   ├── app.ts             # Express application config\n│   └── server.ts          # Project entry point\n├── .env                   # Environment variables\n├── .env.example           # Environment variables template\n├── .lintstagedrc.json     # lint-staged configuration\n├── eslint.config.mjs      # ESLint configuration\n├── jest.config.js         # Jest testing configuration\n├── package.json           # Project dependencies and scripts\n├── pnpm-lock.yaml         # pnpm lock file\n├── prettier.config.js     # Prettier configuration\n├── README.md              # Project documentation\n└── tsconfig.json          # TypeScript configuration\n```\n\n## Git Hooks\n\nThis project uses Husky to manage Git hooks:\n\n- **Pre-commit**: Runs ESLint and Prettier on staged files only\n\n## Contributing\n\nFeel free to fork this repository and make your own changes. Pull requests are welcome!\n\n## License\n\nThis project is licensed under the **ISC License.**\n\n\u003cbr\u003e\n\n\u003e Thank you for reading and happy _express_-ing! 👾\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaiohperlin%2Frest-api-express-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaiohperlin%2Frest-api-express-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaiohperlin%2Frest-api-express-template/lists"}