{"id":48041049,"url":"https://github.com/m99coder/tsoa-hapi","last_synced_at":"2026-04-04T14:07:58.354Z","repository":{"id":45574670,"uuid":"434324764","full_name":"m99coder/tsoa-hapi","owner":"m99coder","description":"Use tsoa and hapi","archived":false,"fork":false,"pushed_at":"2026-03-09T09:06:36.000Z","size":1258,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-09T13:44:35.891Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/m99coder.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-12-02T18:04:47.000Z","updated_at":"2026-03-09T09:06:38.000Z","dependencies_parsed_at":"2024-11-11T10:25:44.214Z","dependency_job_id":"5e12f5d2-22b3-4424-9c94-b10691f4ccb2","html_url":"https://github.com/m99coder/tsoa-hapi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/m99coder/tsoa-hapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m99coder%2Ftsoa-hapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m99coder%2Ftsoa-hapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m99coder%2Ftsoa-hapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m99coder%2Ftsoa-hapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m99coder","download_url":"https://codeload.github.com/m99coder/tsoa-hapi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m99coder%2Ftsoa-hapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31402278,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T10:20:44.708Z","status":"ssl_error","status_checked_at":"2026-04-04T10:20:06.846Z","response_time":60,"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":[],"created_at":"2026-04-04T14:07:57.626Z","updated_at":"2026-04-04T14:07:58.336Z","avatar_url":"https://github.com/m99coder.png","language":"TypeScript","readme":"# tsoa-hapi\n\n## Setup\n\n```shell\ngit init\nyarn init -y\n\n# tsoa, hapi\nyarn add tsoa @hapi/hapi\n\n# typescript\nyarn add -D typescript @types/node @types/hapi__hapi\nyarn run tsc --init --target es2021 --experimentalDecorators --outDir ./dist\n\n# eslint\nyarn add -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin\nyarn run eslint --init\n\n# prettier\nyarn add -D prettier eslint-config-prettier eslint-plugin-prettier\n```\n\n`tsconfig.eslint.json`\n\n```json\n{\n  \"compilerOptions\": {\n    \"types\": [\n      \"@types/node\"\n    ],\n    \"noEmit\": true,\n    \"allowJs\": true,\n  },\n  \"extends\": \"./tsconfig.json\",\n  \"include\": [\n    \".eslintrc.js\",\n    \"src/**/*.ts\",\n    \"test/**/*.ts\",\n  ]\n}\n```\n\n`.eslintrc.js`\n\n```javascript\nmodule.exports = {\n  root: true,\n  env: {\n    es6: true,\n    node: true,\n  },\n  parser: '@typescript-eslint/parser',\n  plugins: ['@typescript-eslint', 'prettier'],\n  parserOptions: {\n    project: ['./tsconfig.eslint.json'],\n    sourceType: 'module',\n    tsConfigRootDir: __dirname,\n    warnOnUnsupportedTypeScriptVersion: false,\n  },\n  extends: [\n    'eslint:recommended',\n    'plugin:@typescript-eslint/recommended',\n    'plugin:@typescript-eslint/recommended-requiring-type-checking',\n    'prettier',\n  ],\n  rules: {\n    'require-await': 'off',\n    '@typescript-eslint/require-await': 'off',\n    'prettier/prettier': 2,\n  },\n}\n```\n\n`.eslintignore`\n\n```text\nbuild\nnode_modules\n```\n\n`.prettierrc`\n\n```json\n{\n  \"semi\": false,\n  \"trailingComma\": \"all\",\n  \"singleQuote\": true,\n  \"printWidth\": 80\n}\n```\n\n`.prettierignore`\n\n```text\nsrc/routes.ts\n```\n\n`package.json`\n\n```json\n{\n  \"scripts\": {\n    \"build\": \"tsc\",\n    \"fmt\": \"prettier --config .prettierrc '{src,test}/**/*.ts' --write --no-color\",\n    \"gen\": \"tsoa spec-and-routes\",\n    \"lint\": \"eslint '{src,test}/**/*.ts'\",\n    \"start\": \"node dist/server.js\"\n  }\n}\n```\n\n## Model, Service, and Controller\n\n* create `src/users/users.ts` exporting the `User` interface\n* create `src/users/users-service.ts` exporting the `UsersCreationParams` type and `UsersService` class\n* create `src/users/users-controller.ts` exporting the `UsersController` class\n\n## Creating the server\n\n`tsoa.json`\n\n```json\n{\n  \"entryFile\": \"src/app.ts\",\n  \"noImplicitAdditionalProperties\": \"throw-on-extras\",\n  \"controllerPathGlobs\": [\"src/**/*-controller.ts\"],\n  \"spec\": {\n    \"outputDirectory\": \"dist\",\n    \"specVersion\": 3\n  },\n  \"routes\": {\n    \"middleware\": \"hapi\",\n    \"routesDir\": \"src\"\n  }\n}\n```\n\n`src/app.ts`\n\n```typescript\nimport * as Hapi from '@hapi/hapi'\nimport { RegisterRoutes } from './routes'\n\nexport const app = (host = 'localhost', port = 3000): Hapi.Server =\u003e {\n  const server = Hapi.server({ host, port })\n  RegisterRoutes(server)\n  return server\n}\n```\n\n`src/server.ts`\n\n```typescript\nimport { app } from './app'\n\nconst host = process.env.HOST || 'localhost'\nconst port = Number(process.env.PORT) || 3000\n\nvoid app(host, port).start()\nconsole.log(`Server running on ${host}:${port}`)\n```\n\n## Requests\n\n```shell\nyarn gen\nyarn build\nyarn start\n```\n\n```shell\n# GET /users/{id}\ncurl -i http://localhost:3000/users/1 \\\n  -H 'Accept: application/json'\n\n# POST /users and see headers\ncurl -i -X POST http://localhost:3000/users \\\n  -H 'Accept: application/json' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"email\":\"john@doe.com\",\"name\":\"John Doe\",\"phoneNumbers\":[]}'\n\n# POST /users and see success response\ncurl -s -X POST http://localhost:3000/users \\\n  -H 'Accept: application/json' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"email\":\"john@doe.com\",\"name\":\"John Doe\",\"phoneNumbers\":[]}' | jq\n\n# POST /users and see error response\ncurl -s -X POST http://localhost:3000/users \\\n  -H 'Accept: application/json' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"id\":123,\"name\":\"Foo Bar\",\"status\":\"Happy\"}' | jq\n```\n\n## Live reloading\n\n```shell\nyarn add -D nodemon ts-node concurrently\n```\n\n`nodemon.json`\n\n```json\n{\n  \"exec\": \"ts-node src/server.ts\",\n  \"watch\": [\"src\"],\n  \"ignore\": [\"src/routes.ts\"],\n  \"ext\": \"ts\"\n}\n```\n\n`package.json`\n\n```json\n{\n  \"scripts\": {\n    \"dev\": \"concurrently \\\"nodemon\\\" \\\"nodemon -x tsoa spec-and-routes\\\"\",\n  }\n}\n```\n\n```shell\nyarn dev\n```\n\n## OpenAPI specification\n\n```shell\nyarn add -D redoc-cli\n```\n\n`package.json`\n\n```json\n{\n  \"scripts\": {\n    \"bundle:api-docs\": \"redoc-cli bundle dist/swagger.json -o dist/api-docs.html\",\n    \"serve:api-docs\": \"redoc-cli serve dist/swagger.json\",\n  }\n}\n```\n\n```shell\nyarn bundle:api-docs\nyarn serve:api-docs\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm99coder%2Ftsoa-hapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm99coder%2Ftsoa-hapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm99coder%2Ftsoa-hapi/lists"}