Catalog npm
PACKAGE EXPLORERView in registry

@01edu/api-client

npm

Type-safe HTTP API Client

Versions collected10
Direct dependencies2From release 0.2.6
Last observed20 Oct, 21:57 UTC

README

Current package documentation

api-client

Tiny, type-safe HTTP API client meant to be used alongside the @01edu/api router (see @01edu/api/router). It builds a strongly-typed client from your server route definitions.

Install

  • deno add jsr:@01edu/api-client

How it fits

  • Define routes on the server with @01edu/api/router and export their type.
  • Use that type on the client with createClient for end-to-end typing.

Server (types export)

import { route } from '@01edu/api/router'
import { STR } from '@01edu/api/validator'

export const routes = {
  'GET/hello': route({
    input: { name: STR() },
    output: { message: STR() },
    fn: (_, { name }) => ({ message: `Hello, ${name}!` }),
  }),
}

export type RoutesDefinitions = typeof routes

Client

import { createClient } from '@01edu/api-client'
import type { RoutesDefinitions } from '/api/routes.ts' // types-only import from your backend

const api = createClient<RoutesDefinitions>('/api')

// One-shot call
const res = await api['GET/hello'].fetch({ name: 'Ada' })

// Reactive usage
const hello = api['GET/hello'].signal()
hello.fetch({ name: 'Ada' })
hello.$.subscribe((v) => console.log(v.pending, v.data, v.error))

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 10

Collected releases
VersionPublishedDirect dependenciesOpen version
0.2.6Registry latest5 May 20262
0.2.55 May 20262
0.2.32 Apr 20262
0.2.21 Apr 20262
0.2.11 Apr 20262
0.1.712 Feb 20262
0.1.512 Jan 20262
0.1.328 Nov 20252
0.1.228 Nov 20252
0.1.127 Nov 20252

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
01-edu/framework

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 21:56 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:dd0a51dae7836b38234741825dc32bcfceb5300a4da32c15edaac32a81e39efc