Skip to content

Instantly share code, notes, and snippets.

@gwuah
Created January 16, 2019 09:38
Show Gist options
  • Save gwuah/2b1627c7edf15a02e04598d3ef7aa2ad to your computer and use it in GitHub Desktop.
Save gwuah/2b1627c7edf15a02e04598d3ef7aa2ad to your computer and use it in GitHub Desktop.
const Ottis = require('Ottis');
const router = Ottis.router;
/* easily declare your route permissions. */
/* can make only post, get, and put requests to /users */
router("/users").post().get().put().done();
/* can make any type of http request to /users */
router("/products").all();
/* can make any type of http request to all routes */
router("*").all();
// no need for something like this
// that's just too much work.
{
"permissions": [
{
"resource": "/users",
"methods": ["POST", "GET", "PUT"],
"action": "allow"
},
{
"resource": "/products",
"methods": ["POST", "GET", "PUT", "DELETE"],
"action": "allow"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment