Comparing version 0.1.0 to 0.1.1
"use strict"; | ||
var inherits = require("util").inherits; | ||
var Unit = require("units").Unit; | ||
var UnitSet = require("units").UnitSet; | ||
@@ -14,3 +12,2 @@ | ||
}; | ||
inherits(AppBase, Unit); | ||
@@ -17,0 +14,0 @@ AppBase.prototype.init = function () { |
"use strict"; | ||
var authen = require('authen'); | ||
var Auth = require('../handlers/auth'); | ||
var CtxAdapter = require('./ctx_adapter'); | ||
var ServiceAuthProvider = require('./providers/service'); | ||
var AppAuthProvider = require('./providers/app'); | ||
var authen = require("authen"); | ||
var Auth = require("../handlers/auth"); | ||
var CtxAdapter = require("./ctx_adapter"); | ||
var ServiceAuthProvider = require("./providers/service"); | ||
var AppAuthProvider = require("./providers/app"); | ||
var AuthUnit = function () { | ||
@@ -27,3 +26,3 @@ this.units = null; | ||
this.units = units; // can be useful for other init | ||
this.settings = units.require('core.settings'); | ||
this.settings = units.require("core.settings"); | ||
this.init(); | ||
@@ -105,3 +104,3 @@ }; | ||
this.providers[provider.type] = provider; | ||
this.providersByKey[provider.options.key || ''] = provider; | ||
this.providersByKey[provider.options.key || ""] = provider; | ||
}; | ||
@@ -149,3 +148,3 @@ | ||
var result; | ||
if (settings == 'main') { | ||
if (settings === "main") { | ||
result = this.adapter; | ||
@@ -152,0 +151,0 @@ } |
"use strict"; | ||
var ops = require('ops'); | ||
var Tokener = require('authen/lib/tokener'); | ||
var ops = require("ops"); | ||
var Tokener = require("authen/lib/tokener"); | ||
@@ -15,3 +15,3 @@ | ||
tokenPrefixSeparator: null, // use default | ||
onBehalfOfHeaderName: 'X-AuthOnBehalfOf' | ||
onBehalfOfHeaderName: "X-AuthOnBehalfOf" | ||
}; | ||
@@ -78,3 +78,3 @@ }; | ||
else { | ||
throw new Error('Not supported for non-HTTP'); | ||
throw new Error("Not supported for non-HTTP"); | ||
} | ||
@@ -81,0 +81,0 @@ }; |
"use strict"; | ||
var inherits = require('util').inherits; | ||
var errors = require('../errors'); | ||
var inherits = require("util").inherits; | ||
var errors = require("../errors"); | ||
var UnexpectedIdentity = function () { | ||
@@ -11,6 +10,6 @@ errors.Conflict.call(this); | ||
UnexpectedIdentity.prototype.name = 'UnexpectedIdentity'; | ||
UnexpectedIdentity.prototype.name = "UnexpectedIdentity"; | ||
UnexpectedIdentity.prototype.getMessage = function () { | ||
return this.status + ' Unexpected Identity'; | ||
return this.status + " Unexpected Identity"; | ||
}; | ||
@@ -17,0 +16,0 @@ |
"use strict"; | ||
var inherits = require('util').inherits; | ||
var AuthProvider = require('authen/lib/auth_provider'); | ||
var inherits = require("util").inherits; | ||
var AuthProvider = require("authen/lib/auth_provider"); | ||
var AppAuthProvider = function (opt_options) { | ||
@@ -7,0 +6,0 @@ AuthProvider.call(this, opt_options); |
"use strict"; | ||
var inherits = require('util').inherits; | ||
var AuthProvider = require('authen/lib/auth_provider'); | ||
var inherits = require("util").inherits; | ||
var AuthProvider = require("authen/lib/auth_provider"); | ||
var ServiceAuthProvider = function (opt_options) { | ||
@@ -11,3 +10,2 @@ AuthProvider.call(this, opt_options); | ||
ServiceAuthProvider.prototype.prepareAuthResult = function (ctx, options, authResult, cb) { | ||
@@ -14,0 +12,0 @@ var result = { |
@@ -6,3 +6,2 @@ "use strict"; | ||
var ClusterMaster = function (opt_options) { | ||
@@ -9,0 +8,0 @@ AppBase.call(this, opt_options); |
@@ -6,3 +6,2 @@ "use strict"; | ||
var Cluster = function () { | ||
@@ -9,0 +8,0 @@ this.settings = null; |
@@ -12,3 +12,2 @@ "use strict"; | ||
// Contract example | ||
@@ -15,0 +14,0 @@ var Contract = function () { |
@@ -6,3 +6,2 @@ "use strict"; | ||
var DaemonMaster = function (opts) { | ||
@@ -9,0 +8,0 @@ AppBase.call(this, opts); |
@@ -8,3 +8,2 @@ "use strict"; | ||
var Daemon = function () { | ||
@@ -11,0 +10,0 @@ this.settings = null; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
var inherits = require('util').inherits; | ||
@@ -9,10 +9,10 @@ var send = require('send'); | ||
var Static = function (rootPaths, opt_options) { | ||
HttpOnly.call(this, opt_options && opt_options.errorHandler); | ||
this.options = ops.cloneWithDefaults(opt_options, this.getDefaultOptions()); | ||
var Static = function(rootPaths, opts) { | ||
HttpOnly.call(this, opts && opts.errorHandler); | ||
this.options = ops.cloneWithDefaults(opts, this.getDefaultOptions()); | ||
if (!Array.isArray(rootPaths)) { | ||
rootPaths = [rootPaths]; | ||
} | ||
this.rootPaths = rootPaths; | ||
if (!Array.isArray(rootPaths)) { | ||
rootPaths = [ rootPaths ]; | ||
} | ||
this.rootPaths = rootPaths; | ||
}; | ||
@@ -23,94 +23,92 @@ inherits(Static, HttpOnly); | ||
Static.prototype.getDefaultOptions = function () { | ||
return { | ||
single: false, | ||
matchKey: 'path', | ||
pathFunc: null, | ||
redirect: false, | ||
maxAge: 0, | ||
allowIndex: false, | ||
index: 'index.html' | ||
}; | ||
Static.prototype.getDefaultOptions = function() { | ||
return { | ||
single: false, | ||
matchKey: 'path', | ||
pathFunc: null, | ||
redirect: false, | ||
maxAge: 0, | ||
allowIndex: false, | ||
index: 'index.html' | ||
}; | ||
}; | ||
Static.prototype.handleHttpRequest = function (ctx) { | ||
var path = this.extractPath(ctx); | ||
this.send(ctx, path); | ||
Static.prototype.handleHttpRequest = function(ctx) { | ||
var path = this.extractPath(ctx); | ||
this.send(ctx, path); | ||
}; | ||
Static.prototype.send = function (ctx, path, idx) { | ||
idx = idx || 0; | ||
var options = this.options; | ||
var self = this; | ||
var sendStream = send(ctx.req, path) | ||
.root(this.rootPaths[idx]) | ||
.hidden(options.hidden) | ||
.maxage(options.maxAge) | ||
.index(options.allowIndex && options.index) | ||
.on('error', function (err) { | ||
if (err.status == 404 && (idx + 1) < self.rootPaths.length) { | ||
self.send(ctx, path, idx + 1); | ||
} | ||
else { | ||
self.onError(ctx, sendStream, err); | ||
} | ||
}) | ||
.on('directory', function () { | ||
self.onDir(ctx, sendStream); | ||
}) | ||
.on('end', function () { | ||
self.onEnd(ctx, sendStream); | ||
}); | ||
sendStream.pipe(ctx.res); | ||
Static.prototype.send = function(ctx, path, idx) { | ||
idx = idx || 0; | ||
var options = this.options; | ||
var self = this; | ||
var sendStream = send(ctx.req, path, { | ||
root: this.rootPaths[idx], | ||
dotfiles: options.hidden ? 'allow' : 'ignore', | ||
maxAge: options.maxAge, | ||
index: options.allowIndex && options.index | ||
}) | ||
.on('error', function(err) { | ||
if (err.status == 404 && (idx + 1) < self.rootPaths.length) { | ||
self.send(ctx, path, idx + 1); | ||
} else { | ||
self.onError(ctx, sendStream, err); | ||
} | ||
}) | ||
.on('directory', function() { | ||
self.onDir(ctx, sendStream); | ||
}) | ||
.on('end', function() { | ||
self.onEnd(ctx, sendStream); | ||
}); | ||
sendStream.pipe(ctx.res); | ||
}; | ||
Static.prototype.extractPath = function (ctx) { | ||
var result = ''; | ||
if (!this.options.single) { | ||
if (this.options.pathFunc != null) { | ||
result = this.options.pathFunc(this, ctx); | ||
} | ||
else if (ctx.pathMatchResult != null && this.options.matchKey != null) { | ||
result = ctx.pathMatchResult[this.options.matchKey] || ''; | ||
} | ||
} | ||
return result; | ||
Static.prototype.extractPath = function(ctx) { | ||
var result = ''; | ||
if (!this.options.single) { | ||
if (this.options.pathFunc != null) { | ||
result = this.options.pathFunc(this, ctx); | ||
} else if (ctx.pathMatchResult != null && this.options.matchKey != null) { | ||
result = ctx.pathMatchResult[this.options.matchKey] || ''; | ||
} | ||
} | ||
return result; | ||
}; | ||
Static.prototype.onError = function (ctx, sendStream, err) { | ||
var status = err.status; | ||
if (status != null && status >= 400 && status < 500) { | ||
if ([400, 403, 404].indexOf(status) != -1) { | ||
// actually all of these are just bad paths | ||
err = new errors.NotFound(); | ||
} | ||
else if (status == 416) { | ||
err = new errors.RequestedRangeNotSatisfiable(); | ||
} | ||
// don't expect 'send' to provide any other HTTP errors | ||
} | ||
this.error(ctx, err); | ||
Static.prototype.onError = function(ctx, sendStream, err) { | ||
var status = err.status; | ||
if (status != null && status >= 400 && status < 500) { | ||
if ([ 400, 403, 404 ].indexOf(status) != -1) { | ||
// actually all of these are just bad paths | ||
err = new errors.NotFound(); | ||
} else if (status == 416) { | ||
err = new errors.RequestedRangeNotSatisfiable(); | ||
} | ||
// don't expect 'send' to provide any other HTTP errors | ||
} | ||
this.error(ctx, err); | ||
}; | ||
Static.prototype.onDir = function (ctx, sendStream) { | ||
var res = ctx.res; | ||
var path = ctx.res.path; | ||
if (this.options.redirect && !(path && path[path.length - 1] == '/')) { | ||
res.redirect(ctx.req.path + '/', 301); | ||
ctx.responseSent(); | ||
ctx.next(); | ||
} | ||
else { | ||
this.error(ctx, new errors.NotFound()); | ||
} | ||
Static.prototype.onDir = function(ctx, sendStream) { | ||
var res = ctx.res; | ||
var path = ctx.res.path; | ||
if (this.options.redirect && !(path && path[path.length - 1] == '/')) { | ||
res.redirect(ctx.req.path + '/', 301); | ||
ctx.responseSent(); | ||
ctx.next(); | ||
} else { | ||
this.error(ctx, new errors.NotFound()); | ||
} | ||
}; | ||
Static.prototype.onEnd = function (ctx, sendStream) { | ||
ctx.res.end(); | ||
ctx.responseSent(); | ||
ctx.next(); | ||
Static.prototype.onEnd = function(ctx, sendStream) { | ||
ctx.res.end(); | ||
ctx.responseSent(); | ||
ctx.next(); | ||
}; | ||
Static.st = function (rootPaths, opt_options) { | ||
return new Static(rootPaths, opt_options); | ||
Static.st = function(rootPaths, opt_options) { | ||
return new Static(rootPaths, opt_options); | ||
}; | ||
@@ -117,0 +115,0 @@ |
"use strict"; | ||
var client = require('./client'); | ||
var nodeClient = require('./node_client'); | ||
var testPage = require('./test_page'); | ||
var Loader = require('./loader'); | ||
var AppBase = require('./app_base'); | ||
var App = require('./app'); | ||
var Daemon = require('./daemon'); | ||
var Cluster = require('./cluster'); | ||
var Settings = require('./settings'); | ||
var Ctx = require('./ctx'); | ||
var errors = require('./errors'); | ||
var logging = require('./logging'); | ||
var auth = require('./auth'); | ||
var handlers = require('./handlers'); | ||
var UncaughtExceptionsHandler = require('./uncaught'); | ||
var resources = require('./resources'); | ||
var mechanics = require('./mechanics'); | ||
var tools = require('./tools'); | ||
var client = require("./client"); | ||
var nodeClient = require("./node_client"); | ||
var testPage = require("./test_page"); | ||
var Loader = require("./loader"); | ||
var AppBase = require("./app_base"); | ||
var App = require("./app"); | ||
var Daemon = require("./daemon"); | ||
var Cluster = require("./cluster"); | ||
var Settings = require("./settings"); | ||
var Ctx = require("./ctx"); | ||
var errors = require("./errors"); | ||
var logging = require("./logging"); | ||
var auth = require("./auth"); | ||
var handlers = require("./handlers"); | ||
var UncaughtExceptionsHandler = require("./uncaught"); | ||
var resources = require("./resources"); | ||
var mechanics = require("./mechanics"); | ||
var tools = require("./tools"); | ||
@@ -21,0 +21,0 @@ |
"use strict"; | ||
var http = require('http'); | ||
var https = require('https'); | ||
var express = require('express'); | ||
var cookie = require('cookie'); | ||
var Ctx = require('../../ctx'); | ||
var resultHandler = require('../../handlers/result').result; | ||
var errors = require('../../errors'); | ||
var crossDomainWorkaround = require('./cross_domain_workaround'); | ||
var Cors = require('./cors'); | ||
var http = require("http"); | ||
var https = require("https"); | ||
var express = require("express"); | ||
var cookie = require("cookie"); | ||
var Ctx = require("../../ctx"); | ||
var resultHandler = require("../../handlers/result").result; | ||
var errors = require("../../errors"); | ||
var crossDomainWorkaround = require("./cross_domain_workaround"); | ||
var Cors = require("./cors"); | ||
@@ -43,3 +43,3 @@ var RequestEntityTooLarge = errors.RequestEntityTooLarge; | ||
this.settings = units.require('core.settings'); | ||
this.settings = units.require("core.settings"); | ||
this.prefix = this.settings.core.prefix; | ||
@@ -56,4 +56,4 @@ var webSettings = this.settings.core.web; | ||
this.logger = units.require('core.logging').getLogger('web'); | ||
this.handler = units.require('core.handler'); | ||
this.logger = units.require("core.logging").getLogger("web"); | ||
this.handler = units.require("core.handler"); | ||
@@ -87,4 +87,4 @@ this.createServers(); | ||
if (this._mediaType === undefined) { | ||
var contentType = this.headers['content-type']; | ||
this._mediaType = contentType ? contentType.split(';')[0] : null; | ||
var contentType = this.headers["content-type"]; | ||
this._mediaType = contentType ? contentType.split(";")[0] : null; | ||
} | ||
@@ -104,4 +104,3 @@ return this._mediaType; | ||
server = express.createServer(settings.https); | ||
} | ||
else { | ||
} else { | ||
server = express.createServer(); | ||
@@ -116,3 +115,3 @@ } | ||
if (!this.settings.core.debug) { | ||
server.set('env', 'production'); | ||
server.set("env", "production"); | ||
} | ||
@@ -149,3 +148,3 @@ var self = this; | ||
Mechanics.prototype.middlewareHandleWithinDomain = function (req, res, next) { | ||
var domain = require('domain'); | ||
var domain = require("domain"); | ||
@@ -157,5 +156,5 @@ var self = this; | ||
domainInstance.add(req); | ||
domainInstance.add(res); | ||
domainInstance.add(res); | ||
domainInstance.on('error', function (err) { | ||
domainInstance.on("error", function (err) { | ||
self.handleUncaughtError(ctxContainer.ctx, req, res, err); | ||
@@ -181,3 +180,3 @@ }); | ||
if (this.handler == null) { | ||
throw new Error('No handler set for web mechanics'); | ||
throw new Error("No handler set for web mechanics"); | ||
} | ||
@@ -232,3 +231,3 @@ | ||
Mechanics.prototype.handleUncaughtErrorWithinDomain = function (ctx, req, res, err) { | ||
var domain = require('domain'); | ||
var domain = require("domain"); | ||
var self = this; | ||
@@ -238,3 +237,3 @@ var errDomain = domain.create(); | ||
errDomain.add(res); | ||
errDomain.on('error', function (nestedErr) { | ||
errDomain.on("error", function (nestedErr) { | ||
self.handleNestedUncaughtError(ctx, req, res, err, nestedErr); | ||
@@ -270,4 +269,3 @@ }); | ||
} | ||
catch (logErr) { | ||
} | ||
catch (logErr) {} | ||
} | ||
@@ -287,7 +285,7 @@ try { | ||
Mechanics.prototype.logUncaughtError = function (ctx, req, err) { | ||
this.logger.logError(err, 'critical', { prefix: 'UncaughtError : ' }); | ||
this.logger.logError(err, "critical", { prefix: "UncaughtError : " }); | ||
}; | ||
Mechanics.prototype.logNestedUncaughtError = function (ctx, req, err) { | ||
this.logger.logError(err, 'critical', { prefix: 'NestedUncaughtError : ' }); | ||
this.logger.logError(err, "critical", { prefix: "NestedUncaughtError : " }); | ||
}; | ||
@@ -315,3 +313,3 @@ | ||
var req = ctx.req; | ||
if (!this.crossDomainWorkaroundSettings.disabled && req.method == 'GET') { | ||
if (!this.crossDomainWorkaroundSettings.disabled && req.method == "GET") { | ||
var crossDomain = ctx.req.query[this.crossDomainWorkaroundSettings.key]; | ||
@@ -321,3 +319,3 @@ var jsonpSettings = this.crossDomainWorkaroundSettings.jsonp; | ||
// special case for jsonp | ||
crossDomain = 'jsonp'; | ||
crossDomain = "jsonp"; | ||
} | ||
@@ -327,3 +325,3 @@ if (crossDomain) { | ||
if (settings && !settings.disabled) { | ||
if (crossDomain == 'jsonp') { | ||
if (crossDomain == "jsonp") { | ||
var callback = req.query[settings.callbackKey]; | ||
@@ -342,6 +340,6 @@ if (callback) { | ||
if (!req.readable) { | ||
cb(new Error('Body is not readable')); | ||
cb(new Error("Body is not readable")); | ||
} | ||
else { | ||
var len = req.headers['content-length'] ? parseInt(req.headers['content-length'], 10) : null; | ||
var len = req.headers["content-length"] ? parseInt(req.headers["content-length"], 10) : null; | ||
if (limit != null && len > limit) { | ||
@@ -360,4 +358,4 @@ cb(new RequestEntityTooLarge(limit)); | ||
chunks = null; | ||
req.removeListener('data', collectFunc); | ||
req.removeListener('end', collectedFunc); | ||
req.removeListener("data", collectFunc); | ||
req.removeListener("end", collectedFunc); | ||
cb(new RequestEntityTooLarge(limit)); | ||
@@ -375,4 +373,4 @@ } | ||
}; | ||
req.on('data', collectFunc); | ||
req.on('end', collectedFunc); | ||
req.on("data", collectFunc); | ||
req.on("end", collectedFunc); | ||
} | ||
@@ -398,4 +396,4 @@ } | ||
res.charset = res.charset || 'utf-8'; | ||
res.setHeader('Content-Type', 'application/json'); | ||
res.charset = res.charset || "utf-8"; | ||
res.setHeader("Content-Type", "application/json"); | ||
@@ -402,0 +400,0 @@ res.send(body); |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
var hyperquest = require('hyperquest'); | ||
@@ -8,54 +8,54 @@ var HttpAdapter = require('./http_adapter'); | ||
var Http = function (opt_baseUri, opt_options) { | ||
this.baseUri = opt_baseUri; | ||
this.options = opt_options || {}; | ||
this.adapter = null; | ||
this.authenticator = null; | ||
var Http = function(opt_baseUri, opt_options) { | ||
this.baseUri = opt_baseUri; | ||
this.options = opt_options || {}; | ||
this.adapter = null; | ||
this.authenticator = null; | ||
}; | ||
Http.prototype.setAdapter = function (adapter) { | ||
this.adapter = adapter; | ||
Http.prototype.setAdapter = function(adapter) { | ||
this.adapter = adapter; | ||
}; | ||
Http.prototype.setAuthenticator = function (authenticator) { | ||
this.authenticator = authenticator; | ||
Http.prototype.setAuthenticator = function(authenticator) { | ||
this.authenticator = authenticator; | ||
}; | ||
Http.prototype.sendAuthenticated = function (path, method, headers, data, options, cb) { | ||
this.ensureAuthenticator(); | ||
this.authenticator.sendAuthenticated(path, method, headers, data, options, cb); | ||
Http.prototype.sendAuthenticated = function(path, method, headers, data, options, cb) { | ||
this.ensureAuthenticator(); | ||
this.authenticator.sendAuthenticated(path, method, headers, data, options, cb); | ||
}; | ||
Http.prototype.send = function (path, method, headers, data, options, cb) { | ||
this.ensureAdapter(); | ||
var req = this.adapter.createRequestData(this.baseUri, path, method, headers, data, options); | ||
var r = hyperquest(req.url, { | ||
method: req.method, | ||
headers: req.headers | ||
}); | ||
if (req.body != null) { | ||
r.end(req.body); | ||
} | ||
Http.prototype.send = function(path, method, headers, data, options, cb) { | ||
this.ensureAdapter(); | ||
var req = this.adapter.createRequestData(this.baseUri, path, method, headers, data, options); | ||
var r = hyperquest(req.url, { | ||
method: req.method, | ||
headers: req.headers | ||
}); | ||
if (req.body != null) { | ||
r.end(req.body); | ||
} | ||
var res; | ||
var body = ''; | ||
var self = this; | ||
r.on('data', function (buf) { | ||
body += buf; | ||
}); | ||
r.on('response', function (r) { | ||
res = r; | ||
}); | ||
r.on('error', function (err) { | ||
self.handleHttpResult(err, null, options, cb); | ||
}); | ||
r.on('end', function () { | ||
self.handleHttpResult(null, { | ||
status: res.statusCode, | ||
headers: res.headers, | ||
body: body | ||
}, options, cb); | ||
}); | ||
var res; | ||
var body = ''; | ||
var self = this; | ||
r.on('data', function(buf) { | ||
body += buf; | ||
}); | ||
r.on('response', function(r) { | ||
res = r; | ||
}); | ||
r.on('error', function(err) { | ||
self.handleHttpResult(err, null, options, cb); | ||
}); | ||
r.on('end', function() { | ||
self.handleHttpResult(null, { | ||
status: res.statusCode, | ||
headers: res.headers, | ||
body: body | ||
}, options, cb); | ||
}); | ||
return r; | ||
return r; | ||
}; | ||
@@ -65,34 +65,33 @@ | ||
Http.prototype.ensureAdapter = function () { | ||
if (this.adapter == null) { | ||
this.adapter = this.createAdapter(this.options.adapter); | ||
} | ||
Http.prototype.ensureAdapter = function() { | ||
if (this.adapter == null) { | ||
this.adapter = this.createAdapter(this.options.adapter); | ||
} | ||
}; | ||
Http.prototype.createAdapter = function (opt_options) { | ||
return new HttpAdapter(opt_options); | ||
Http.prototype.createAdapter = function(opt_options) { | ||
return new HttpAdapter(opt_options); | ||
}; | ||
Http.prototype.ensureAuthenticator = function () { | ||
if (this.authenticator == null) { | ||
this.authenticator = this.createAuthenticator(this.options.auth); | ||
} | ||
Http.prototype.ensureAuthenticator = function() { | ||
if (this.authenticator == null) { | ||
this.authenticator = this.createAuthenticator(this.options.auth); | ||
} | ||
}; | ||
Http.prototype.createAuthenticator = function (options) { | ||
return new HttpAuthenticator(this, options); | ||
Http.prototype.createAuthenticator = function(options) { | ||
return new HttpAuthenticator(this, options); | ||
}; | ||
Http.prototype.handleHttpResult = function (err, httpResult, options, cb) { | ||
var result; | ||
if (err == null) { | ||
result = this.adapter.parseResponseData(httpResult.status, httpResult.headers, httpResult.body, options); | ||
err = WebError.extract(result); | ||
} | ||
if (err != null) { | ||
cb(err); | ||
} | ||
else { | ||
cb(err, result); | ||
} | ||
Http.prototype.handleHttpResult = function(err, httpResult, options, cb) { | ||
var result; | ||
if (err == null) { | ||
result = this.adapter.parseResponseData(httpResult.status, httpResult.headers, httpResult.body, options); | ||
err = WebError.extract(result); | ||
} | ||
if (err != null) { | ||
cb(err); | ||
} else { | ||
cb(err, result); | ||
} | ||
}; | ||
@@ -99,0 +98,0 @@ |
@@ -16,5 +16,5 @@ "use strict"; | ||
if (httpMethod != 'POST' || method == this.logicDefaultForPost) { | ||
if (httpMethod !== "POST" || method === this.logicDefaultForPost) { | ||
if (httpMethod in this.map) { | ||
throw new Error('Ambigous mapping'); | ||
throw new Error("Ambigous mapping"); | ||
} | ||
@@ -44,12 +44,12 @@ this.map[httpMethod] = method; | ||
MethodMapper.prototype.logicToHttpMap = { | ||
call: 'POST', | ||
create: 'POST', | ||
get: 'GET', | ||
head: 'HEAD', | ||
update: 'PUT', | ||
del: 'DELETE', | ||
options: 'OPTIONS' | ||
call: "POST", | ||
create: "POST", | ||
get: "GET", | ||
head: "HEAD", | ||
update: "PUT", | ||
del: "DELETE", | ||
options: "OPTIONS" | ||
}; | ||
MethodMapper.prototype.logicDefaultForPost = 'create'; | ||
MethodMapper.prototype.logicDefaultForPost = "create"; | ||
@@ -60,3 +60,3 @@ MethodMapper.prototype.resolveMethod = function (ctx) { | ||
if (ctx.isHttp) { | ||
if (method == 'POST') { | ||
if (method === "POST") { | ||
var key = ctx.appSettings.core.web.headers.nameMethod.toLowerCase(); | ||
@@ -63,0 +63,0 @@ var subMethod = ctx.req.headers[key]; |
@@ -6,5 +6,4 @@ "use strict"; | ||
module.exports = { | ||
isSuccess: isSuccess | ||
}; |
"use strict"; | ||
var http = require('./http'); | ||
var path = require('./path'); | ||
var TimedChecker = require('./timed_checker'); | ||
var http = require("./http"); | ||
var path = require("./path"); | ||
var TimedChecker = require("./timed_checker"); | ||
module.exports = { | ||
@@ -8,0 +7,0 @@ http: http, |
"use strict"; | ||
var inherits = require('util').inherits; | ||
var Unit = require('units').Unit; | ||
var UncaughtExceptionHandler = function () { | ||
this.logger = null; | ||
}; | ||
inherits(UncaughtExceptionHandler, Unit); | ||
@@ -11,0 +7,0 @@ UncaughtExceptionHandler.prototype.unitInit = function (units) { |
{ | ||
"name": "apis", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Library for creation web and websocket restful APIs", | ||
@@ -16,7 +16,7 @@ "keywords": [ | ||
"dependencies": { | ||
"ain2": "~1.1.1", | ||
"ain2": "~1.5.2", | ||
"authen": "~0.0.2", | ||
"cookie": "~0.0.4", | ||
"cookie": "~0.2.0", | ||
"express": "~2.5.11", | ||
"hyperquest": "~0.1.5", | ||
"hyperquest": "~1.2.0", | ||
"inherits": "~2.0.1", | ||
@@ -26,7 +26,7 @@ "marked_types": "~0.0.1", | ||
"ops": "~0.0.1", | ||
"send": "~0.0.4", | ||
"send": "~0.13.0", | ||
"trun": "~0.0.1", | ||
"units": "~0.0.1", | ||
"valid": "~0.1.0", | ||
"ws": "^0.7.2" | ||
"ws": "^0.8.0" | ||
}, | ||
@@ -33,0 +33,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
474950
116
5
12165
+ Addedain2@1.5.3(transitive)
+ Addedbindings@1.1.1(transitive)
+ Addedbufferutil@1.2.1(transitive)
+ Addedcookie@0.2.4(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddebug@2.2.0(transitive)
+ Addeddepd@1.1.2(transitive)
+ Addeddestroy@1.0.4(transitive)
+ Addedduplexer2@0.0.2(transitive)
+ Addedee-first@1.1.1(transitive)
+ Addedescape-html@1.0.3(transitive)
+ Addedetag@1.7.0(transitive)
+ Addedfresh@0.3.0(transitive)
+ Addedhttp-errors@1.3.1(transitive)
+ Addedhyperquest@1.2.0(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedmime@1.3.4(transitive)
+ Addedms@0.7.1(transitive)
+ Addednan@2.0.92.4.0(transitive)
+ Addedon-finished@2.3.0(transitive)
+ Addedrange-parser@1.0.3(transitive)
+ Addedreadable-stream@1.0.341.1.14(transitive)
+ Addedsend@0.13.2(transitive)
+ Addedstatuses@1.2.1(transitive)
+ Addedstring_decoder@0.10.31(transitive)
+ Addedthrough2@0.6.5(transitive)
+ Addedunix-dgram@0.2.2(transitive)
+ Addedutf-8-validate@1.2.2(transitive)
+ Addedws@0.8.1(transitive)
+ Addedxtend@4.0.2(transitive)
- Removedain2@1.1.1(transitive)
- Removedbufferutil@1.1.0(transitive)
- Removeddebug@4.4.0(transitive)
- Removedduplexer@0.1.2(transitive)
- Removedfresh@0.1.0(transitive)
- Removedhyperquest@0.1.8(transitive)
- Removedmime@1.2.6(transitive)
- Removedms@2.1.3(transitive)
- Removednan@1.8.4(transitive)
- Removedrange-parser@0.0.4(transitive)
- Removedsend@0.0.4(transitive)
- Removedthrough@2.2.7(transitive)
- Removedutf-8-validate@1.1.0(transitive)
- Removedws@0.7.2(transitive)
Updatedain2@~1.5.2
Updatedcookie@~0.2.0
Updatedhyperquest@~1.2.0
Updatedsend@~0.13.0
Updatedws@^0.8.0