@untypeable/spacex

v1.0.2
Untypeable router type definitions & validators for the open source SpaceX API
api space spacex typescript untypeable

🚀 @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");
npm i @untypeable/spacex

Metadata

  • MIT
  • Whatever
  • nurodev
  • released 4/11/2023

Downloads

Maintainers