0.2.2 • Published 3 years ago

typewags v0.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

typewags

A typescript web API generator script.

Usage

To generate the TypeScript definitions, you need a type definition and web API information JSON.

Here is a NuGet package for ASP.NET Core projects to generate the JSON:

typewags-aspnetcore

Here is an example of usage if you followed the example of typewags-aspnetcore.

import axios from "axios";
import path from "path";
import fs from "fs/promises";
import { WebAPIInspectResult, ApiBundleGenerator } from "typewags";

async function main() {
  const response = await axios.get<WebAPIInspectResult>(
    // If you follow the example, you can get the definition json by the following request.
    "http://localhost:5000/typewags"
  );
  const json = response.data;
  // Generate all of the definitions by a simple API.
  const generator = new ApiBundleGenerator(json);
  const declarationContent = generator.generateApiInterfaceBundle();
  await fs.writeFile(
    path.resolve(process.cwd(), "bundle.ts"),
    declarationContent
  );
}

main();
0.2.1

3 years ago

0.2.0

3 years ago

0.2.2

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago