Skip to content
Myr

transport.ts

This file

Path

examples/burrow/packages/kit/src/transport.ts

21 lines · 725 bytes · TypeScript

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than 678c8b8 point at it.

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 1–21why, one step back
1/** What a request comes back as: its status, and its body as text. */
2export interface Reply {3 readonly status: number;4 readonly text: string;5}67/** Sends a GET to a URL. Services use `fetchTransport`; tests pass a fake. */8export type Transport = (url: string) => Promise<Reply>;910/** Where every burrow service's API lives. */11export const API = "https://api.burrow.example";1213/** The transport over the runtime's own `fetch`. */14export const fetchTransport: Transport = async (url) => {15 const response = await fetch(url);1617 return { status: response.status, text: await response.text() };18};1920/** Whether a status is a success (2xx). */21export const isSuccess = (status: number) => status >= 200 && status < 300;