New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

opinion

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opinion

this is my opinion on koa and stuff

latest
Source
npmnpm
Version
1.0.36
Version published
Maintainers
1
Created
Source

Build Status

NPM

koa opinions

Originally forked from koajs/common

Installation

$ npm install opinion

default configuration

a builtin routing mechanism

An extensive default middleware stack

DEFAULT_MIDDLEWARE_STACK = {
    NoKeepAlive: common.NoKeepAlive,
    responseTime: common.responseTime,
    logger: common.logger,
    compress: common.compress,
    conditionalGet: common.conditionalGet,
    etag: common.etag,
    statics: common.statics,
    session: common.session,
    csrf: common.csrf,
    router: common.router
};

The request ctx has been extended with a send method to send files, and a render method to render views using any consolidate compatible render engine, or plain html files.

And as a extra bonus, socket.io is builtin and can be enabled by configuration flag.

Usage

"use strict";
var opinion = require('opinion');


var app = opinion({
    middlewareOrder: opinion.DEFAULT_MIDDLEWARE_STACK, // this can be manipulated
    // here are some configurations, both general, and middleware specific (by name)
    keys: ['78fd9fe83f2af46f2a8b567154db8d2a'],
    statics: 'assets',
    render: ['views', 'dust'],
    socketio: { clientPath: '/js/socket.io.js' }
});


// simple route
app.get('/',
    function* () {
        yield this.render('hello-world');
    }
);


// a CORS enabled proxy to `gist.github.com`
app.get('/snippet/cors/:user/:id', function* () {
    this.set('Access-Control-Allow-Origin', '*');
    this.set('Access-Control-Allow-Methods', 'GET');
    this.set('Access-Control-Allow-Headers', 'Content-Type');
    this.type = 'application/javascript';
    this.body = require('request')('https://gist.github.com/' + this.params.user + '/' + this.params.id + '/raw');
});


app.listen(prosess.env.PORT || 8080, function () {
    console.log("Server listening on %s", this._connectionKey);
});


// websocket push example
setInterval(function () {
    app.webSockets.emit('gaga', JSON.stringify(process.memoryUsage()))
}, 3000);

License

MIT

Keywords

opinion

FAQs

Package last updated on 15 Sep 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts