{"id":15714529,"url":"https://github.com/helloakn/typescript-for-restapi","last_synced_at":"2026-05-09T00:35:15.699Z","repository":{"id":253121771,"uuid":"842535390","full_name":"helloakn/typescript-for-restapi","owner":"helloakn","description":"This repository is just for passion and you can refer for your project. ","archived":false,"fork":false,"pushed_at":"2024-08-25T06:11:50.000Z","size":105,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T22:37:31.143Z","etag":null,"topics":["express","jest","jest-mocking","restful-api","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/helloakn.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":"2024-08-14T14:48:27.000Z","updated_at":"2024-08-25T06:11:52.000Z","dependencies_parsed_at":"2024-10-24T11:59:10.502Z","dependency_job_id":"078215fb-2d22-4b8c-96b5-1a1282f12766","html_url":"https://github.com/helloakn/typescript-for-restapi","commit_stats":null,"previous_names":["helloakn/typescript-for-restapi"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloakn%2Ftypescript-for-restapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloakn%2Ftypescript-for-restapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloakn%2Ftypescript-for-restapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloakn%2Ftypescript-for-restapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/helloakn","download_url":"https://codeload.github.com/helloakn/typescript-for-restapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246372503,"owners_count":20766626,"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":["express","jest","jest-mocking","restful-api","typescript"],"created_at":"2024-10-03T21:37:49.234Z","updated_at":"2026-05-09T00:35:10.664Z","avatar_url":"https://github.com/helloakn.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Typescript For RestAPI\n\n[![Star Count](https://img.shields.io/badge/dynamic/json?color=brightgreen\u0026label=Star\u0026query=stargazers_count\u0026url=https%3A%2F%2Fapi.github.com%2Frepos%2Fhelloakn%2Ftypescript-for-restapi)](https://github.com/helloakn/typescript-for-restapi) [![Licence](https://img.shields.io/badge/dynamic/json?color=informational\u0026label=LICENCE\u0026query=license.name\u0026url=https%3A%2F%2Fapi.github.com%2Frepos%2Fhelloakn%2Ftypescript-for-restapi)](https://github.com/helloakn/typescript-for-restapi) [![Language](https://img.shields.io/badge/dynamic/json?color=blueviolet\u0026label=Language\u0026query=language\u0026url=https%3A%2F%2Fapi.github.com%2Frepos%2Fhelloakn%2Ftypescript-for-restapi)](https://github.com/helloakn/typescript-for-restapi) \n\n[![NodeJs](https://img.shields.io/badge/nodejs-v18.6.0-green)](https://github.com/helloakn/typescript-for-restapi) \n[![Express](https://img.shields.io/badge/express-v^4.18.1-green)](https://github.com/helloakn/typescript-for-restapi) \n\n## Table of content\n- [1] File Structure\n- [2] Git Conventional Commits Message\n- [3] Routing Eample\n\n----\n\n### [1] File Structure\n```\n-typescript-for-restapi\n├── __tests__                         # for testing\n│   ├── e2e-tests                     # for all the integration tests\n│   └── unit-tests                    # for all the integration tests \n├── src                               # for typescripts\n│   ├── app                           # AS AS Open/Close Principle\n│   │   ├── controllers\n│   │   │    └─ ...            \n│   │   ├── middlewares               \n│   │   ├── models                    # for database table\n│   │   └── routes                    # for admin / user / swigger api routes etc\n│   ├── config                        # for main functions and components\n│   │   └─ ...\n│   ├── core                          # for main functions and components\n│   │   └─ ...\n├...\n\n```\n\n---\n\n### [2] Git Conventional Commits Message\n\u003cpre\u003e\n\u003cb\u003e\u003ca href=\"#body\"\u003e[Type] : Message\u003c/a\u003e\u003c/b\u003e\n\u003csub\u003eType =\u003e  [Create], [Modify], [Fix], [Delete]\u003c/sub\u003e\n\u003csub\u003eMessage =\u003e  Describe about the commit\u003c/sub\u003e\n\n\u003cb\u003e\u003ca href=\"#body\"\u003eExample\u003c/a\u003e\u003c/b\u003e\n\u003csub\u003e[Create] message event for bla bla bla\u003c/sub\u003e\n\u003csub\u003e[Modify] message event for bla bla bla\u003c/sub\u003e\n\u003csub\u003e[Fix] message event for bla bla bla\u003c/sub\u003e\n\u003c/pre\u003e\n\n---\n\n\n### [3] Routing Eample\n *  Route : without controller\n *  Route : with controller\n *  Route : prefix\n *  Route : Authorization {with guard}\n *  Route : Multiple request method\n\n#### Route Example\n *  Route : without controller\n```javascript\nimport type { Request, Response, NextFunction } from 'express';\nimport Routers from '@/core/route'\nimport { REQUEST_METHODS } from '@/config';\n\nconst { GET } = REQUEST_METHODS;\nconst routers = new Routers();\n\nconst demoFun = (req: Request, res: Response, next?: NextFunction) =\u003e {\n    res.status(200).json({ 'msg': 'tes testFunt' })\n}\nrouters.addRoute([GET], '/demo', [demoFun])\n\n```\n *   Route : controller\n```javascript\n import ServiceCheckController from '@/app/controllers/serviceCheck.controller';\n\nimport Routers from '@/core/route'\nimport { REQUEST_METHODS } from '@/config';\nconst { GET } = REQUEST_METHODS;\nconst routers = new Routers();\n\nexport default routers\n    .addRoute([GET], '/health-check', ServiceCheckController.healthCheck)\n\n```\n\n *   Route : Prefix\n```javascript\n/* \nroute prefix\n*/\n\nimport type { Request, Response, NextFunction } from 'express';\n\nimport Routers from '@/core/route'\nimport { REQUEST_METHODS } from '@/config';\n\nconst { GET } = REQUEST_METHODS;\nconst routers = new Routers();\n\nconst testFun = (req: Request, res: Response, next?: NextFunction) =\u003e {\n    res.status(200).json({ 'msg': 'tes testFunt' })\n}\nexport default routers\n    .addPrefix('/api/v1', (routers) =\u003e {\n        routers\n            .addRoute([GET], '/register', [testFun])\n            .addRoute([GET], '/login', [testFun])\n        return routers;\n    });\n\n```\n\n *   Route : Authorization {with guard}\n```javascript\n/* \nroute authorization\n*/\n\nimport type { Request, Response, NextFunction } from 'express';\nimport { isAuthorizeAccess } from '@/app/middlewares';\n\nimport Routers from '@/core/route'\nimport { REQUEST_METHODS } from '@/config';\n\nconst { GET } = REQUEST_METHODS;\nconst routers = new Routers();\n\nconst testFun = (req: Request, res: Response, next?: NextFunction) =\u003e {\n    res.status(200).json({ 'msg': 'tes testFunt' })\n}\nexport default routers\n    .addPrefix('/api/v1/user', (routers) =\u003e {\n        routers\n            .addRoute([GET], '/profile', [isAuthorizeAccess, testFun])\n        return routers;\n    });\n\n\n```\n*   Route : Multiple request method\n```javascript\nimport type { Request, Response, NextFunction } from 'express';\n\nimport Routers from '@/core/route'\nimport { REQUEST_METHODS } from '@/config';\n\nconst { GET,POST,PUT } = REQUEST_METHODS;\nconst routers = new Routers();\n\nconst testFun = (req: Request, res: Response, next?: NextFunction) =\u003e {\n    res.status(200).json({ 'msg': 'tes testFunt' })\n}\nexport default routers\n.addRoute([GET,POST,PUT], '/profile', [ testFun])\n```\n- - -","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelloakn%2Ftypescript-for-restapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhelloakn%2Ftypescript-for-restapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelloakn%2Ftypescript-for-restapi/lists"}