Skip to content

Instantly share code, notes, and snippets.

@VanTudor
Created January 18, 2016 15:39
Show Gist options
  • Save VanTudor/777662c4fb919cb4ad87 to your computer and use it in GitHub Desktop.
Save VanTudor/777662c4fb919cb4ad87 to your computer and use it in GitHub Desktop.
Express.js example API user service configuration file
module.exports = function() {
var config = {};
config.registration = {
mandatoryFields : [
{
name: "userID",
type: "text",
shouldBeUnique: true,
maxLength: 32
},
{
name: "password",
type: "password",
shouldBeUnique: false,
maxLength: 32
},
{
name: "email",
type: "text",
shouldBeUnique: true,
maxLength: 32
},
{
name: "firstName",
type: "text",
shouldBeUnique: false,
maxLength: 32
},
{
name: "lastName",
type: "text",
shouldBeUnique: false,
maxLength: 32
}
],
optionalFields : [
{
name: "telephone",
type: "text",
shouldBeUnique: false,
maxLength: 32
},
{
name: "photo",
type: "text",
shouldBeUnique: true,
maxLength: 32
}
]
};
config.backendServices = {
registerAddress : "http://example.com",
loginAddress : "http://example.com",
};
config.client = {};
config.backend = {};
config.client.makeResponse = function(responseStatusOk, responseContent) {
var response = {};
response.ok = responseStatusOk;
response.response_data = [];
response.response_data.push(responseContent);
return JSON.stringify(response);
};
config.backend.makeRequest = function() {
};
config.client.makeError = function(reason) {
return config.client.makeResponse(false, {"reason": reason});
};
return config;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment