@dimerapp/http-server

Http server to serve dimer docs over REST API

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
60Nov 6, 2018Jul 25, 2018Minified + gzip package size for @dimerapp/http-server in KB

Readme

Dimer App

Dimer is an open source project and CMS to help you publish your documentation online.


We believe every project/product is incomplete without documentation.
We want to help you publish user facing documentation, without worrying about tools or code to write.


Dimer Http server

Serve dimer datastore over HTTP server

travis-image appveyor-image npm-image

This module can be used to serve Dimer datastore JSON files over HTTP server.

Installation

npm i @dimerapp/http-server

# yarn
yarn add @dimerapp/http-server

Usage

Http server needs a callback, which is used as a middleware and must attach basePath property to req object.

The basePath is the path where .json files for a website project are stored.

const httpServer = require('@dimerapp/http-server')

const { router, createServer } = httpServer({
  cors: {}, // https://github.com/expressjs/cors#readme
  NODE_ENV: 'development'
})

// This middleware is required and must set the basePath
router.use((req, res, next) => {
  req.basePath = join(__dirname, 'api')

  // optionally
  req.distPath = 'dist'
  next()
})

createServer().listen(5000)

API

/config.json

Returns the config for the project.

Status code Response
200 The response will be an object of config

/versions.json

Returns versions for the project

Status code Response
200 The response will be an array of versions.

/version/:no.json

Returns the content tree for a given version.

You can also use the keyword default instead of defining the version number.

Status code Response
200 An array of docs nested under categories.
404 If version doesn't exists.

/version/:no/:permalink.json

Returns doc content for a given permalink on a given version.

You can also use the keyword default instead of defining the version number.

Status code Response
200 An object containing the doc meta data and actual content in JSON format.
404 If doc doesn't exists.
301 If permalink resolves as a redirect for a given doc. The returned response will have the actual permalink.

/search/:no.json

Search for content for a given version.

You can also use the keyword default instead of defining the version number.

Status code Response
200 An array of docs for the matched result ordered by their score

Change log

The change log can be found in the CHANGELOG.md file.

Contributing

Everyone is welcome to contribute. Please take a moment to review the contributing guidelines.

Authors & License

thetutlage and contributors.

MIT License, see the included MIT file.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.