accountdown-parser
Advanced tools
Comparing version 0.1.2 to 0.1.3
28
index.js
var extend = require('extend') | ||
var formBody = require('body/any') | ||
module.exports = accountdown-parser | ||
module.exports = Parser | ||
function accountdown-parser (accountdown, opts) { | ||
if (!(this instanceof accountdown-parser)) { | ||
return new accountdown-parser(accountdown, opts) | ||
function Parser (accountdown, opts) { | ||
if (!(this instanceof Parser)) { | ||
return new Parser(accountdown, opts) | ||
} | ||
if (!opts) opts = {}; | ||
if (!opts) opts = {} | ||
this.accountdown = accountdown | ||
@@ -20,12 +20,12 @@ // When updating an account, this function tells us whether the | ||
// Formats the account request data that could not be done on the client | ||
this.format = opts.format; | ||
this.format = opts.format | ||
this.parse = function(string, cb) { | ||
var parsedBody = require('qs').parse(string) | ||
return cb(null, parsedBody); | ||
return cb(null, parsedBody) | ||
} | ||
} | ||
accountdown-parser.prototype.create = function (req, res, cb) { | ||
var self = this; | ||
Parser.prototype.create = function (req, res, cb) { | ||
var self = this | ||
@@ -35,6 +35,6 @@ formBody(req, res, { querystring: { parse: this.parse }}, function(err, body) { | ||
// { login: {...}, value: {key: .., ...} } | ||
if (err) return console.log("accountdown-parser: body did not parse:", err) | ||
if (err) return console.log("Parser: body did not parse:", err) | ||
if (self.format) body = self.format(body) | ||
if (!self.validate(body)) | ||
return console.log("\naccountdown-parser.create: invalid body: ", self.validate.errors) | ||
return console.log("\nParser.create: invalid body: ", self.validate.errors) | ||
@@ -48,4 +48,4 @@ self.accountdown.create(body.value.key, body, function (err) { | ||
accountdown-parser.prototype.update = function (req, res, key, cb) { | ||
var self = this; | ||
Parser.prototype.update = function (req, res, key, cb) { | ||
var self = this | ||
self.accountdown.get(key, function (err, existingAccountValue) { | ||
@@ -59,3 +59,3 @@ if (err) return console.log(err) | ||
if (!self.validate(body)) | ||
return console.log("\naccountdown-parser.update: invalid body: ", self.validate.errors) | ||
return console.log("\nParser.update: invalid body: ", self.validate.errors) | ||
@@ -62,0 +62,0 @@ // Overwrite all new values in existing account, and retain any values not |
{ | ||
"name": "accountdown-parser", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Facilitates account creation and user input validation using accountdown and json-schema", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
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
7139