This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var koa = require('koa'); | |
| var path = require('path'); | |
| var route = require('koa-route'); | |
| var render = require('koa-swig'); | |
| var app = koa(); | |
| render(app, { | |
| root: path.join(__dirname, 'views'), | |
| autoescape: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '.source.js': | |
| 'console.log': | |
| 'prefix': 'l' | |
| 'body': 'console.log(${1:arguments});$2' | |
| 'console.error': | |
| 'prefix': 'e' | |
| 'body': 'console.error($1);$2' | |
| 'require': | |
| 'prefix': 'r' | |
| 'body': 'require(\'$1\')$2' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (!MySchema.options.toObject) { | |
| PlanSchema.options.toObject = {}; | |
| } | |
| MySchema.options.toObject.transform = function(doc, ret) { | |
| // Set the id from the retrun object value which will be a string. | |
| ret.id = ret._id; | |
| delete ret._id; | |
| delete ret.__v; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.get = function(fn) { | |
| var deferred = Q.defer(); | |
| request('http://example.com', function(err, response) { | |
| if (err) { | |
| return deferred.reject(err); | |
| } | |
| if (response.statusCode !== 200) { | |
| return deferred.reject(new Error(response.body || 'Response failed with code ' + response.statusCode)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = function() { | |
| const NONCE_CHARS = [ | |
| 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r', | |
| 's','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J', | |
| 'K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1', | |
| '2','3','4','5','6','7','8','9' | |
| ]; | |
| const NONCE_SIZE = 32; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Pretty form/input labels | |
| */ | |
| body { | |
| font-family: 'helvetica', sans-serif; | |
| font-size: 16px; | |
| } | |
| form { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var express = require('express') | |
| , formidable = require('formidable') | |
| , fs = require('fs') | |
| , path = require('path') | |
| , app = express() | |
| , storedFiles = []; | |
| // | |
| // Serve the cloud storage contents. | |
| // |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.all(/.*/, function(req, res, next) { | |
| var host = req.header('host'); | |
| if (host.match(/^www\..*/i)) return next(); | |
| res.redirect(301, 'http://www.' + host); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SRC = $(wildcard *.js) | |
| test: $(SRC) | |
| @node_modules/.bin/jshint $^ | |
| @node_modules/.bin/istanbul test node_modules/.bin/_mocha \ | |
| -R spec -- \ | |
| --require should \ | |
| --reporter spec | |
| # Uncomment if your tests are in a directory named test. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var logger = require('tracer').colorConsole({ | |
| format: '{{timestamp}} <{{title}}> {{message}} (in {{file}}:{{line}})' | |
| }); |