api-typify
v0.3.2
Published
Write APIs in TypeScript which compile to less than 400 bytes
Downloads
1,052
Readme
Examples
// api.ts
const routes = {
GET: {
"/users/{id}": {
req: undefined, // Requests body type
res: User, // Response type
},
},
};
const api = getAPI<typeof routes>(
"https://api.example.com",
fetch,
);
// Get's the user object
const user = await api.get("/users/{id}", {
params: {
id: "123",
},
});