From 888f25f6064a7e631046b177d91f78bffc03807f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Tue, 28 Feb 2017 17:39:38 +0200 Subject: [PATCH] Updated docs --- README.md | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3c3a259..f34c795 100644 --- a/README.md +++ b/README.md @@ -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