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 🙏

© 2024 – Pkg Stats / Ryan Hefner

littlefork-http

v1.0.0-rc.1

Published

A HTTP interface for littlefork.

Downloads

2

Readme

The Littlefork HTTP.

Wrap littlefork around a HTTP API.

Installation

git clone [email protected]:littlefork/littlefork-api.git
cd littlefork-api
npm install

The littlefork API is configured using environment variables. It's possible to configure options in a local file, .env. This file will not be added to the git repository, an entry in the .gitignore prevents that.

cp .env.example
cat .env  // Edit as necessary
  • LF_API_PORT :: The port to listen on. Defaults to 6667.
  • LF_API_DATA_DIR :: The path to the storage directory. Defaults to ./data.
  • LF_API_KEY :: The api key that should be sent in a header to auth the request

Usage

To simply run the API, start the server: npm run server. This starts a server on the port defined in the environment as LF_API_PORT.

There are local targets to run the linting, documentation building and unit testing. Simply start a development setup: npm run dev.

The package exports the server as a binary. Add littlefork-http as a dependency and run the server:

$(npm bin)/littlefork-http

Documentation

To build the latest version of this readme run: npm run docs:api. This rebuilds this readme file.

The HTTP routes are documented as well. To build them run: npm run docs:rest. This will build HTML documentation for the HTTP routes. They can be found in docs/rest.

firefox docs/rest/index.html

To build all docs, run: npm run docs.

Development

All functions are curried:

read('path/to/dir', 'project'); // =
read('path/to/dir')('project');

curl test: curl -v -H "apikey: haha" http://localhost:8666/projects

fs-db

read

Read a file and return it as parsed JSON.

read :: String -> String -> Future Json

Parameters

  • p String The path of the node.
  • f String The name of the file.

Returns Promise<Object> The parsed JSON that was read from the file.

init

Initialize a node.

init :: String -> Future ()

Parameters

  • p String The path of the node.

Returns Promise<Null> Returns Unit, pure side effect.

write

Write data into a node. Initialize the node recursively if it doesn't exist.

write :: String -> String -> {} -> Future ()

Parameters

Returns Promise<Null> Returns Unit, pure side effect.

readNode

Read a node for all data and sub nodes.

readNode :: String -> Future [[Object], [String]]

const [fs, ds] = readNode('data/projects');
// fs => [{...}, {...}]
// ds = ['other', 'nodes']

Parameters

  • p String The path of the node.

Returns Promise<Array<Array<Object>, Array<String>>> Returns an array tuple with the first element being a list of data units, and the second element a list of sub nodes.

list

List the data in a node.

list :: String -> Future [Object]

Parameters

  • p String The path of the node.

Returns Promise<Array<Object>> A list of data units.