@untypeable/spacex
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

🚀 @untypeable/spacex

Untypeable router type definitions & validators for the open source SpaceX API

🚀 Install

Install it locally in your project

# npm
npm install @untypeable/spacex

# yarn
yarn add @untypeable/spacex

# pnpm
pnpm install @untypeable/spacex

🦄 Usage

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

import { createTypeLevelClient } from "untypeable";

import type { SpaceXRouter } from "@untypeable/spacex";

const client = createTypeLevelClient<SpaceXRouter>(async (path, input = {}) => {
  const pathWithParams = path.replace(
    /:([a-zA-Z0-9_]+)/g,
    (_, key) => input[key]
  );

  const url = new URL(pathWithParams, "https://api.spacexdata.com");

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

const capsules = await client("/v4/capsules");

Package Sidebar

Install

npm i @untypeable/spacex

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

255 kB

Total Files

9

Last publish

Collaborators

  • nurodev