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

aramsay-server

v2.0.0

Published

Basic express server with plumbing in place, ready to use for application development.

Downloads

40

Readme

ARamsay Server

This is a simple express server with no routes configured*. The idea is that it can be dropped into a MEAN project, and all the boilerplate of getting the server started will be taken care of. You begin coding with adding routes to an express router, and focusing your development time on business logic rather than configuring authentication/authorization, logging, error handling, etc.

  • I may add some pre-build auth routes in the future

disclaimer this project is primarily written to make my life easier. It is built around my preferred structure of MEAN stack applications, and may lack configuration options necessary for use in a different context.

Usage

In your main server.js file, simply instantiate the server, call into your routes config (see below), and call .start().

	// server.js
const SimpleServer = require('simple-server');
	const config = require('./config');
	const routesConfig = require('./routesConfig');

let simpleServer = new SimpleServer(config);

simpleServer.configureRoutes(routesConfig);

simpleServer.start();

The SimpleServer constructor takes in a single parameter, a config object containing the options described below. It can be specified inline but the server.js file can be kept much cleaner by putting it in its own module. // config.js module.exports = { // ... };

Your routesConfig.js file must export an object with a single method on it: configureRoutes. It can be a class with other methods you use to set up other dependencies, or it can be a simple object literal with a configure function. // routesConfig.js module.exports = { configure(router, middlewares) { router.get('/api/my-resource', function () { /* ... */ }); } };

Options

TBD

Authentication

A basic authentication system is in place. This supports 3 authentication strategies pre configured to work with the users in the database.

  • 'local' - Looks for a username/password in the request body. It will verify the credentials against the database. (used internally for obtaining an auth token).
  • 'token' - Looks for an 'Authorization: Bearer SOME_JWT_TOKEN' header in the request. It validates the token and finds the user identified in the payload.
  • 'anonymous' - Allows access without any successful authentication.

All routes should specify the authenticate() middleware, and explicitly state if they allow anonymous access. There is a custom eslint rule require-authenticate enabled by default to assist in catching routes missing an authenticate() call.