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

gengojs-wrappify

v1.0.0

Published

An Express, Hapi, an Koa wrapper for the core of gengojs. This module should be used for test purposes only.

Downloads

12

Readme

gengojs-wrappify

An Express, Hapi, an Koa wrapper for the core of gengojs. This module should be used when you need to test your gengojs plugins that need or use the request object.

The following is an example that shows you to:

  • Make sure the plugin has properly loaded
  • Make sure that the internal API is properly exposed.
  • Make sure that the internal API's API are exposed as well.

Note that there are two version of Wrappify. One is without es6 and the other is. The example below is with ES6. Therefore, make sure to use the --harmony flag when running your tests or use Babel to convert your ES6 code to ES5.

Also note that the wrapper for koa only supports Koa >= v2.0.0.

var assert = require('chai').assert;
var core = require('gengojs-core');
var header = require('your plugin path');
// Wrappify with harmony
// (without harmony would simply be require('gengojs-wrappify'))
var wrappify = require('gengojs-wrappify/es6');

describe('Header', function() {
  describe('load plugins', function() {
    it('should exist', function() {
     // Create an instance of the core.
      var gengo = core({}, header());
      gengo.plugins.headers.forEach(function(plugin) {
        assert.isDefined(plugin);
        assert.strictEqual(plugin.package.type, 'header');
        assert.strictEqual(plugin.package.name, 'gengojs-default-header');
      });
    });
  });
  describe('koa', function() {
    var gengo = core({}, header());
    var Koa = require('koa');
    var app = new Koa();
    // Use Koa wrapper
    app.use(wrappify(gengo).koa());
    var request = require('supertest');
    it('should have the api exposed internally', function() {
      request(app.listen()).get('/').end(function() {
        assert.isDefined(gengo.header);
        assert.isDefined(gengo.header.getLocale);
      });
    });
  });

  describe('express', function() {
    var gengo = core({}, header());
    var express = require('express');
    var app = express();
    var request = require('supertest');
    // Use Express wrapper
    app.use(wrappify(gengo).express());
    it('should have the api exposed internally', function() {
      request(app).get('/').end(function() {
        assert.isDefined(gengo.header);
        assert.isDefined(gengo.header.getLocale);
      })
    });
  });

  describe('hapi', function() {
    var gengo = core({}, header());
    var Hapi = require('hapi');
    var server = new Hapi.Server();
    server.connection({
      port: 3000
    });
    // Register Hapi wrapper
    server.register(wrappify(gengo).hapi(), function(err) {});

    it('should have the api exposed internally', function() {
      server.inject('/', function(res) {
        assert.isDefined(gengo.header);
        assert.isDefined(gengo.header.getLocale);
      })
    });
  });
});