Giter Club home page Giter Club logo

micro-fs-router's Introduction

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

micro-fs-router's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.