Goal | Import Handy API v2 using a code generator and use the imported code to create a TypeScript application that starts Handy and then stops it after 5 seconds |
---|---|
Completion time | 15min |
Skills needed | Typescript, package managers |
Installed tools | nodejs + npm |
All our APIs can be generated into full-typed classes. In this tutorial, we will generate code from the Handy API v2 and make a Handy move using the generated code.
Create a folder and navigate into the folder:
mkdir typescript-api
cd typescript-api
Create a file called ts-demo.ts
Create a new project.
npm init -y
Not needed if you already have this installed globally
npm install -D typescript ts-node
The code generator will generate typed codes for all the API functions.
npm install -D openapi-typescript-codegen