This file contains 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
importScripts('grim/server-fn.js'); | |
function main(request, response) { | |
server(request, response); | |
} | |
server.headers.link['/'] = [ | |
{ href:'/', rel:'self' }, | |
{ href:'/people', rel:'collection' }, | |
{ href:'/people/{title}', rel:'item' } |
This file contains 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
// this works, but the imported scripts pollute the global namespace | |
function require(url) { | |
self.module = { exports:{} }; | |
importScripts(url); | |
var exports = self.module.exports; | |
delete self.module; | |
return exports; | |
}; | |
// this is the one I want: |
This file contains 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
// Responder | |
// ========= | |
// responder sugar functions | |
// ========================= | |
// this structure is used to build the various forms of the respond function | |
// thanks to http://httpstatus.es/ for these descriptions | |
var RESPONDER_FNS = { | |
// information | |
processing : [102, 'server has received and is processing the request'], |
This file contains 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
(function(exports) { | |
var cur_iid = 0; | |
function geniid() { | |
return cur_iid++; | |
} | |
// StaticServer | |
// ============ | |
// provides simple static data hosting | |
// - all content is added through the server object's method interface |
This file contains 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
// ConfigServer | |
// ============ | |
// serves HTML for navigation | |
function ConfigServer() { | |
Environment.Server.call(this); | |
this.schemas = {}; | |
this.values = {}; | |
this.validators = {}; | |
this.broadcasters = {}; |
This file contains 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
ROUTE(request, | |
{ head: 'get', put: 'set', patch: 'set', post:'postTo' }, | |
{ | |
service: '/', | |
products: '/products', | |
product: '/products/:pid', | |
session: '/session', | |
collection: '/:collection', | |
item: '/:collection/:item' | |
}, |
This file contains 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
ROUTE(request, | |
{ head: 'get', put: 'set', patch: 'set', post:'postTo' }, | |
{ | |
'/': service, | |
'/products': products, | |
'/products/:pid': productItems, | |
'/session': session, | |
'/:collection': collection, | |
'/:collection/:item': item | |
} |
This file contains 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 time = require('util/time.js'); | |
var validate = require('validators.js'); | |
var render = require('templates.js'); | |
/) | |
← Host: grimwire.com | |
→ Accept: text/html | |
←" (/ render.layout() /) |
This file contains 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 auth = require('../../lib/auth'); | |
var utils = require('../../lib/utils'); | |
var qs = require('querystring'); | |
var main_server = require('../../globals').server; | |
function createServer(config) { | |
var express = require('express'); | |
var server = express(); |
This file contains 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 addRoutes(server, config) { | |
var path = require('path'); | |
var Imap = require('imap'); | |
var MailParser = require('mailparser'); | |
var Email = require('emailjs'); | |
// (Mail)boxes | |
// =========== | |
function end(req, res, next) { |