Skip to content

Commit

Permalink
2.0.1
Browse files Browse the repository at this point in the history
- Added `router.stack` feature.
- Bumped various dependencies.
  • Loading branch information
kethinov committed Nov 20, 2021
1 parent 09b2a06 commit f63f794
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

- Put your changes here...

## 2.0.1

- Added `router.stack` feature.
- Bumped various dependencies.

## 2.0.0

- Transferred ownership of this repo to the Roosevelt framework.
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,25 @@ pageExpressMapper({

Default: `undefined`

The `router` object returned by `pageExpressMapper()` also has a member object called `stack` indexed by route with member booleans for whether the route accepts GET, POST, or both. This is useful for getting a list of all registered routes on your frontend.

Example `router.stack` object:

```javascript
{
"/": {
"get": true
},
"/about": {
"get": true
},
"/pageWithForm": {
"get": true,
"post": true
}
}
```

Sample app
===

Expand Down
8 changes: 8 additions & 0 deletions page-express-mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,26 @@ function pageExpressMapper (params) {
return {
get: function (callback) {
page(route, callback)
router.stack[route] = router.stack[route] || {}
router.stack[route].get = true
},
post: function (callback) {
page(route, callback)
router.stack[route] = router.stack[route] || {}
router.stack[route].post = true
},
all: function (callback) {
page(route, callback)
router.stack[route] = router.stack[route] || {}
router.stack[route].get = true
router.stack[route].post = true
}
}
}
}
}

router.stack = {}
return router
}

Expand Down

0 comments on commit f63f794

Please sign in to comment.