# expedite

> Framework for deploying Express and WebSocket enabled servers in an OO fashion

Latest version **0.0.2** (published 2016-06-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install expedite
pnpm add expedite
yarn add expedite
bun add expedite
```

## Health

**Score 5/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2016-06-05 |
| First published | 2016-06-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 13 |
| Known vulnerabilities | 0 (+16 in 5 direct dependencies) |
| Install scripts | no |
| Author | Andrew A. Grapsas |
| Maintainers | centaur2048 |

## Links

- npm: https://www.npmjs.com/package/expedite
- Repository: https://github.com/centaur2048/expedite
- Homepage: https://github.com/centaur2048/expedite#readme
- Issues: https://github.com/centaur2048/expedite/issues
- npm.io page: https://npm.io/package/expedite

## Dependencies (13)

- [cors](https://npm.io/package/cors.md) 2.7.1
- [when](https://npm.io/package/when.md) 3.7.7
- [lodash](https://npm.io/package/lodash.md) 4.6.1
- [express](https://npm.io/package/express.md) 4.13.4
- [forever](https://npm.io/package/forever.md) 0.15.1
- [git-rev](https://npm.io/package/git-rev.md) git+https://github.com/centaur2048/git-rev.git#master
- [request](https://npm.io/package/request.md) 2.69.0
- [couchbase](https://npm.io/package/couchbase.md) 2.1.4
- [socket.io](https://npm.io/package/socket.io.md) 1.4.5
- [body-parser](https://npm.io/package/body-parser.md) 1.15.0
- [bcrypt-nodejs](https://npm.io/package/bcrypt-nodejs.md) 0.0.3
- [cookie-parser](https://npm.io/package/cookie-parser.md) 1.4.1
- [express-session](https://npm.io/package/express-session.md) 1.13.0

## Recent versions

- 0.0.2 (latest) — 2016-06-05
- 0.0.1 — 2016-06-03

## README

# Expedite Server
A simple, fast wrapper for getting Express HTTP and WebSocket servers up, running, and maintained.

## Why?
Express is nice and concise and that is exactly what a lot of minimalist, simple services need. But, in larger projects, there are a lot of decisions to be made about how to best used express. The goal of `Expedite Server` is to create both a minimalist framework on top of Express AND provide large-project level abstractions for ease of separation and interaction.

## Installation
```bash
$ npm install expedite
```

## Fast example
```javascript
    var Expedite = require( 'expedite' );

    // Create a root endpoint that just returns the default JSON object with data set to "Thank you!"
    Expedite( "root" ).get( "/" ).then( ( req, res ) => res.ok( "Thank you!" ) );

    // Run the server
    Expedite.start();
```

### Configuring a server
```javascript
    var Server = require( 'expedite/server' );

    var config = {};
    config.port = 9001;
    config.name = "Hello World";

    var server = new Server( config );

    server.setDefaultSecurityPolicy( function( req, done )
    {
        if ( req.query.id === "myadminname" )
        {
            // Return true to indicate that the security
            // policy has been met.
            done( true );
            return;
        }

        // False indicate the security policy has NOT been met
        // and will cause an unauthorized access message.
        done( false );
    } );

    // Alternate configurations can be supplied
    var devConfig = {};
    devConfig.environment = "dev";

    // Merged configurations will look through the arguments used to spawn
    // the process and determine if they should be merged into the server's
    // configuration object.

    // If this server was started with the arg 'dev', then the specified config
    // will be merged in, otherwise discarded.
    server.mergeConfigs( { dev : devConfig } );

    // Endpoints should be added individually
    server.addEndpoint( require( './rootendpoint' ) );

    server.start();
```

### Building an endpoint
```javascript
    var Endpoint = require( 'expedite/http/endpoint' );

    // Endpoint instance that all actions will be attached to
    var root = new Endpoint( "root" );

    // Secure endpoint (using default policy)
    // @NOTE: 'then' is not a thenable, just a function convention
    root.get( "/" ).setSecure( true ).then( function( req, res, config )
    {
        var data = {};
        data.message = "hello world";
        data.config = config;

        // ok function is used for an OK response (everything went OK)
        res.ok( data );
    } );

    // Non-secure endpoint posting to the same root URL,
    // note that 'id' is required as part of the query parameter
    // and 'name' is required as part of the posted body.
    root.post( "/" )
        .requireParam( "id" )
        .requireBodyParam( "name" )
        .then( function( req, res )
    {
        // An error alias allows more semantic error code
        res.error.internal( "NOT_IMPLEMENT" );
    } );

    root.put( "/" ).then( function( req, res )
    {
        // Various error types exist with reasonable error code mappings
        res.error.security( "You are not admin" );
    } );

    // Endpoint is exported for requiring in by the entry point module (see: server above)
    module.exports = root;
```

### WebSockets
Coming soon!

### Mock Dummies
Coming soon!

---
_Source: https://npm.io/package/expedite · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
