npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

literium-request

v0.2.1

Published

Request module for Literium web-framework.

Downloads

14

Readme

Request for Literium web-framework

npm version npm downloads Build Status

This project is part of Literium WEB-framework but can be used standalone.

Why not use fetch API

The Literium applications used Fetch API some time ago. The fetch adds overhead related to promises, but Literium uses own less complex and lightweight alternative to promises which is called futures. Unlike promises which has two final states (resolved and rejected) the Literium futures has single final (resolved) which can hold either value or error.

Request API

The API have single function, named request, which gets request data and returns future of result with response data as a value and string as an error.

function request(req: GenericRequest): Future<Result<GenericResponse, string>>;

The simple way to run request shown in the example below:

import { is_ok, un_ok } from 'literium-base';
import { request, Method, Status, DataType } from 'literium-request';

request({
    method: Method.Get,
    url: '/some/api/path',
    headers: { accept: 'application/json' }
    response: DataType.String,
})(res => {
    if (is_ok(res)) {
      const { status, message, body } = un_ok(res);
      if (status == 200 &&
          message == 'OK') {
          const data = JSON.parse(body);
          // do something with data
      }
})

Typed requests

There is some correct use-cases for requests. This package provides corresponding typing rules to check correctness of request construction by TypeScript compiler.

For example, you can do POST or PUT requests with body but you cannot do GET or DELETE requests with body.

Requests without body

The simple requests haven't body.

interface RequestWithoutBody<TMethod extends Method> {
    method: TMethod;
    url: string;
    headers?: Headers;
    timeout?: number;
    progress?: Send<Progress>;
}

The methods of requests without body is: GET, HEAD, and DELETE.

Requests with body

interface RequestWithBody<TMethod extends Method> extends RequestWithoutBody<TMethod> {
    body: GenericBody;
}

The methods of requests with body is: POST, PUT, and PATCH.

Typed responses

Response body types

To set preferred type of response body use response field of request.

interface WithResponseBody<TData extends DataType> {
    response: TData;
}

You must set response type when you need body contents of response, else you won't be able to read it at all.

Responses without body

The responses which never have body is: HEAD, DELETE and OPTIONS.

Common types

Headers

Currently you can set request headers and get response headers as dictionary with string keys and values:

type Headers = Record<string, string>;

The types headers system, like that Rust's Hyper provides, is not implemented because it adds extra complexity level.

The available/allowed header names related to user-agent restrictions.

Body data types

You can send and receive text and binary data in body:

const enum DataType {
    String,
    Binary,
}

type GenericBody = string | ArrayBuffer;

Progress events

To receive progress events you may set progress field of request.

The progress event looks like below:

interface Progress {
    left: number;  // loaded bytes
    size: number;  // total bytes
    down: boolean; // true when downloading, false when uploading
}