var errorFactory = require('error-factory'); /** * Communication Errors * */ /** * No token found. Call auth() first! * * @constructor */ var NoTokenError = errorFactory( 'noToken', { 'message': 'No token has been found. Have you called auth() first?' } ); /** * Internal zimbra error * * @constructor */ var ZimbraError = errorFactory( 'zimbraError', { 'message': 'Got Zimbra error: ({{code}}) {{reason}} | {{detail}}', 'messageData': {} }
const PLUGINS_GLOB = '**/*.js'; const PLUGIN_EXT_PATTERN = /\.js$/; var path = require('path'); var fs = require('co-fs'); var glob = require('co-glob'); var errorFactory = require('error-factory'); var moduleResUtil = require('../util/resources'); var PluginsLoaderException = errorFactory('beyo.PluginsLoaderException', [ 'message', 'eventData' ]); /** Load plugins for the given path Options - path the plugins' root path relative to beyo.rootPath - plugins an object mapping plugin names @event pluginLoad called before loading a plugin @event pluginLoadError error while loading a plugin @event pluginLoadComplete called after loading a plugin @param {Beyo} beyo the beyo module object @param {Object} options the loader options */ module.exports = function * pluginsLoader(beyo, options) { var plugins = {}; var files; var file;
/** Exceptions */ var errorFactory = require('error-factory'); /** Expose EventException */ module.exports.EventException = errorFactory('beyo.events.EventException', [ 'message', 'messageData' ]);
import createError from 'error-factory'; export {ValidationError} from 'vlad'; export let NotAuthorizedError = createError('NotAuthorizedError', { message: "Not authorized" }); export let NotFoundError = createError('NotFoundError', { message: "Not found" }); export function auth(req, res, next) { if (req.user) return next(); next(NotAuthorizedError()); }
var errorFactory = require('error-factory'); /** * Request Errors * */ /** * No requests found. Add a request first. * @constructor */ var NoRequestsError = errorFactory( 'noRequests', { 'message': 'There were no requests. Use addRequest first.' } ); module.exports = { NoRequests: NoRequestsError };
var winston = require('winston'); var errorFactory = require('error-factory'); var LoggerLoaderException = errorFactory('beyo.LoggerLoaderException', [ 'message', 'messageData' ]); module.exports = function * loggerLoader(beyo, options) { var logger; var eventData; if (options === undefined) { throw LoggerLoaderException('No options specified'); } else if (options === null || options.__proto__.constructor !== Object) { throw LoggerLoaderException('Invalid options value: {{options}}', { options: String(options) }); } eventData = { options: options }; beyo.emit('loggerLoad', eventData); try { logger = new winston.Logger(_getLoggerConfig(options)); eventData.logger = logger; beyo.emit('loggerLoadComplete', eventData); } catch (e) { beyo.emit('loggerLoadError', e, eventData);
var merge = require('merge'); var parallel = require('co-parallel'); var Module = require('module'); var appLoader = require('./loaders/app'); var configLoader = require('./loaders/config'); var pluginsLoader = require('./loaders/plugins'); var loggerLoader = require('./loaders/logger'); var modulesLoader = require('./loaders/modules'); var objectUtil = require('./util/object'); var resourcesUtil = require('./util/resources'); var errorFactory = require('error-factory'); var ArgumentException = errorFactory('beyo.ArgumentException'); var IllegalStateException = errorFactory('beyo.IllegalStateException'); var InitializationException = errorFactory('beyo.InitializationException', ['message', 'messageData']); /** Export Beyo */ module.exports = Beyo; /** Beyo is a function constructor defining the application's global context */ function Beyo(options) { _init.call(this, options);
var path = require('path'); var readline = require('readline'); var co = require('co'); var fs = require('co-fs'); var chalk = require('chalk'); var suspend = require('co-suspend'); var errorFactory = require('error-factory'); var Beyo = require(path.join(__dirname, '..', '..')); var ArgumentException = errorFactory('beyo.ArgumentException'); /** Wrap the given action with argument and options check. The action should be a yieldable (generator, thunk, promise, etc.) Arguments are values that are not defined in the command options. For example a command defining no option would receive all values as arguments. Note : everything after '--' will be given as arguments, not options. The argument argCheck should be */ module.exports = function prepareCommandApp(argCheck, optionCheck, callback) { return function initCommandApp() { var args = Array.prototype.slice.call(arguments); var options = detectOptions(args.pop(), ['verbose', 'showStackTrace', 'quiet']); var beyo;
var errorFactory = require('error-factory'); // // 403 // var NotAllowedError = module.exports.NotAllowedError = errorFactory('NotAllowedError', ['message', 'path']); module.exports.notAllowed = function notAllowed(req) { return new NotAllowedError("Not allowed", req.originalUrl); } // // 404 // var NotFoundError = module.exports.NotFoundError = errorFactory('NotFoundError', ['message', 'path']); module.exports.notFound = function notFound(req) { return new NotFoundError("Not found", req.originalUrl); } // // 501 // var NotImplementedError = module.exports.NotImplementedError = errorFactory('NotImplementedError', ['message', 'path']);
var errorFactory = require('error-factory'); var namedArguments = { 'message': undefined, // the error message (string) 'status': undefined, // the error code status (may be HTTP status code) 'fields': undefined, // the fields applicable by this error (array) 'messageData': undefined, // the data, in case 'message' is a template 'expose': true // true to expose this error even in production mode }; /** Expose Model: ModelException */ module.exports.ModelException = errorFactory('beyo.model.ModelException', namedArguments); /** Expose Collection: CollectionException */ module.exports.CollectionException = errorFactory('beyo.model.CollectionException', namedArguments); /** Expose Types: TypeException */ module.exports.TypeException = errorFactory('beyo.model.TypeException', namedArguments); /** Expose Types: ValidationException */ module.exports.ValidationException = errorFactory('beyo.model.ValidationException', namedArguments);
/** Suspend */ var co = require('co'); var errorFactory = require('error-factory'); var SuspendError = errorFactory('SuspendError'); var AsyncTimeoutError = errorFactory('AsyncTimeoutError'); var globalIndex = 0; /** Expose function */ module.exports = createMarker; module.exports.SuspendError = SuspendError; module.exports.AsyncTimeoutError = AsyncTimeoutError; /** Wrap inside a builder method to encapsulate the marker */ function createMarker() { var markerId = ++globalIndex; var waiting = false; var done = false; var doneArgs = undefined; var timeoutError = null;
var fs = require('fs'); var path = require('path'); var Model = require('beyo-model').Model; var Types = require('beyo-model').Types; var errorFactory = require('error-factory'); var errorArguments = [ 'message', 'messageData' ]; var ValidationException = errorFactory('beyo.model.validation.ValidationException', errorArguments); /** System validators */ var validators = loadBuiltinValidators(); /** Custom unlocked validators */ var customValidators = {}; module.exports.define = defineValidator; module.exports.undefine = undefineValidator; module.exports.isDefined = isValidatorDefined; module.exports.getValidators = getDefinedValidators; module.exports.get = getValidator; module.exports.validate = validateModel; Object.freeze(validators);
var err = function(name) { return factory('FrozenExpress.' + name + 'Error'); };
const APPLICATION_NAME_REGEXP = /^[a-z]+[a-zA-Z0-9-_.]*$/; const MODULE_NAME_REGEXP = /^[a-z]+[a-zA-Z0-9]*$/; var crypto = require('crypto'); var co = require('co'); var errorFactory = require('error-factory'); var basename = require('path').basename; var fileProc = require('../../lib/io/file-processor'); var BeyoInitException = errorFactory('beyo.BeyoInitException', [ 'message', 'messageData' ]); module.exports = function init(command, actionWrapper) { command .description('Initialize a new project') .usage('init [options] [url|file]') .option('-n, --app-name <name>', 'the project name [' + basename(process.cwd()) + ']', basename(process.cwd())) .option('-m, --module-name <name>', 'the default module name [default]', 'default') .option('-p, --create-package', '(optional) create a package.json file', false) .option('-I, --no-npm-install', '(optional) do not run npm install', false) .option('-X, --no-shell-exec', '(optional) do not run shell commands', false) .option('-f, --fixture <git-repo>', '(optional) use fixture from git repo', false) .action(actionWrapper(['url|file'], null, _initAction)) ; }; function * _initAction(beyo, args, options) { var context = { 'hash_auth_key': hash(), 'hash_secure_auth_key': hash(),
const MODULE_FILE = 'index'; var path = require('path'); var errorFactory = require('error-factory'); var ApplicationException = errorFactory('beyo.ApplicationException'); module.exports = appLoader; function * appLoader(beyo, options) { var moduleAppInit; var eventData; if (options === undefined) { throw ApplicationException('No options specified'); } else if (options === null || options.__proto__.constructor !== Object) { throw ApplicationException('Invalid options value: ' + String(options)); } else if (!('path' in options)) { throw ApplicationException('Application path not specified'); } else if (typeof options.path !== 'string') { throw ApplicationException('Invalid path value: ' + String(options.path)); } eventData = { appPath: options.path }; try {