Skip to content

brechtcs/routesfile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

routesfile

Parse ROUTES file for static sites

Install

npm install routesfile

Usage

var routesfile = require('routesfile')

// async
routesfile.read('./ROUTES', function (err, routes) {
  if (err) throw err
  // do something with `routes`
})

// sync
var fs = require('fs')

var file = fs.readFileSync('./ROUTES', 'utf-8')
var routes = routesfile.parse(file)
// do something with `routes`

API

var routes = routesfile.parse(string)

Returns a routes objects of the following format:

{
  [redirectFromUrl: string]: {
    code: [statusCode: number],
    target: [redirectToUrl: string]
  },
  // more routes...
}

routesfile.read(path, cb)

Callback with signature (err, routes), with routes being the same format as returned by the parse method.

License

Apache-2.0

About

Parse ROUTES file for static sites

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published