Skip to content

Commit

Permalink
chore(style): format & fix by eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
a632079 committed Jun 14, 2020
1 parent b6dc849 commit 40c1f75
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ class cache {
const client = redis.createClient(config)
return client
}

static connectOrSkip () {
if (this.hasOwnProperty('redis')) {
if (this.redis) {
return true
} else {
return this.connect()
}
}

static command (commands, params) {
this.connectOrSkip()
const param = params
Expand Down
3 changes: 1 addition & 2 deletions src/controller.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
'use strict'
// Load Packages
const fs = require('fs')
const winston = require('winston')
Expand Down Expand Up @@ -29,7 +28,7 @@ class controllers {
async load () {
try {
// Load Controller
let controllers = {}
const controllers = {}
const dir = fs.readdirSync(path.join(__dirname, '../', './src/controllers'))
await dir.map((item, index, input) => {
controllers[item.substring(0, item.length - 3)] = module.parent.require(path.join(__dirname, '../', './src/controllers/' + item))
Expand Down
2 changes: 1 addition & 1 deletion src/cron.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Cron {
static async autoLoad (isArray) {
try {
// Load Crons
let crons = {}
const crons = {}
const dir = fs.readdirSync(path.join(__dirname, '../', './src/crons'))
if (isArray) {
await dir.map((item, index, input) => {
Expand Down
2 changes: 2 additions & 0 deletions src/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class db {
this.connect()
return this.registerModel(model)
}

static async connect () {
if (this.sequelize) {
return this.sequelize
Expand Down Expand Up @@ -48,6 +49,7 @@ class db {
return sequelize
}
}

static async registerModel (model) {
await this.connect()
if (this[model]) {
Expand Down
2 changes: 1 addition & 1 deletion src/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function log (ctx, start, len, err, event) {

// set the color of the status code;
const s = status / 100 | 0
const color = colorCodes.hasOwnProperty(s) ? colorCodes[s] : 0
const color = colorCodes.s ? colorCodes[s] : 0

// get the human readable response length
let length
Expand Down
2 changes: 2 additions & 0 deletions src/mail.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class mail {
return this.smtp
}
}

/*
* msg - Object
* -- to To Mail (String)
Expand All @@ -51,6 +52,7 @@ class mail {
delete msg.title
return this.smtp.sendMailAsync(msg)
}

static error (errStruct) {
// Send Error to Admins
const admin = nconf.get('admin')
Expand Down
7 changes: 2 additions & 5 deletions src/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ class route {

async routes () {
try {
let routes
const controller = await this.controller
// Load RouteMap
// RouteMap
const Router = require('koa-router')
const RouteMap = require(path.join(__dirname, '../', './routes'))(new Router(), controller)
routes = RouteMap
return routes
return require(path.join(__dirname, '../', './routes'))(new Router(), controller)
} catch (err) {
winston.error(err)
process.exit(1)
Expand Down

0 comments on commit 40c1f75

Please sign in to comment.