A micro plugin that leverage the filesystem
- 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, ...
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
- Create an issue and describe your idea
- Fork the project (https://github.com/b4dnewz/micro-fs-router/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes with logic (
git commit -am 'Add some feature'
) - Publish the branch (
git push origin my-new-feature
) - Add some test for your new feature
- Create a new Pull Request
Made with love and MIT license © Filippo Conti