From 9b825ccaf0d70ce8f650bb7b8d05a2b3603fcfb9 Mon Sep 17 00:00:00 2001 From: sveisvei Date: Tue, 1 Nov 2016 15:38:27 +0100 Subject: [PATCH] rename files --- .../unleash-api/lib/error/name-exists-error.js | 16 +++++++--------- .../unleash-api/lib/error/notfound-error.js | 16 +++++++--------- .../unleash-api/lib/error/validation-error.js | 16 +++++++--------- packages/unleash-api/lib/event-store.js | 17 ++++++++--------- packages/unleash-api/server-impl.js | 2 +- 5 files changed, 30 insertions(+), 37 deletions(-) diff --git a/packages/unleash-api/lib/error/name-exists-error.js b/packages/unleash-api/lib/error/name-exists-error.js index c3ea9c98ce..518b0ba18a 100644 --- a/packages/unleash-api/lib/error/name-exists-error.js +++ b/packages/unleash-api/lib/error/name-exists-error.js @@ -1,15 +1,13 @@ 'use strict'; -const util = require('util'); +class NameExistsError extends Error { + constructor (message) { + super(); + Error.captureStackTrace(this, this.constructor); -function NameExistsError (message) { - Error.call(this); - Error.captureStackTrace(this, this.constructor); - - this.name = this.constructor.name; - this.message = message; + this.name = this.constructor.name; + this.message = message; + } } -util.inherits(NameExistsError, Error); - module.exports = NameExistsError; diff --git a/packages/unleash-api/lib/error/notfound-error.js b/packages/unleash-api/lib/error/notfound-error.js index ed06f80acb..7bfff69860 100644 --- a/packages/unleash-api/lib/error/notfound-error.js +++ b/packages/unleash-api/lib/error/notfound-error.js @@ -1,15 +1,13 @@ 'use strict'; -const util = require('util'); +class NotFoundError extends Error { + constructor (message) { + super(); + Error.captureStackTrace(this, this.constructor); -function NotFoundError (message) { - Error.call(this); - Error.captureStackTrace(this, this.constructor); - - this.name = this.constructor.name; - this.message = message; + this.name = this.constructor.name; + this.message = message; + } } -util.inherits(NotFoundError, Error); - module.exports = NotFoundError; diff --git a/packages/unleash-api/lib/error/validation-error.js b/packages/unleash-api/lib/error/validation-error.js index 5f34bbe9d7..7cf4688fcb 100644 --- a/packages/unleash-api/lib/error/validation-error.js +++ b/packages/unleash-api/lib/error/validation-error.js @@ -1,15 +1,13 @@ 'use strict'; -const util = require('util'); +class ValidationError extends Error { + constructor (message) { + super(); + Error.captureStackTrace(this, this.constructor); -function ValidationError (message) { - Error.call(this); - Error.captureStackTrace(this, this.constructor); - - this.name = this.constructor.name; - this.message = message; + this.name = this.constructor.name; + this.message = message; + } } -util.inherits(ValidationError, Error); - module.exports = ValidationError; diff --git a/packages/unleash-api/lib/event-store.js b/packages/unleash-api/lib/event-store.js index b97e937fc4..30b163de45 100644 --- a/packages/unleash-api/lib/event-store.js +++ b/packages/unleash-api/lib/event-store.js @@ -1,16 +1,15 @@ 'use strict'; -const util = require('util'); const EventEmitter = require('events').EventEmitter; -function EventStore (eventDb) { - this.eventDb = eventDb; - EventEmitter.call(this); -} -util.inherits(EventStore, EventEmitter); +module.exports = class EventStore extends EventEmitter { + constructor (eventDb) { + super(); + this.eventDb = eventDb; + } -EventStore.prototype.create = function (event) { - return this.eventDb.store(event).then(() => this.emit(event.type, event)); + create (event) { + return this.eventDb.store(event).then(() => this.emit(event.type, event)); + } }; -module.exports = EventStore; diff --git a/packages/unleash-api/server-impl.js b/packages/unleash-api/server-impl.js index 1c228e4096..7bf4878c2d 100644 --- a/packages/unleash-api/server-impl.js +++ b/packages/unleash-api/server-impl.js @@ -4,7 +4,7 @@ const logger = require('./lib/logger'); const migrator = require('./migrator'); const DEFAULT_OPTIONS = { - databaseUri: process.env.DATABASE_URL, + databaseUri: process.env.DATABASE_URL || 'postgres://unleash_user:passord@localhost:5432/unleash', port: process.env.HTTP_PORT || process.env.PORT || 4242, baseUriPath: process.env.BASE_URI_PATH || '', };