Skip to content

Latest commit

 

History

History

lil.apis

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

🤏 @untypeable/lil.apis

Untypeable router type definitions & validators for the lil.apis API

🚀 Install

Install it locally in your project

# npm
npm install @untypeable/lil.apis

# yarn
yarn add @untypeable/lil.apis

# pnpm
pnpm install @untypeable/lil.apis

🦄 Usage

Create a new client instance with the LilRouter & your desired fetch handler

import { createTypeLevelClient } from "untypeable";

import type { LilRouter } from "@untypeable/lil.apis";

const client = createTypeLevelClient<LilRouter>(async (path, input = {}) => {
  const url = new URL(path, "https://api.lil.software/");
  Object.entries(input).forEach(([key, value]) =>
    url.searchParams.append(key, value)
  );

  return fetch(url.href).then((response) => response.json());
});

const weather = await client("/weather", {
  latitude: 40.709335,
  longitude: -73.956558,
});

const news = await client("/news");

const stocks = await client("/stocks", {
  symbol: "AAPL",
});