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

just-write-api

v0.3.0

Published

A simple API for creating and organizing content via JSON files.

Downloads

4

Readme

Just Write API

A simple API for creating and organizing content via JSON files. No database required, so it works great as a back-end for static site generation.

Installation

Snag the package from NPM:

npm install --save just-write-api

Standalone Usage

The Just Write API can run as a server on Node.js.

Use it programmatically:

const {server} = require('just-write-api');
server([options]);

Or start it from the command line:

just-write-api [--content-dir content][--host localhost][--port 8001]

Usage as an Express Router

The API endpoints can also be included in an existing Express server. Simply import endpointRouter from the module and use it as you would any other Express router.

const express = require('express');
const {endpointRouter} = require('just-write-api');

const app = express();

app.use(endpointRouter());

// or, as a nested route
app.use('/api', endpointRouter());

Core Concepts

The Just Write API concerns itself with two things: pages and tags.

Pages

Pages could be blog posts, pages on a website, or documents like recipes or book chapters.

A page entity consists of a title and content property and any optional metadata you'd like to associate with it. They're stored and accessed as JSON.

Minimally

{
    "title": "A Minimal Page Example",
    "content": "This is page content."
}

Elaborately

{
    "title": "A Realistic Example for a Static Site Generator",
    "content": "# My Markdown Content!",
    "tags": "a123, b456",
    "created": "December 27, 2017",
    "updated": "January 3, 2018",
    "author": "Peter Parker"
}

Tags

Tags are organizational units of the Just Write API. They're how pages are classified.

Tag entities consist of a name property and any additional metadata; just as with pages, they're stored and accessed as JSON.

Minimally

{
    "name": "My Tag"
}

Elaborately

{
    "name": "A Realistic Tag",
    "description": "A classification relevant to organizing pages.",
    "created": "January 3, 2018",
    "related": "tagId123,tagId456"
}

No Categories?

No. No categories.

Tags, with other tags, can represent any hierarchy: categories, sub-categories, keywords, etc. Information architecture is unopinionated so you can organize your content however you like using logical dis/conjunctions.

Endpoints

/pages

| HTTP Method | Required | Returns | Description | |-------------|----------|---------|-------------| | GET | | Array of objects | Get a listing of all page entities; supports filters | | POST | title, content | Object | Create a new tag entity and returns the newly created resource, including its generated UUID and creation timestamp |

/pages/tagged/:tagId1[,tagId2,...tagIdN]

| HTTP Method | Required | Returns | Description | |-------------|----------|---------|-------------| | GET | | Array of objects | Retrieve pages tagged by the comma-delimited list of tag IDs. Currently only supports conjunctions of tags, but does support filters

/page/:id

| HTTP Method | Required | Returns | Description | |-------------|----------|---------|-------------| | DELETE | | Array of objects | Deletes a specific page resource and returns the new listing of pages | | GET | | Object | Retrieve data for a specific page resource | | PUT | title, content | Object | Update a specific page resource and return the updated resource with a timestamp |

/tags

| HTTP Method | Required | Returns | Description | |-------------|----------|---------|-------------| | GET | | Array of objects | Get a listing of all tag entities; supports filters | | POST | name | Object | Create a new tag entity and returns the created resource, including its generated UUID |

/tag/:id

| HTTP Method | Required | Returns | Description | |-------------|----------|---------|-------------| | GET | | Object | Retrieve data on a specific tag entity | | PUT | name | Object | Update a specific tag entity and return the updated tag | | DELETE | | Array of objects | Delete a specific tag entity and return the updated list of tag entities |

Filters

The API supports filters on specified requests -- namely GETs -- to narrow down a results set. Filters are passed as URI query parameters to the request.

Example

GET /pages?author=Jack
// returns page entities whose author field matches 'Jack'

Currently, filters are only supported for entity field subsets.

Configuration Options

The API has a minimal set of configuration options. All of them are optional.

| Property | Command Line Flag | Default | Description | |----------|-------------------|---------|-------------| | contentDir | --content-dir | content | Folder where content is created and managed in the current working directory | | host | --host | localhost | Host name where the API server will run. Not available when using endpointRouter mode | | port | --port | 8001 | Port the API server will run on. Not available when using endpointRouter mode |