I'm trying to make an api wrapper for tmdb (https://developer.themoviedb.org)
and I like the way octokit for github does it... is there a way i can implement this with type safety?
await octokit.request("POST /repos/{owner}/{repo}/issues", {
owner: "octocat",
repo: "hello-world",
title: "Hello, world!",
body: "I created this issue using Octokit!",
});
i think this would be pretty easy
await tmdb.get["/title/{query}"]({
query: 'South Park',
sort: 'ascending',
});
In that example if i understand correctly i would just make tmdb.get a proxy object that returns a function that makes a request to that path and replaces the templates with the values. and then i would manually use tyescript to declare tmdb.get as an object where each property is a function that takes in the parameters and returns the data. it looks kinda janky with the square brackets so i was thinking if there was some kind of solution to make the path the first function parameter? is it possible?