Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brechtcs/routesfile
Parse ROUTES file for static sites
https://github.com/brechtcs/routesfile
Last synced: about 10 hours ago
JSON representation
Parse ROUTES file for static sites
- Host: GitHub
- URL: https://github.com/brechtcs/routesfile
- Owner: brechtcs
- License: apache-2.0
- Created: 2018-02-13T18:35:14.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-14T17:36:50.000Z (almost 7 years ago)
- Last Synced: 2024-04-24T20:03:09.919Z (7 months ago)
- Language: JavaScript
- Size: 20.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# routesfile
Parse ROUTES file for static sites
## Install
`npm install routesfile`
## Usage
```js
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:
```js
{
[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