{"id":15508636,"url":"https://github.com/draym/node-api-kit","last_synced_at":"2026-06-10T03:31:06.204Z","repository":{"id":98461883,"uuid":"595924294","full_name":"Draym/node-api-kit","owner":"Draym","description":"toolkit for api development","archived":false,"fork":false,"pushed_at":"2023-04-05T09:35:00.000Z","size":398,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-10T19:53:03.030Z","etag":null,"topics":["api-rest","sdk"],"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/Draym.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}},"created_at":"2023-02-01T04:44:46.000Z","updated_at":"2023-03-06T08:50:03.000Z","dependencies_parsed_at":"2023-06-01T20:30:54.216Z","dependency_job_id":null,"html_url":"https://github.com/Draym/node-api-kit","commit_stats":{"total_commits":44,"total_committers":1,"mean_commits":44.0,"dds":0.0,"last_synced_commit":"a2cfc6af32c2f91f3284457ac41fbfbad604025c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Draym%2Fnode-api-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Draym%2Fnode-api-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Draym%2Fnode-api-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Draym%2Fnode-api-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Draym","download_url":"https://codeload.github.com/Draym/node-api-kit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241045420,"owners_count":19899648,"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":["api-rest","sdk"],"created_at":"2024-10-02T09:39:26.832Z","updated_at":"2026-06-10T03:31:06.158Z","avatar_url":"https://github.com/Draym.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `API-Kit` ![NodeJS](https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge\u0026logo=node.js\u0026logoColor=white)![TypeScript](https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge\u0026logo=typescript\u0026logoColor=white) [![npm version](https://badge.fury.io/js/@d-lab%2Fapi-kit.svg)](https://badge.fury.io/js/@d-lab%2Fapi-kit)\nTypescript utility KIT for Express apis, including sequelize tools.\n\n[available on NPM](https://www.npmjs.com/package/@d-lab/api-kit)\n\n## Installation\n\n```bash\nnpm i @d-lab/api-kit\n```\n\n## Usage\n\n- Add Error middleware to your App\n```ts\nimport express from \"express\"\n\nconst app = express()\napp.use(errorMiddleware)\n```\n\n- Declare API handler in your routes, removing Express from your Controllers logic\n```ts\n// from routes/user.route.ts\nimport {Router} from \"express\"\nimport {handle} from \"../interfaces/api\"\n\n// your own controller\nimport UserController from \"../controllers/user.controller\"\nimport {validateRequest} from \"../middleware\"\nconst ctrl = new UserController()\n\nconst router = Router()\nrouter.get(\"/users/:userId\", handle.bind(ctrl.get))\nrouter.post(\"/users\", validateRequest(CreateRequest), handle.bind(ctrl.create))\n\nexport default router\n```\n\n- Compile your routes in /routes/index.ts\n```ts\nimport userRouter from \"./user.route\"\nconst routers = [\n  userRouter\n]\nexport default routers\n```\n\n- Add routes to your App\n```ts\nimport routers from \"./routes\"\napp.use(routers)\n```\n\n- Create your Controllers\n  - You can now consider your controllers as simple methods without considering Express anymore\n  - The success response will be handled in the router and the possible errors will be handled by the error middleware when HttpException are thrown in your code\n```ts\nimport {PathRequest, AuthBodyRequest} from \"../interfaces/api\"\n\nexport default class UserController {\n    public get = async (req: PathRequest\u003cGetRequest\u003e): Promise\u003cUserResponse\u003e =\u003e {\n        const params = req.params\n        return {}\n    }\n    public create = async (req: BodyRequest\u003cCreateRequest\u003e): Promise\u003cUserResponse\u003e =\u003e {\n        const body = req.body\n        return {}\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdraym%2Fnode-api-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdraym%2Fnode-api-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdraym%2Fnode-api-kit/lists"}