tsoa

Framework with integrated OpenAPI compiler to build Node.js serve-side applications using TypeScript.

Example

   1 npm init
   2 npm install ts-node typescript express @types/express tslint cors @types/cors tsoa @types/tsoa swagger-ui-express @types/swagger-ui-express
   3 mkdir -p src/hello
   4 touch src/index.ts
   5 touch src/hello/helloController.ts  
   6 touch src/hello/helloResponse.ts
   7 
   8 mkdir -p build
   9 # create tsconfig
  10 npx tsc --init
  11 touch README.md 
  12 # ts-node src/index.ts
  13 # enable "experimentalDecorators": true,  in tsconfig.json 
  14 # enable "resolveJsonModule": true, in tsconfig.json  
  15 # in script start in package.json put 
  16 #  npx tsoa swagger && npx tsoa spec-and-routes && ts-node src/index.ts
  17 npm start
  18 # http://localhost:3000/
  19 curl -vvv localhost:3000
  20 curl -vvv localhost:3000/swagger/

== tsoa.json ==

   1 {
   2   "entryFile": "src/index.ts",
   3   "noImplicitAdditionalProperties": "throw-on-extras",
   4   "controllerPathGlobs": [
   5     "src/**/*Controller.ts"
   6   ],
   7   "spec": {
   8     "outputDirectory": "build",
   9     "specVersion": 3
  10   },
  11   "routes": {
  12     "routesDir": "build"
  13   }
  14 }

src/index.ts

tsoa (last edited 2023-10-10 20:33:18 by vitor)