mirror of
https://github.com/typicode/json-server.git
synced 2025-07-28 12:43:18 +08:00
Add comments
This commit is contained in:
13
bin/index.js
13
bin/index.js
@ -19,12 +19,13 @@ var argv = yargs
|
|||||||
alias: 'p',
|
alias: 'p',
|
||||||
description: 'Set port',
|
description: 'Set port',
|
||||||
default: 3000
|
default: 3000
|
||||||
},
|
|
||||||
host: {
|
|
||||||
alias: 'H',
|
|
||||||
description: 'Set host',
|
|
||||||
default: 'localhost'
|
|
||||||
}
|
}
|
||||||
|
// Disable for the moment...
|
||||||
|
// host: {
|
||||||
|
// alias: 'H',
|
||||||
|
// description: 'Set host',
|
||||||
|
// default: 'localhost'
|
||||||
|
// }
|
||||||
})
|
})
|
||||||
.example('$0 db.json', '')
|
.example('$0 db.json', '')
|
||||||
.example('$0 file.js', '')
|
.example('$0 file.js', '')
|
||||||
@ -70,7 +71,7 @@ function start(object, filename) {
|
|||||||
// Set file and port
|
// Set file and port
|
||||||
var source = argv._[0]
|
var source = argv._[0]
|
||||||
var port = process.env.PORT || argv.port
|
var port = process.env.PORT || argv.port
|
||||||
var host = process.env.HOST || argv.host
|
var host = 'localhost' //process.env.HOST || argv.host
|
||||||
|
|
||||||
// Say hi, load file and start server
|
// Say hi, load file and start server
|
||||||
console.log(chalk.cyan('{^_^} Hi!\n'))
|
console.log(chalk.cyan('{^_^} Hi!\n'))
|
||||||
|
@ -9,9 +9,12 @@ var errorhandler = require('errorhandler')
|
|||||||
module.exports = function() {
|
module.exports = function() {
|
||||||
var server = express()
|
var server = express()
|
||||||
|
|
||||||
|
// Logger
|
||||||
server.use(logger('dev', {
|
server.use(logger('dev', {
|
||||||
skip: function(req, res) { return req.path === '/favicon.ico' }
|
skip: function(req, res) { return req.path === '/favicon.ico' }
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
// Beautify JSON
|
||||||
server.set('json spaces', 2)
|
server.set('json spaces', 2)
|
||||||
|
|
||||||
// Serve static files
|
// Serve static files
|
||||||
|
Reference in New Issue
Block a user