laze
A tiny typed class-based REST client based on ohmyfetch.
usage
import { ... } from "https://deno.land/x/laze@0.1.0/mod.ts"
import { ... } from "laze-rest"
import { ... } from "https://www.skypack.dev/laze-rest"
import { ... } from "https://github.com/Suyashtnt/laze/releases/download/version/bundle.js"
@RestClient("https://jsonplaceholder.typicode.com")
class TestClient {
@GET("/todos")
getAllTodos(): Promise<Todo[]> {
throw new Error("not implemented");
}
@GET("/todos")
getTodosForUser(@Query("userId") userId: number): Promise<Todo[]> {
throw new Error("not implemented");
}
@POST("/todos")
addTodo(@Body todo: Omit<Todo, "id">): Promise<Pick<Todo, "id">> {
throw new Error("not implemented");
}
@PUT("/todos/:id")
replaceTodo(
@Path("id") todoId: number,
@Body newTodo: Todo,
): Promise<Todo> {
throw new Error("not implemented");
}
@Header("Test", "Use wireshark or something to see it being sent")
@PATCH("/todos/:id")
updateTodo(
@Path("id") _todoId: number,
@Body _newTodo: Partial<Todo>,
): Promise<Todo> {
throw new Error("not implemented");
}
@DELETE("/todos/:id")
deleteTodo(@Path("id") _todoId: number): Promise<void> {
throw new Error("not implemented");
}
}
const client = new TestClient();
console.log(client.getAllTodos())