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

@luzzif/express-fs

v1.0.2

Published

Bootstraps you express' app routing based on your project structure

Downloads

12

Readme

Coverage Status Build Status

Express FS

Express FS bootstraps your express' app routing based on your source code location, enforcing a neat project structure and removing the need for explicit routing definition.

Installing

npm install @luzzif/express-fs

or

yarn add @luzzif/express-fs

How to use

The library's basic concept block is the fs-route.

In Express FS a fs-route is a simple Node module which exports a handler and some middleware functions (those are the same entities that you would normally define in express in order to specify a route).

An example of an fs-route can be something like this:

// route.js

export const handler = (request, response, next) => next();
export const middleware = (request, response, next) => next();

// Alternatively, multiple middleware functions can be specified
// like this:
// export const middleware = [
//    (request, response, next) => next(),
//    (request, response, next) => next()
// ];

The other aspects of an fs-route aside for the implementation are the path and the method: those are simply deducted by the location of the fs-route module.

The location should in fact reflect the wanted fs-route's path, while the last part of the location should indicate the wanted method.

Some examples to clarify the concept (the route is expressed in the format <method>@<path>):

  • a/route/path/get/index.js => GET@/a/route/path
  • foo/bar/post.js => POST@/foo/bar
  • patch.js => PATCH@/

In order to make Express FS register one or more fs-routes, simply pass the app's root (typically __dirname) and the glob referencing those Node modules containing an fs-route definition to the fsRouter function, and pass the result to express' use.

Example:

// server.js

const express = require("express");
const { fsRouter } = require("@luzzif/express-fs");

const app = express().use(fsRouter(__dirname, "api/**/index.js"));

The snippet above registers all those fs-routes located under the project's root directory api.

By leveraging this approach, Express FS completely eliminates the need for any routing setup and enforces a clear, straight-forward project structure.

Donations

Please if you like my work consider donating something. Every offer helps me giving out the best software!

  • Bitcoin: 3JFXQE6mQibmrxoq3YHKqRUHAvmXxuY8r9
  • Ethereum: 0x35E2acD3f46B13151BC941daa44785A38F3BD97A

Thank you all <3