This repository has been archived by the owner on Jun 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
143 changed files
with
5,750 additions
and
5,857 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es6": true, | ||
"node": true, | ||
"mocha": true | ||
}, | ||
"plugins": ["node"], | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:node/recommended" | ||
], | ||
"parserOptions": { | ||
"sourceType": "module", | ||
"ecmaVersion": 2016 | ||
}, | ||
"rules": { | ||
"strict": ["error", "global"], | ||
"indent": [ | ||
"error", | ||
2 | ||
], | ||
"linebreak-style": [ | ||
"error", | ||
"unix" | ||
], | ||
"quotes": [ | ||
"error", | ||
"single", | ||
{ | ||
"avoidEscape": true | ||
} | ||
], | ||
"semi": [ | ||
"error", | ||
"always" | ||
], | ||
"node/exports-style": [ | ||
"error", | ||
"module.exports" | ||
], | ||
"node/no-unpublished-require": ["error", { | ||
"allowModules": ["chai", "sinon", "mock-knex", "chai-as-promised", "mockery", "redis-mock"], | ||
"tryExtensions": [".js", ".json", ".node"] | ||
}], | ||
"prefer-const": "error", | ||
"no-var": "error", | ||
"prefer-arrow-callback": "error", | ||
"no-template-curly-in-string": "error", | ||
"array-callback-return": "error", | ||
"default-case": "error", | ||
"curly": "error", | ||
"guard-for-in": "error", | ||
"no-else-return": "error", | ||
"no-empty-function": "error", | ||
"no-extra-bind": "error", | ||
"no-labels": "error", | ||
"no-lone-blocks": "error", | ||
"no-loop-func": "error", | ||
"no-multi-spaces": "error", | ||
"no-new": "error", | ||
"no-new-func": "error", | ||
"no-new-wrappers": "error", | ||
"no-return-assign": ["error", "except-parens"], | ||
"no-return-await": "error", | ||
"no-script-url": "error", | ||
"no-self-compare": "error", | ||
"no-throw-literal": "error", | ||
"no-unmodified-loop-condition": "error", | ||
"no-unused-expressions": "error", | ||
"no-useless-call": "error", | ||
"no-useless-concat": "error", | ||
"no-useless-escape": "error", | ||
"no-useless-return": "error", | ||
"no-void": "error", | ||
"yoda": ["error", "never"], | ||
"no-catch-shadow": "error", | ||
"array-bracket-spacing": ["error", "never", { | ||
"singleValue": true, | ||
"objectsInArrays": true, | ||
"arraysInArrays": true | ||
}], | ||
"block-spacing": "error", | ||
"brace-style": "error", | ||
"comma-dangle": ["error", "never"], | ||
"comma-spacing": "error", | ||
"comma-style": "error", | ||
"computed-property-spacing": "error", | ||
"func-call-spacing": "error", | ||
"key-spacing": "error", | ||
"arrow-body-style": "error", | ||
"arrow-parens": "error", | ||
"arrow-spacing": "error" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ temp | |
.env | ||
|
||
.vagrant | ||
.eslintcache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
language: node_js | ||
node_js: | ||
- "4.6" | ||
- "6.10.3" | ||
env: | ||
- CXX=g++-4.8 | ||
addons: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
var express = require('express'); | ||
var requid = require('cuid'); | ||
var helmet = require('helmet'); | ||
const express = require('express'); | ||
const requid = require('cuid'); | ||
const helmet = require('helmet'); | ||
|
||
var config = require('./api/config'); | ||
var database = require('./api/database'); | ||
var logger = require('./api/logging'); | ||
const config = require('./api/config'); | ||
const database = require('./api/database'); // eslint-disable-line no-unused-vars | ||
const logger = require('./api/logging'); | ||
|
||
// the dirname is local to every module, so we expose the app root's cwd | ||
// here (before initializing the api) | ||
config.cwd = process.__dirname; | ||
|
||
var instance = express(); | ||
const instance = express(); | ||
instance.use(helmet()); | ||
instance.use(function (req, res, next) { req.id = requid(); next(); }); | ||
instance.use((req, res, next) => { | ||
req.id = requid(); | ||
next(); | ||
}); | ||
|
||
var api = require('./api/'); | ||
const api = require('./api/'); | ||
instance.use('/v1', api.v1); | ||
|
||
instance.listen(config.port, function() { | ||
logger.info("initialized api (http://localhost:%d)", config.port); | ||
instance.listen(config.port, () => { | ||
logger.info('initialized api (http://localhost:%d)', config.port); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
var config = require('./config'); | ||
var logger = require('./logging'); | ||
const config = require('./config'); | ||
const logger = require('./logging'); | ||
|
||
var _Promise = require('bluebird'); | ||
var redis = require('redis'); | ||
const _Promise = require('bluebird'); | ||
const redis = require('redis'); | ||
|
||
_Promise.promisifyAll(redis.RedisClient.prototype); | ||
if(redis.Multi) { | ||
_Promise.promisifyAll(redis.Multi.prototype); | ||
_Promise.promisifyAll(redis.Multi.prototype); | ||
} | ||
|
||
_REDIS_CONFIG = { | ||
host: config.redis.host, | ||
port: config.redis.port | ||
const _REDIS_CONFIG = { | ||
host: config.redis.host, | ||
port: config.redis.port | ||
}; | ||
|
||
function CacheManager () { | ||
logger.info("connecting to cache"); | ||
logger.info('connecting to cache'); | ||
|
||
this._cache = redis.createClient(_REDIS_CONFIG); | ||
this._cache.on("error", function (err) { | ||
logger.error(err); | ||
}); | ||
this._cache = redis.createClient(_REDIS_CONFIG); | ||
this._cache.on('error', (err) => { | ||
logger.error(err); | ||
}); | ||
} | ||
|
||
CacheManager.prototype.constructor = CacheManager; | ||
|
||
CacheManager.prototype.instance = function() { | ||
return this._cache; | ||
return this._cache; | ||
}; | ||
|
||
module.exports = new CacheManager(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
var config = require('./config'); | ||
var logger = require('./logging'); | ||
|
||
var milliseconds = require('ms'); | ||
|
||
var KNEX_CONFIG = { | ||
client: 'mysql', | ||
connection: { | ||
host: config.database.primary.host, | ||
port: config.database.primary.port, | ||
user: config.database.primary.user, | ||
password: config.database.primary.password, | ||
database: config.database.primary.name | ||
}, | ||
pool: { | ||
min: config.database.primary.pool.min, | ||
max: config.database.primary.pool.max, | ||
idleTimeout: milliseconds(config.database.primary.pool.idleTimeout) | ||
} | ||
const config = require('./config'); | ||
const logger = require('./logging'); | ||
|
||
const milliseconds = require('ms'); | ||
|
||
const KNEX_CONFIG = { | ||
client: 'mysql', | ||
connection: { | ||
host: config.database.primary.host, | ||
port: config.database.primary.port, | ||
user: config.database.primary.user, | ||
password: config.database.primary.password, | ||
database: config.database.primary.name | ||
}, | ||
pool: { | ||
min: config.database.primary.pool.min, | ||
max: config.database.primary.pool.max, | ||
idleTimeout: milliseconds(config.database.primary.pool.idleTimeout) | ||
} | ||
}; | ||
|
||
function DatabaseManager() { | ||
logger.info("connecting to database"); | ||
this._knex = require('knex')(KNEX_CONFIG); | ||
logger.info('connecting to database'); | ||
this._knex = require('knex')(KNEX_CONFIG); | ||
|
||
this._bookshelf = require('bookshelf')(this._knex); | ||
this._bookshelf.plugin('pagination'); | ||
this._bookshelf = require('bookshelf')(this._knex); | ||
this._bookshelf.plugin('pagination'); | ||
} | ||
|
||
DatabaseManager.prototype.constructor = DatabaseManager; | ||
|
||
DatabaseManager.prototype.instance = function() { | ||
return this._bookshelf; | ||
return this._bookshelf; | ||
}; | ||
|
||
DatabaseManager.prototype.connection = function () { | ||
return this._knex; | ||
return this._knex; | ||
}; | ||
|
||
module.exports = new DatabaseManager(); |
Oops, something went wrong.