All Projects → serviejs → servie

serviejs / servie

Licence: other
Standard, framework-agnostic HTTP interfaces for JavaScript servers and clients

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to servie

net
A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package.
Stars: ✭ 16 (-58.97%)
Mutual labels:  https, request, response
Interceptors
Low-level HTTP/HTTPS/XHR/fetch request interception library.
Stars: ✭ 100 (+156.41%)
Mutual labels:  https, request
Http Client
A high-performance, high-stability, cross-platform HTTP client.
Stars: ✭ 86 (+120.51%)
Mutual labels:  https, request
Sppermissions
Ask permissions with ready-use interface. You can check status permission and if it has been requested before. Support SwiftUI.
Stars: ✭ 4,701 (+11953.85%)
Mutual labels:  interface, request
electron-request
Zero-dependency, Lightweight HTTP request client for Electron or Node.js
Stars: ✭ 45 (+15.38%)
Mutual labels:  https, request
Phin
Node HTTP client
Stars: ✭ 449 (+1051.28%)
Mutual labels:  https, request
Fire
🔥A delightful HTTP/HTTPS networking framework for iOS/macOS/watchOS/tvOS platforms written in Swift.
Stars: ✭ 243 (+523.08%)
Mutual labels:  https, request
Netclient Ios
Versatile HTTP Networking in Swift
Stars: ✭ 117 (+200%)
Mutual labels:  request, response
chronosjs
JS Channels (Events / Commands / Reqest-Response / Courier) Mechanism
Stars: ✭ 35 (-10.26%)
Mutual labels:  request, response
WaterPipe
URL routing framework, requests/responses handler, and HTTP client for PHP
Stars: ✭ 24 (-38.46%)
Mutual labels:  request, response
http
Aplus Framework HTTP Library
Stars: ✭ 113 (+189.74%)
Mutual labels:  request, response
wumpfetch
🚀🔗 A modern, lightweight, fast and easy to use Node.js HTTP client
Stars: ✭ 20 (-48.72%)
Mutual labels:  https, request
Examples
Examples of Mock Service Worker usage with various frameworks and libraries.
Stars: ✭ 163 (+317.95%)
Mutual labels:  request, response
izzyparser-ios
IzzyParser is an iOS library for serializing and deserializing JSON:API objects
Stars: ✭ 19 (-51.28%)
Mutual labels:  request, response
Holen
Declarative fetch for React
Stars: ✭ 152 (+289.74%)
Mutual labels:  request, response
Shcheck
A basic tool to check security headers of a website
Stars: ✭ 160 (+310.26%)
Mutual labels:  https, response
Kitura Net
Kitura networking
Stars: ✭ 98 (+151.28%)
Mutual labels:  request, response
Alamofire
Elegant HTTP Networking in Swift
Stars: ✭ 36,896 (+94505.13%)
Mutual labels:  request, response
reqres
Powerful classes for http requests and responses
Stars: ✭ 36 (-7.69%)
Mutual labels:  request, response
active endpoint
[ARCHIVE] 🔧 ActiveEndpoint is middleware for Rails application that collect and analize request and response per request for route endpoint. It works with minimum affecting to application response time.
Stars: ✭ 13 (-66.67%)
Mutual labels:  request, response

Servie

NPM version NPM downloads Build status Test coverage Bundle size

Standard, framework-agnostic HTTP interfaces for JavaScript servers and clients.

Installation

npm install servie --save

Usage

import { Body, Request, Response, Headers, AbortController } from "servie";

Servie is a universal package, meaning node.js and browsers are supported without needing configuration. This means the primary endpoint requires some dom types in TypeScript. When in a node.js, or browser, only environment, prefer importing servie/dist/{node,browser} instead.

Body

Base HTTP class shared between Request and Response.

new Body(body, headers);

Body

Supported body types, depending on environment:

  • Node.js - string | Buffer | ArrayBuffer | Readable | null | undefined
  • Browser - string | ArrayBuffer | ReadableStream | null | undefined

Properties and Methods

  • bodyUsed Boolean whether the body is already consumed
  • text() Returns the body as a Promise<string>
  • json() Returns the body with JSON.parse as Promise<any>
  • arrayBuffer() Returns the body as a Promise<ArrayBuffer>
  • clone() Clones an unconsumed body
  • destroy() Consumes and destroys the body

Request

HTTP class for modelling a Request, extends Body.

new Request(input [, init]);

Input

A URL string or another Request instance to clone from.

Init

  • method? HTTP request method.
  • body? Any support body types.
  • signal? A signal from an AbortController.
  • headers? A map, list of tuples, or Header instance to initialize from.
  • trailer? A promise resolve to a support header initialization types (above).

Properties and Methods

  • url Requested url string
  • method Requested method string
  • signal Signal event emitter
  • headers A Headers instance
  • trailer A Promise<Headers> instance
  • clone() Clones the request into a new instance

Response

HTTP class for modelling a Response, extends Body.

new Response([body [, init]]);

Body

One of the support body types (above).

Init

  • status? The numeric HTTP response status code
  • statusText? The HTTP response status text

Properties and Methods

  • status The numeric HTTP response status code
  • statusText The HTTP response status text
  • ok Boolean indicates successful response (status between 200 and 299)
  • headers A Headers instance
  • trailer A Promise<Headers> instance
  • clone() Clones the response into a new instance

Headers

Map representation of HTTP headers.

new Headers([init]);

Init

Initialize headers from Iterable<HeaderTuple>, a HeadersObject or an existing Headers instance.

Methods

  • set(name: string, value: string | string[]): void Set a HTTP header by overriding case-insensitive headers of the same name
  • append(name: string, value: string | string[]): void Append a HTTP header
  • get(name: string): string | undefined Retrieve a case-insensitive HTTP header
  • getAll(name: string): string[] Retrieve a list of matching case-insensitive HTTP headers
  • has(name: string): boolean Check if a case-insensitive header is already set
  • delete(name: string): void Delete a case-insensitive header
  • asObject(): HeadersObject Return the lower-cased headers as a plain object
  • extend(obj: HeadersInit): this Extends the current headers with an object
  • keys() Iterable of the available header names
  • values() Iterable of header values
  • entries() Iterable of headers as [key, value]
  • clear() Clears the headers instance
  • clone() Clones the Headers instance

AbortController

Simple controller for aborting a Request instance.

new AbortController();

Properties and Methods

  • signal A Signal instance to pass to a Request
  • abort() Used to abort any listening requests through the signal

Signal

Tiny event emitter for communicating during a request.

Methods

  • aborted Boolean indicating whether the request is aborted
  • on(type, fn) Attach an event listener to an event type
  • off(type, fn) Remove an event listener from an event type
  • each(fn) Attach an event listener for all events
  • none(fn) Remove a global event listener
  • emit(type, ...args) Emit an event to all listeners

Standard Events

  • abort The request has been aborted
  • requestBytes Emitted on request progress with current bytes
  • requestEnded The request has ended
  • requestStarted The request has been started
  • responseBytes Emitted on response progress with current bytes
  • responseEnded The response has ended
  • responseStarted The response has started

Plugins can emit new types of events.

Implementation

If you're building the transports for Servie, there are some life cycle events you need to be aware of:

  1. Listen to the error event on signal for errors
  2. Listen to the abort event on signal to destroy the connection
  3. Resolve trailer promise and append to HTTP request or response
  4. There are some existing built-in type-safe events in SignalEvents you can support

JavaScript

This module is designed for ES2017 environments and published with TypeScript definitions on NPM.

License

Apache 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].