bloggify-flexible-router

    2.0.7 • Public • Published

    bloggify-flexible-router

    Version Downloads

    A flexible router for Bloggify apps.

    ☁️ Installation

    # Using npm 
    npm install --save bloggify-flexible-router
     
    # Using yarn 
    yarn add bloggify-flexible-router

    ❓ Get Help

    There are few ways to get help:

    1. Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
    2. For bug reports and feature requests, open issues. 🐛

    📝 Documentation

    Plugin Configuration

    If the routes (default: app/routes) folder exists, it will dictate the routes structure. For example:

    _ is alias for index. _foo is alias for :foo

    routes/
    ├── 404.ajs                    << 404 page
    ├── _.ajs                      << The index page (loaded on `/`)
    ├── api                        << Rest API (`/api`)
    │   ├── index.js               << Api Handlers (e.g. sending a custom 404)
    │   └── users                  << The `/api/users[/...]` endpoint
    │       ├── index.js           << Handling `/api/users` (sending the list of users)
    │       └── _username          << Handling `/api/users/:username`
    │           └── index.js       << Fetching the user, by username, and sending it
    └── users                      << The users list, in HTML format (`/users`)
        ├── _.ajs                  << The `/users` view
        ├── _.js                   << The `/users` controler
        └── _user                  << `/users/:user` endpoint
            ├── _.ajs              << View
            └── _.js               << Controller
    

    The controller files look like this:

    // Before hook
    exports.before = (ctx, cb) => ...
     
    // After hook
    exports.after = (ctx, cb) => ...
     
    // Handle all the methods
    // Alias for module.exports = ctx => ...
    exports.all = ctx => ...
     
    // Handle post requests
    exports.post = ctx => ...
    • Object config:
    • routes_dir (String): The path to the directory where the routes are stored. They should be randable view files. For dynamic routes, use the _character.

    "/path/to/route": { controllerPath, viewPath }

    😋 How to contribute

    Have an idea? Found a bug? See how to contribute.

    💫 Where is this library used?

    If you are using this library in one of your projects, add it in this list. ✨

    • bloggify
    • bloggify-cli

    📜 License

    MIT © Bloggify

    Install

    npm i bloggify-flexible-router

    DownloadsWeekly Downloads

    2

    Version

    2.0.7

    License

    MIT

    Unpacked Size

    17.3 kB

    Total Files

    4

    Last publish

    Collaborators

    • ionicabizau