Skip to content

Latest commit

 

History

History
67 lines (50 loc) · 1.44 KB

README.md

File metadata and controls

67 lines (50 loc) · 1.44 KB

tsoa

A Wing library for working with TSOA - An OpenAPI-compliant Web APIs using TypeScript.

Prerequisites

Installation

npm i @winglibs/tsoa

Usage

// main.w
bring tsoa;

let service = new tsoa.Service(
  controllerPathGlobs: ["./src/*Controller.ts"],
  outputDirectory: "../build",
  routesDir: "../build"
);

It is also possible to use Wing resources from the TS code

let bucket = new cloud.Bucket();
service.lift(bucket, id: "bucket", allow: ["put"]);
// someController.ts ...
import { lifted } from "@winglibs/tsoa/clients.js";

@Get("{userId}")
public async getUser(
  @Path() userId: number,
  @Request() request: Req,
  @Query() name?: string,
): Promise<User> {
  let bucket = lifted("bucket");
  await bucket.put(userId.toString(), name ?? "not-a-name");

  return  {
    id :userId,
    name: name ?? "not-a-name",
    status: "Happy",
    email:"email",
    phoneNumbers: ["a"]
  }
}

Roadmap

License

This library is licensed under the MIT License.