Have ideas to improve npm?Join in the discussion! »

typedrest
TypeScript icon, indicating that this package has built-in type declarations

0.3.3 • Public • Published

TypedRest for TypeScript

TypedRest API documentation Build
TypedRest helps you build type-safe, fluent-style REST API clients. Common REST patterns such as collections are represented as classes, allowing you to write more idiomatic code.

const client = new MyClient(new URL("http://example.com/"));
 
// GET /contacts
const contactList: Contact[] = await client.contacts.readAll();
 
// POST /contacts -> Location: /contacts/1337
const smith: ContactEndpoint = await client.contacts.create(new Contact("Smith"));
//const smith: ContactEndpoint = client.contacts.get("1337");
 
// GET /contacts/1337
contactContact = await smith.read();
 
// PUT /contacts/1337/note
await smith.note.set(new Note("some note"));
 
// GET /contacts/1337/note
const note: Note = await smith.note.read();
 
// DELETE /contacts/1337
await smith.delete();

Read a more detailed Introduction to TypedRest or jump right in with the Getting started guide.

Install

npm i typedrest

DownloadsWeekly Downloads

20

Version

0.3.3

License

MIT

Unpacked Size

229 kB

Total Files

93

Last publish

Collaborators

  • avatar