- Notifications
You must be signed in to change notification settings - Fork40
sdkgen is a tool to help design, implement and maintain good APIs with minimal effort
License
NotificationsYou must be signed in to change notification settings
sdkgen/sdkgen
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
First of all you need Node.js 16 or newer on your machine. We recommend using the latest LTS version, check for it here:https://nodejs.org/en/download/.
Install the global CLI:
npm i -g @sdkgen/cliCreate anapi.sdkgen to describe your API. For example:
type Post { id: uuid title: string body: string createdAt: datetime author: { name: string }}fn getPost(id: uuid): Post?You can then generate the TypeScript source for this description withsdkgen api.sdkgen -o api.ts -t typescript_nodeserver.
Let's start a new project with TypeScript:
npm init -ynpm i --save-dev typescriptnpm i @sdkgen/node-runtimenpx tsc --init -t esnextThen create amain.ts file:
// Import sdkgen's runtime and the generated fileimport{SdkgenHttpServer}from"@sdkgen/node-runtime";import{api}from"./api";// Every endpoint described must receive some implementationapi.fn.getPost=async(ctx,{ id})=>{return{ id,title:"Getting Started",author:{name:"John Doe"},body:"Lorem ipsum",createdAt:newDate(),};};// Start a HTTP server for the APIconstserver=newSdkgenHttpServer(api);server.listen(8000);
Build and run it:
npx tscnode main.jsAbout
sdkgen is a tool to help design, implement and maintain good APIs with minimal effort
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.