Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

littlefork-http

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

littlefork-http

A HTTP interface for littlefork.

  • 1.0.0-rc.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

The Littlefork HTTP.

Wrap littlefork around a HTTP API.

Installation

git clone git@gitlab.com: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.

Keywords

FAQs

Package last updated on 11 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc