0.2.2 • Published 1 year ago
instant-endpoint v0.2.2
Instant endpoint is a factory function for nextjs for declaring routes.
- It handles defining params required for transaction ( headers, params, body )
- Parses unknowns
- Returns an ednpoint function and calling function, with TypeGuard for using an endpoint in a way that will satisfy declared requirements.
const [PANCAKES_ROUTE, CALL_PANCAKES] = instantEndpoint(
"https://localhost:3000/api/test",
"GET",
{ headers: { "Content-Type": "application/json", pancakes: z.string() } },
async (request, { headers }) => {
return {
url: request.url,
pancakes: headers.pancaces,
};
}
);
Export from route.tsx at adres provided in argument to instantEndpoint
export { PANCAEES_ROUTE as GET };
Call endpoint in the client using returned call function
export default async function PancakesComponent(){
const res = await CALL_PANCACES({ headers : { "Content-Type": "application/json", pancakes: "with topping" }})
return (
{ res && <p> res.pancakes </p>}
)
}
0.2.2
1 year ago
0.2.1
1 year ago
0.2.0
1 year ago
0.1.20
1 year ago
0.1.21
1 year ago
0.1.22
1 year ago
0.1.17
1 year ago
0.1.18
1 year ago
0.1.19
1 year ago
0.1.10
1 year ago
0.1.11
1 year ago
0.1.13
1 year ago
0.1.14
1 year ago
0.1.15
1 year ago
0.1.8
1 year ago
0.1.7
1 year ago
0.1.9
1 year ago
0.1.5
1 year ago
0.1.4
1 year ago
0.1.2
1 year ago
0.1.1
1 year ago
0.0.2
1 year ago
0.0.1
1 year ago