Skip to content

madsquare/simple-message

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-message

version download

simple message handler.

Install

npm install simple-message

API

message.error.get(key)

var message = require('simple-message');

var error = message.error.get('common.missing_required_parameter');
// console.log(error);

{
  type: 'common.missing_required_parameter',
  code: 400,
  message: 'The request is missing a required parameter.'
}

message.load(key, value, [callback])

load by json object

var message = require('simple-message');

message.load('error', {
  "common.missing_required_parameter": [
    400,
    "The request is missing a required parameter."
  ],
  "common.method_not_allowed": [
    400,
    "The API call is correct, but the method is not allowed."
  ],
  "common.unexpected_parameter": [
    400,
    "The request specifies an unexpected parameter."
  ],
  "common.invalid_json_string": [
    400,
    "Problems parsing JSON."
  ]
});

message.load(key, url, [callback])

load by remote json file.

var message = require('simple-message');

message.load('error', 'json format file url', function(err, item) {
  console.log(item['common.missing_required_parameter'][1], message.error.get('common.missing_required_parameter').message);
});

message.loadYAML(key, url, [callback])

load by remote yaml file.

message.loadYAML('error', 'yaml format file url', function(err, item) {
  console.log(item['common.missing_required_parameter'][1], message.error.get('common.missing_required_parameter').message);
});

Sample file

LICENSE

simple-message is licensed under the MIT license.

Packages

No packages published

Languages

  • JavaScript 100.0%