modify code to standard style

This commit is contained in:
Jay 2018-03-13 23:40:10 +08:00
parent d4f9e78e2a
commit 32916d269e
7 changed files with 14 additions and 14 deletions

5
app.js
View File

@ -1,15 +1,12 @@
const Koa = require('koa') const Koa = require('koa')
const app = new Koa() const app = new Koa()
const path = require('path') const path = require('path')
const fs = require('fs')
const config = require('./config') const config = require('./config')
// require middleware // require middleware
const cors = require('kcors') const cors = require('kcors')
const koaBody = require('koa-body')
const koaSession = require('koa-session2') const koaSession = require('koa-session2')
const koaLogger = require('koa-logger') const koaLogger = require('koa-logger')
const koaMount = require('koa-mount')
const koaStatic = require('koa-static') const koaStatic = require('koa-static')
if (process.env['NODE_ENV'] !== 'test') { if (process.env['NODE_ENV'] !== 'test') {
@ -30,4 +27,4 @@ const server = app.listen(config.port, () => {
console.log(`start on port ${server.address().port}`) console.log(`start on port ${server.address().port}`)
}) })
module.exports = server module.exports = server

View File

@ -6,6 +6,6 @@ module.exports = {
port: process.env.DB_PORT || 5432, port: process.env.DB_PORT || 5432,
db: process.env.DB_NAME || 'mystorage', db: process.env.DB_NAME || 'mystorage',
user: process.env.DB_USER || 'postgres', user: process.env.DB_USER || 'postgres',
pass: process.env.DB_PASS || '', pass: process.env.DB_PASS || ''
} }
} }

View File

@ -1,3 +1,3 @@
process.env.__BASE = __dirname process.env.__BASE = __dirname
const server = require('./app') require('./app')

View File

@ -5,7 +5,7 @@ r.use('/api', require('./api').routes())
r.get('/', async (c, n) => { r.get('/', async (c, n) => {
c.status = 200 c.status = 200
c.body = "" c.body = ''
}) })
module.exports = r module.exports = r

View File

@ -13,4 +13,4 @@ module.exports = {
message: 'Internal Error' message: 'Internal Error'
} }
} }
} }

View File

@ -1,10 +1,12 @@
/* eslint-disable no-unused-vars */
/* eslint-disable no-undef */
/* eslint-disable no-unused-expressions */
it('api root test', done => { it('api root test', done => {
chai.request(server) chai.request(server)
.get('/api') .get('/api')
.end((err, res) => { .end((err, res) => {
chai.expect(err).to.be.null chai.expect(err).to.be.null
chai.expect(res).to.be.status(200) chai.expect(res).to.have.status(200)
done() done()
}) })
}) })

View File

@ -1,3 +1,5 @@
/* eslint-disable no-undef */
/* eslint-disable no-unused-vars */
process.env['NODE_ENV'] = 'test' process.env['NODE_ENV'] = 'test'
global.chai = require('chai') global.chai = require('chai')
global.chaiHttp = require('chai-http') global.chaiHttp = require('chai-http')
@ -5,7 +7,6 @@ global.server = require('../app')
global.chai.use(chaiHttp) global.chai.use(chaiHttp)
global.importTest = (name, path) => { global.importTest = (name, path) => {
describe(name, () => { describe(name, () => {
require(path) require(path)
@ -14,4 +15,4 @@ global.importTest = (name, path) => {
describe('Project Test', () => { describe('Project Test', () => {
importTest('Test API', './api') importTest('Test API', './api')
}) })