You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@untypeable/hackernews

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@untypeable/hackernews

Untypeable router type definitions & validators for the Hacker News API

1.0.2
latest
Source
npmnpm
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

🗞️ @untypeable/hackernews

Untypeable router type definitions & validators for the Hacker News API

🚀 Install

Install it locally in your project

# npm
npm install @untypeable/hackernews

# yarn
yarn add @untypeable/hackernews

# pnpm
pnpm install @untypeable/hackernews

🦄 Usage

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

import { createTypeLevelClient } from "untypeable";

import type { HackerNewsRouter } from "@untypeable/hackernews";

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

  const url = new URL(pathWithParams, "https://hacker-news.firebaseio.com");

  const response = await fetch(url.href);

  return await response.json();
});

const topStories = await client("/v0/topstories.json");

Keywords

api

FAQs

Package last updated on 11 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts