# easy-express

> Express with sockets (+sessions), session, file server (for yeoman fast debug), rpc: with just 1 line

Latest version **0.5.14** (published 2015-03-23) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install easy-express
pnpm add easy-express
yarn add easy-express
bun add easy-express
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.14 |
| Published | 2015-03-23 |
| First published | 2013-11-29 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 16 |
| Known vulnerabilities | 0 (+5 in 3 direct dependencies) |
| Install scripts | no |
| Author | totty90 |
| Maintainers | totty90 |
| Keywords | express, yeoman, session, sockets, easy, fast, complete, server |

## Links

- npm: https://www.npmjs.com/package/easy-express
- Repository: https://github.com/totty90/easy-express
- Issues: https://github.com/totty90/easy-express/issues
- npm.io page: https://npm.io/package/easy-express

## Dependencies (16)

- [fibers](https://npm.io/package/fibers.md) ^1.0.5
- [tracer](https://npm.io/package/tracer.md) ^0.7.1
- [express](https://npm.io/package/express.md) ^4.10.2
- [socket.io](https://npm.io/package/socket.io.md) ^0.9.17
- [formidable](https://npm.io/package/formidable.md) ^1.0.15
- [underscore](https://npm.io/package/underscore.md) ~1.5.2
- [body-parser](https://npm.io/package/body-parser.md) ^1.9.2
- [compression](https://npm.io/package/compression.md) ^1.2.0
- [node.extend](https://npm.io/package/node.extend.md) 1.0.8
- [connect-mongo](https://npm.io/package/connect-mongo.md) ^0.4.1
- [cookie-parser](https://npm.io/package/cookie-parser.md) ^1.3.3
- [cookie-session](https://npm.io/package/cookie-session.md) ^1.1.0
- [express-session](https://npm.io/package/express-session.md) ^1.9.2
- [futures-requirejs](https://npm.io/package/futures-requirejs.md) ~2.1.3
- [session.socket.io](https://npm.io/package/session.socket.io.md) ~0.1.6
- [connect-mongostore](https://npm.io/package/connect-mongostore.md) ^0.1.4

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.5.14 (latest) — 2015-03-23
- 0.5.13 — 2014-07-24
- 0.5.12 — 2014-07-11
- 0.5.11 — 2014-07-10
- 0.5.9 — 2014-07-08
- 0.5.8 — 2014-07-08
- 0.5.7 — 2014-07-08
- 0.5.6 — 2014-07-08
- 0.5.5 — 2014-07-08
- 0.5.4 — 2014-06-26
- 0.5.3 — 2014-04-08
- 0.5.2 — 2014-03-20
- 0.5.1 — 2014-03-18
- 0.5.0 — 2014-03-17
- 0.4.3 — 2014-03-13
- … 19 more at https://npm.io/package/easy-express/versions

## README

What
==========

Express with sockets (+sessions), session, file server (for yeoman fast debug), rpc: with just 1* line;
**Works out of the box**




Install
=======

npm install easy-express





Setup
=====

 - MongoDB: Run "mongod" in order to use the mongodb database. Is required in order to work (for now).
 - Node





Use
===

Create a file named "index.js" with the following contents. Then run it like this "node index.js".

    var defaultOptions = {

        /**
         * The type of environment. Based on this, if yeoman is enabled,
         * will add certain file paths to the server.
         * [development, production]
         *
         * You can also manually set certain file paths for each environment.
         */
        environment: 'development',

        /**
         * Sometimes you just want to start your node in a certain environment
         * just by appending on of the keywords ['production', 'development'].
         * This will override the environment passed in environment.
         *
         * @todo: should be better and should not only be in the index = 2.
         *
         * Set this value processArgv equal to the process.argv.
         *
         *     {
         *         extractEnvironmentFromCmdLineOptions : true,
         *         processArgv                          : process.argv
         *     }
         */
        extractEnvironmentFromCmdLineOptions: null,

        /**
         * Pass the process argv. Those are only used if
         * extractEnvironmentFromCmdLineOptions is true.
         */
        processArgv: null,


        /**
         * Host name
         */
        host: 'localhost',

        /**
         * Port of the host
         */
        port: 80,

        /**
         * Sockets
         */
        sockets: {
            enabled: true,

            /**
             * Url of the socket used in socket.io
             */
            url: '/socket',

            /**
             * Log level of the sockets.
             */
            logLevel: 1,
        },
        ssl: {
            enabled: false,
            key: null,
            cert: null,
            port: 443,
        },
        /**
         * Sessions
         */
        sessions: {
            enabled: true,

            /**
             * Type of session:
             *  - database: saves to a mongodb database by default
             *  - memory: saves in memory, bad practice and doesn't work with sockets
             */
            type: 'database',

            /**
             * The secret that encodes the sessions. (change this)
             */
            secret: 'random',

            /**
             * For how long lasts the sessions in milliseconds.
             */
            maxAge: 9000000,

            /**
             * Database of the sessions, when database is enabled.
             */
            database: {

                /**
                 * Where the sessions are saved.
                 */
                name: 'sessions',

                /**
                 * Database host.
                 */
                host: 'localhost',

                /**
                 * Database port.
                 */
                port: 27017,
            },
        },

        /**
         * Compress files for faster downloading.
         */
        enableGzip: true,

        /**
         * Used to get the post data in the requests.
         */
        enableBodyParser: true,

        /**
         * Serve files from path. Is recommend to be only used in a development
         * environment. In production use nginx, is faster and better.
         *
         * serveIndexByDefault:
         *     Whenever you want to serve the index.html from the static folder.
         *     Turn off when you want your express route to catch the "/" route
         *     and serve a specific html file or a dynamic one.
         *
         * Format:
         *     {
         *         path: 'my/path',
         *         serveIndexByDefault: false // Default true
         *     }
         */
        fileServer: {
            paths: []
        },

        /**
         * Enabling yeoman will add (not replace) your file server based on the environment.
         * If the environment is development will add 2 paths and in that order:
         *     /.tmp
         *     /app
         * If is production:
         *     /dist
         */
        yeoman: {
            enabled: true,

            /**
             * Root folder of the server, used to create a file server for
             * files in the .tmp, app and dist folder.
             */
            rootFolder: null,

            /**
             * Apply serveIndexByDefault to each yeoman folder.
             * Read fileServer for more info.
             */
            serveIndexByDefault: true,
        },

        /**
         * Using this will force the app to be in a certain way which is:
         *  - You can communicate both via sockets and post seamless;
         *  - The post path is always "/rpc"
         *  - The socket event name is always "rpc"
         *  - Services are called using the API on the client side and has the following
         *    format:
         *        {
         *            serviceName: String
         *            serviceArguments: Whatever you want
         *        }
         *  - The output of the service has the following format:
         *        {
         *            id: Number, only used in sockets to know which socket is for which request,
         *            data: data returned by the service,
         *            err: [errorMessage:String, errorNumber: Integer]
         *        }
         *  - In the case of sockets when they are connected will return the following data:
         *        {
         *            data: {connected: true},
         *            err: undefined
         *        }
         */
        rpc: {
            enabled: true,

            /**
             * This is the rpc app; The service name will always be a method on the rpcApp;
             */
             app: null,
        },
    }


    var innerDefaults = {
        fileServer: {
            path: {
                url                 : '',
                serveIndexByDefault : true,
            }
        }
    }

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