aramsay-server
Basic express server with plumbing in place, ready to use for application development.
Last updated 4 years ago by andrewaramsay .
MIT · Original npm · Tarball · package.json
$ cnpm install aramsay-server 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 0.1.32                                ...           latest (4 years ago)

33 Versions

  • 0.1.32                                ...           4 years ago
  • 0.1.31                                ...           4 years ago
  • 0.1.30                                ...           4 years ago
  • 0.1.29                                ...           4 years ago
  • 0.1.28                                ...           4 years ago
  • 0.1.27                                ...           4 years ago
  • 0.1.26                                ...           4 years ago
  • 0.1.25                                ...           4 years ago
  • 0.1.24                                ...           4 years ago
  • 0.1.23                                ...           4 years ago
  • 0.1.22                                ...           4 years ago
  • 0.1.21                                ...           4 years ago
  • 0.1.20                                ...           4 years ago
  • 0.1.19                                ...           4 years ago
  • 0.1.18                                ...           4 years ago
  • 0.1.17                                ...           4 years ago
  • 0.1.16                                ...           4 years ago
  • 0.1.15                                ...           4 years ago
  • 0.1.14                                ...           4 years ago
  • 0.1.13                                ...           4 years ago
  • 0.1.12                                ...           4 years ago
  • 0.1.11                                ...           4 years ago
  • 0.1.10                                ...           4 years ago
  • 0.1.9                                ...           4 years ago
  • 0.1.8                                ...           4 years ago
  • 0.1.7                                ...           4 years ago
  • 0.1.6                                ...           4 years ago
  • 0.1.5                                ...           4 years ago
  • 0.1.4                                ...           4 years ago
  • 0.1.3                                ...           4 years ago
  • 0.1.2                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (18)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |