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

gopher

v0.2.1

Published

Gopher Express is a more opinionated flavor of express (expressjs.com)

Downloads

9

Readme

Gopher Express

Express is the de-facto standard for a light weight web framework in node.js, but sometimes it might be nice to include just a bit more in terms of default configuration and behavior. That's what Gopher Express is for.

Words Of Caution

This module is largely an experiment in API design for a node.js web framework, and will frequently introduce API changes. Use at your own risk. However, since Gopher is just a customized version of Express with some extra features, it is easy to do anything the plain old Express way, or migrate to just using Express.

Installation

npm install --save gopher

Usage

var app = require('gopher');

app.get('/', function(request, response) {
    response.send('hello world!');
});

Visit http://localhost:3000/.

What happened?

  • Creates a pre-configured Express 4 app as the base module object
  • Creates and starts an HTTP server with the given express app on process.nextTick

Configuration

Your Gopher Express app uses the express app configuration API to store configuration properties for the app. Here is the default configuration, all of which can be overridden if desired:

Standard Express Configuration

  • app.set('view engine', 'jade'); : Use Jade as the templating engine
  • app.set('views', path.join(process.cwd(), 'views')); : Views directory is views in the webapp directory
  • app.set('port', process.env.PORT || 3000); : Use an environment variable for the HTTP port, or start up on port 3000

Default Middleware

Express 4 removed much of the built-in middleware included in Express 3. These have been replaced by their standalone projects. Check them out here.

  • app.use(require('morgan')('dev'));
  • app.use(require('body-parser').urlencoded({extended:false}));
  • app.use(require('method-override')());
  • app.use(express.static(path.join(process.cwd(), 'public'))); : static content goes in public
  • Development: app.use(require('errorhandler')());

Gopher-specific configuration

  • app.set('gopher.autostart', true) : automatically start the created HTTP server
  • app.set('gopher.middleware', true); : automatically mount default middleware
  • app.set('gopher.browserify', true); : enable browserify middleware (see below)
  • app.set('gopher.browserify.options', { debug: process.env.NODE_ENV !== 'production' }); : options passed to the browserify bundle command. Setting debug to false will also have the effect of uglifying your browserify bundle
  • app.set('gopher.less', true); : Enable Less CSS middleware (see below)

Browserify (experimental feature, API not fully baked)

Gopher will automatically use browserify to bundle and then serve any JS files in your project's browser directory. Gopher sets up a route for /browser/:filename.js, and will browserify any files found there by that name.

Less CSS (experimental feature, API not fully baked)

Gopher will automatically mount less-middleware. TL;DR - this middleware will intercept GET requests for *.css. It will look for .less files in your public directory by the same name. If it finds one, it will Less compile that file and place it in your public directory. The resulting CSS will then be served up by Express' static middleware.

Note that this compilation step will only happen once per node process launch, so during development, any changes to your Less files will not be picked up until the next app launch. However, you're probably already using nodemon or something similar to watch your app files for changes and restart your node process, right? If not, start! This will save you lots of time. Once you start using nodemon, you can monitor both your .js and .less files for changes, and restart your node process when either file type is modified. Start your app like this from now on:

nodemon -e js,less your_app.js

API and Module Properties

require('gopher')

Load the Gopher module, create a pre-configured express web application.

Returns: An express web app

app.httpServer

An http server created for the application.

app.startServer()

Start app.httpServer and listen on app.get('port') if it hasn't already been started.

License

MIT