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

easy-express

v0.5.14

Published

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

Downloads

41

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,
        }
    }
}