perf[mock-server]: optimize variable name

This commit is contained in:
Pan 2019-04-11 10:00:21 +08:00
parent 035c7d78f1
commit 5dd98ea47f
1 changed files with 3 additions and 3 deletions

View File

@ -3,16 +3,16 @@ const bodyParser = require('body-parser')
const chalk = require('chalk') const chalk = require('chalk')
function registerRoutes(app) { function registerRoutes(app) {
let mockStartIndex let mockLastIndex
const { default: mocks } = require('./index.js') const { default: mocks } = require('./index.js')
for (const mock of mocks) { for (const mock of mocks) {
app[mock.type](mock.url, mock.response) app[mock.type](mock.url, mock.response)
mockStartIndex = app._router.stack.length mockLastIndex = app._router.stack.length
} }
const mockRoutesLength = Object.keys(mocks).length const mockRoutesLength = Object.keys(mocks).length
return { return {
mockRoutesLength: mockRoutesLength, mockRoutesLength: mockRoutesLength,
mockStartIndex: mockStartIndex - mockRoutesLength mockStartIndex: mockLastIndex - mockRoutesLength
} }
} }