micro-fs-router
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

micro-fs-router

A micro plugin that leverage the filesystem

NPM version Build Status Coverage percentage

Features

  • Works out of the box with zero config
  • Automatically parse request query, params and body
  • Can be extended with a compose function
  • Support route params, nested routes, ...

Getting started

Install the project using your favourite package manager.

npm install micro-fs-router

Import the module in your main script and run it with the routes path.

import microFsRouter from "micro-fs-router";
 
const router = microFsRouter("./routes");
 
export default router;

Inside the routes folder a file called hello.js with a micro function.

export default function({ query }) {
    return `Hello, ${query.name || "micro"}`;
}

Now run it with micro and try to access the service.

$ npx micro index.js
$ curl http://localhost:3000/hello
Hello, micro

$ curl http://localhost:3000/hello?name=test
Hello, test

Contributing

  1. Create an issue and describe your idea
  2. Fork the project (https://github.com/b4dnewz/micro-fs-router/fork)
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes with logic (git commit -am 'Add some feature')
  5. Publish the branch (git push origin my-new-feature)
  6. Add some test for your new feature
  7. Create a new Pull Request

License

Made with love and MIT license © Filippo Conti

Package Sidebar

Install

npm i micro-fs-router

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

22.4 kB

Total Files

9

Last publish

Collaborators

  • b4dnewz