{"id":19964045,"url":"https://github.com/pilotpirxie/express-endpoints-collection","last_synced_at":"2026-02-11T04:02:49.392Z","repository":{"id":246662675,"uuid":"821768008","full_name":"pilotpirxie/express-endpoints-collection","owner":"pilotpirxie","description":"Create API endpoints in Express with TypeScript inference, validation and OpenAPI 3 schema out of the box","archived":false,"fork":false,"pushed_at":"2025-01-30T22:41:15.000Z","size":721,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-25T07:19:54.139Z","etag":null,"topics":["api","endpoints","express","expressjs","nodejs","openapi","rest","rest-api","swagger","typescript","validation","zod"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/express-endpoints-collection","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/pilotpirxie.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,"zenodo":null}},"created_at":"2024-06-29T11:30:39.000Z","updated_at":"2025-01-30T22:41:19.000Z","dependencies_parsed_at":"2024-06-29T13:55:22.247Z","dependency_job_id":"bdcb50d1-9863-4cf1-af4e-c41c50fa6738","html_url":"https://github.com/pilotpirxie/express-endpoints-collection","commit_stats":null,"previous_names":["pilotpirxie/simple-express-openapi-middleware","pilotpirxie/express-endpoints-collection"],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/pilotpirxie/express-endpoints-collection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pilotpirxie%2Fexpress-endpoints-collection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pilotpirxie%2Fexpress-endpoints-collection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pilotpirxie%2Fexpress-endpoints-collection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pilotpirxie%2Fexpress-endpoints-collection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pilotpirxie","download_url":"https://codeload.github.com/pilotpirxie/express-endpoints-collection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pilotpirxie%2Fexpress-endpoints-collection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29326833,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T03:52:29.695Z","status":"ssl_error","status_checked_at":"2026-02-11T03:52:23.094Z","response_time":97,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","endpoints","express","expressjs","nodejs","openapi","rest","rest-api","swagger","typescript","validation","zod"],"created_at":"2024-11-13T02:18:54.801Z","updated_at":"2026-02-11T04:02:49.377Z","avatar_url":"https://github.com/pilotpirxie.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# express-endpoints-collection\n\n## Description\n\nThis package provides easy to use helper for creating API endpoints in Express with TypeScript inference, validation and OpenAPI 3 schema out of the box.\n\nNo need to duplicate OpenAPI definitions in your codebase. Just define your API endpoints and automatically generate OpenAPI 3 schema.\n\nYou can configure exposed endpoints, request and response schemas, and validation rules.\n\n![output](./img/output1.png)\n\n## Features\n\n- Fully typed endpoints (TypeScript hints and checks)\n  - Request body\n  - Response body\n  - Query parameters\n  - Path parameters\n  - Headers\n- Automatic OpenAPI 3 schema generation\n- Request and response validation using Zod\n- Middleware support\n- Minimal setup\n\n## Installation\n\n```shell\nnpm install express-endpoints-collection\n\n# or\n\nyarn add express-endpoints-collection\n\n# or\n\npnpm add express-endpoints-collection\n```\n\n## Usage\n\n```typescript\nimport express, { Express } from \"express\";\nimport bodyParser from \"body-parser\";\nimport { z } from \"zod\";\nimport { EndpointsCollection } from \"express-endpoints-collection\";\nimport { generateOpenAPI } from \"express-endpoints-collection/generator\";\n\n// 1. Create express app\nconst app: Express = express();\napp.use(bodyParser.json());\n\n// 2. Create endpoints collection, this will store all your endpoints\nconst endpointsCollection = new EndpointsCollection();\n\n// 3. Add new endpoint\nendpointsCollection.post(\n  \"/add\",\n  {\n    inputSchema: {\n      body: z.object({\n        a: z.number(),\n        b: z.number(),\n      }),\n    },\n    outputSchema: [\n      {\n        status: 200,\n        body: z.object({\n          result: z.number(),\n        }),\n      },\n    ],\n    summary: \"Add two numbers\",\n  },\n  // 4. req and res are fully typed!\n  (req, res) =\u003e {\n    const { a, b } = req.body;\n    res.json({ result: a + b });\n  },\n);\n\n// 5. Collection creates its own router, to use it just add it to your app\napp.use(endpointsCollection.getRouter());\n\n// 6. Expose OpenAPI 3 schema\napp.get(\"/openapi\", (req, res) =\u003e {\n  res.setHeader(\"Content-Type\", \"text/yaml\");\n  res.send(\n    generateOpenAPI({\n      title: \"Minimal demo\",\n      version: \"1.0.0\",\n      endpoints: endpointsCollection.getEndpoints(),\n      servers: [\"http://localhost:3000\"],\n    }),\n  );\n});\n\n// 7. Start the server and done!\napp.listen(3000, () =\u003e {\n  console.info(`Server is running on port http://localhost:3000`);\n});\n```\n\nit will generate OpenAPI 3 definition as follow:\n\n```yaml\nopenapi: 3.0.0\ninfo:\n  title: Minimal demo\n  version: 1.0.0\ncomponents:\n  schemas: {}\n  parameters: {}\npaths:\n  /add:\n    post:\n      summary: Add two numbers\n      requestBody:\n        content:\n          application/json:\n            schema:\n              type: object\n              properties:\n                a:\n                  type: number\n                b:\n                  type: number\n              required:\n                - a\n                - b\n      responses:\n        \"200\":\n          description: Response for status code 200\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  result:\n                    type: number\n                required:\n                  - result\n```\n\nor as JSON\n\n```json\n{\n  \"openapi\": \"3.0.0\",\n  \"info\": {\n    \"title\": \"Minimal demo\",\n    \"version\": \"1.0.0\"\n  },\n  \"components\": {\n    \"schemas\": {},\n    \"parameters\": {}\n  },\n  \"paths\": {\n    \"/add\": {\n      \"post\": {\n        \"summary\": \"Add two numbers\",\n        \"requestBody\": {\n          \"content\": {\n            \"application/json\": {\n              \"schema\": {\n                \"type\": \"object\",\n                \"properties\": {\n                  \"a\": {\n                    \"type\": \"number\"\n                  },\n                  \"b\": {\n                    \"type\": \"number\"\n                  }\n                },\n                \"required\": [\"a\", \"b\"]\n              }\n            }\n          }\n        },\n        \"responses\": {\n          \"200\": {\n            \"description\": \"Response for status code 200\",\n            \"content\": {\n              \"application/json\": {\n                \"schema\": {\n                  \"type\": \"object\",\n                  \"properties\": {\n                    \"result\": {\n                      \"type\": \"number\"\n                    }\n                  },\n                  \"required\": [\"result\"]\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}\n```\n\n## Example\n\n![output](./img/output0.png)\n\nType inference and checks:\n\n![infer0](./img/infer0.png)\n\n![infer1](./img/infer1.png)\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpilotpirxie%2Fexpress-endpoints-collection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpilotpirxie%2Fexpress-endpoints-collection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpilotpirxie%2Fexpress-endpoints-collection/lists"}