# express-routes-file

> express routing via rails / play-framework style 'routes' file

Latest version **1.0.9** (published 2020-06-29) · Unlicense license · 0 weekly downloads

## Install

```sh
npm install express-routes-file
pnpm add express-routes-file
yarn add express-routes-file
bun add express-routes-file
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2020-06-29 |
| First published | 2020-05-17 |
| Weekly downloads | 0 |
| License | Unlicense |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Dylan Nissley |
| Maintainers | dnissley |

## Links

- npm: https://www.npmjs.com/package/express-routes-file
- Repository: https://github.com/dnissley/express-routes-file
- Homepage: https://github.com/dnissley/express-routes-file#readme
- Issues: https://github.com/dnissley/express-routes-file/issues
- npm.io page: https://npm.io/package/express-routes-file

## Dependencies (1)

- [array-flat-polyfill](https://npm.io/package/array-flat-polyfill.md) ^1.0.1

## Recent versions

- 1.0.9 (latest) — 2020-06-29
- 1.0.8 — 2020-06-29
- 1.0.7 — 2020-06-29
- 1.0.6 — 2020-06-15
- 1.0.5 — 2020-06-08
- 1.0.4 — 2020-06-08
- 1.0.3 — 2020-06-02
- 1.0.2 — 2020-05-17
- 1.0.1 — 2020-05-17
- 1.0.0 — 2020-05-17

## README

# express-routes-file ![continuous integration status](https://github.com/dnissley/express-routes-file/workflows/Build%20&%20Test/badge.svg) [![npm version](https://badge.fury.io/js/express-routes-file.svg)](https://badge.fury.io/js/express-routes-file)

Ever worked with rails, play framework, or some other web framework that used a 'routes' file to do the simple work of hooking up urls to code? Dislike the overly flexible nature of express routing and wish you had something like a routes file instead? This library is for you.

## Usage

1. To install run this command: `npm install express-routes-file`

2. Create a file named `routes` in the root directory of your project:

    ```plaintext
    GET     /                 someFunction      # first: http method, second: url, third: name of handler function
    POST    /with-param/:id   anotherFunction   # feel free to add comments and blank lines too
    ```

3. Set up your app like this:

    ```javascript
    const express = require('express')
    const configureRoutes = require('express-routes-file')

    const app = express()

    // configureRoutes() returns an express.Router
    const routes = configureRoutes({
      someFunction: (req, res) => res.send('hello from someFunction()'),
      anotherFunction: (req, res) => res.send('hi from anotherFunction()')
    })

    app.use('/', routes)

    app.listen(3000, () => console.log('listening on port 3000'))
    ```

## Working Examples

[Using Plain Node.js](https://github.com/dnissley/js/tree/master/express-routes-file-example)

[Using Typescript](https://github.com/dnissley/ts/tree/master/express-routes-file-example)

---
_Source: https://npm.io/package/express-routes-file · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
