https://github.com/brechtcs/routesfile
Parse ROUTES file for static sites
https://github.com/brechtcs/routesfile
Last synced: about 1 month 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 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-14T17:36:50.000Z (almost 8 years ago)
- Last Synced: 2025-10-05T19:46:21.476Z (about 2 months ago)
- Language: JavaScript
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- 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