Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
IonicaBizau committed Feb 28, 2017
1 parent eaaa502 commit 888f25f
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,48 @@ $ npm i --save bloggify-flexible-router


```js
const bloggifyFlexibleRouter = require("bloggify-flexible-router");

console.log(bloggifyFlexibleRouter());
// Config
{
"bloggify-flexible-router": {
"controllers_dir": "app/controllers",
"routes_dir": "app/routes",
"error_pages": {
"404": "404.ajs",
"500": "500.ajs",
"bad_csrf": "422.ajs"
}
}
}

// The app/routes contains:
// ├── 404.ajs
// ├── 422.ajs
// ├── 500.ajs
// └── users
// └── _user
// └── index.ajs

// The app/controllers contain the controllers. For instance, app/users/_user/index.js would look like this:
const USERS = {
"Alice": {
name: "Alice"
, location: "Earth"
}
};

exports.get = (lien, cb) => {
const user = USERS[lien.params.user];

// End with a 404 if the user is not found
if (!user) {
return lien.next();
}

// Pass the data to the template
cb(null, {
user
});
};
```

## :memo: Documentation
Expand Down

0 comments on commit 888f25f

Please sign in to comment.