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

node-ally

v1.0.4

Published

A collection of express middleware helpers

Downloads

16

Readme

node-ally

A collection of express middleware helpers.

NPM Version Build Status Downloads Stats

node-ally is a very small library that has some middleware functions that I find useful.

Installation

npm install node-ally --save

Usage example

node-ally is an extremely small and easy to use library, it currently contains four middleware functions, these functions are as follows;

  • errorHandler - The error handler is used to capture errors thrown in your NodeJS application and return a message + status code based on the thrown error as the server response.

  • enableCORS - This middleware function enabled cross origin requests

  • notFound - This middleware function will return an appropriate error to the client if they hit an endpoint that doesn't exist in your API

  • requestTime - This middleware records the time of the request and puts it on the req object

import express from 'express';
import { errorHandler, enableCORS, notFound, requestTime } from 'node-ally';

const app = express();

app.use(enableCORS);
app.use(notFound);
app.use(errorHandler);
app.use(requestTime);

export default app;
  • supportCrossOrigin - This is used for preflight requests from browsers, currently it returns a 200 to the preflight request while also telling the browser that it accepts cross origin requests using this will enable CORS for the route you use it on
import express from 'express';
import { supportCrossOrigin } from 'node-ally';

const router = express.Router();

router.options('/hello-world', supportCrossOrigin);
router.post('/hello-world', (req, res, next) => {
  res.status(200).send('Hello World');
});

export default router;

Development setup

If you want to setup node-ally for development then you're going to need to get this repo onto your local machine by forking it and then cloning it, after it's on your machine the rest of the setup is pretty simple, you just need to install the dependencies with npm install and check everything is working with npm test the current node version being used can be found in the .travis.yml

npm install
npm test

Release History

  • 1.0.4
    • ADD: Added middleware function that added the current time to the req object
  • 1.0.3
    • ADD: Added this readme file
    • ADD: added travis CI to the project
  • 1.0.2
    • CHANGE: modified to only bundle index.js rather than index.js and index.test.js in final build
  • 1.0.1
    • FIX: removed deprecated prepublish npm script
  • 1.0.0
    • The initial version of the project

Meta

Grant Leadbetter – @Grantlyk[email protected]

Distributed under the MIT license. See LICENSE for more information.

https://github.com/grantlyk/node-ally

Contributing

  1. Fork it (https://github.com/yourname/yourproject/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Add your changes including tests
  4. Commit your changes (git commit -am 'Add some fooBar')
  5. Push to the branch (git push origin feature/fooBar)
  6. Create a new Pull Request
  7. Ensure the CI build passes