npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

router-plan

v1.1.3

Published

Another way to achieve routing, management projects more convenient.

Downloads

2

Readme

router-plan

Another way to achieve routing, management projects more convenient.

advantage

  1. Clause clearer, a type of routing is a file.

All requests are go through a common method, easy to handle.

  1. Interface only one, different requests only incoming parameters are different.

use

npm install router-plan

The file directory is as follows:

- router-list           --- Storage routing folder
      - A               --- routing folder
            - a.js      --- Specific routing documents
            - index.js  --- Expose the current path of all the routing files
      - index.js        --- Expose the current route all the routing files
- server.js

server.js file format is as follows, after the success of the creation of the server, you only need to call routerPlan () this method and the incoming corresponding parameters, the other automatically help you achieve.

const http = require('http');
const routerPlan = require('router-plan');
http.createServer((req,res) => {
    routerPlan(req, res, {
        routerList:require('./router-list'),    //Routing file address
        crossDomain:true                        //Whether to allow cross-domain
    });
}).listen(80,() => {
    console.log('server start ok!');
});

router-list folder index.js below, mainly used to expose the file inside the router-list folder, used to generate json object.

const fileList = ['a','b','c'];//router-list below all the folder name

fileList.forEach((fileName) => {
    module.exports[fileName] = require(`./${fileName}`);
});

A folder index.js below, mainly used to expose all the files inside the A folder, used to generate json objects

const fileList = ['a','b','c'];//A below all the folder name

fileList.forEach((fileName) => {
    module.exports[fileName] = require(`./${fileName}`);
});

'a.js' file format is as follows: Route file wording, the methods are exposed to the corresponding upper object, through the exports.functionName (method name) to write the interface.

exports.a1 = function (query,req,res) {
      res.end('this is fileName:c,fn:a1');
};

exports.a2 = function (query,req,res) {
    res.end('this is fileName:c,fn:a2');
};

Client request parameters are as follows:

eg: A request a folder inside the a1 method

$.ajax({
    url: 'http://localhost',
    type:'post',
    data: {
        folderName: "A",     //Router-list folder below the folder name
        fileName: "a",       //A folder below the file name
        fn: "a1"             //A file name inside the method
    },
    success: function (data) {
        console.log(JSON.parse(data));
    }
})