2.1.0 • Published 1 year ago

bloggify-flexible-router v2.1.0

Weekly downloads
10
License
MIT
Repository
github
Last release
1 year ago

bloggify-flexible-router

Version Downloads

A flexible router for Bloggify apps.

:cloud: Installation

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

# Using yarn
yarn add bloggify-flexible-router

:question: 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. :bug:

:memo: 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 }

:yum: How to contribute

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

:dizzy: Where is this library used?

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

  • bloggify
  • bloggify-cli

:scroll: License

MIT © Bloggify

2.1.0

1 year ago

2.0.7

4 years ago

2.0.6

4 years ago

2.0.5

4 years ago

2.0.4

5 years ago

2.0.3

6 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago