Permalink
Browse files

init

  • Loading branch information...
luoquanquan
luoquanquan committed Dec 20, 2018
0 parents commit ad976c71b37a39ce9050a9fbb26c144101931da0
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
@@ -0,0 +1,3 @@
module.exports = {
"extends": "standard"
};
@@ -0,0 +1 @@
node_modules
88 bin/www
@@ -0,0 +1,88 @@
#!/usr/bin/env node

/**
* Module dependencies.
*/

var app = require('../src/app')
var debug = require('debug')('demo:server')
var http = require('http')

/**
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || '3000')
// app.set('port', port);

/**
* Create HTTP server.
*/

var server = http.createServer(app.callback())

/**
* Listen on provided port, on all network interfaces.
*/

server.listen(port)
server.on('error', onError)
server.on('listening', onListening)

/**
* Normalize a port into a number, string, or false.
*/

function normalizePort (val) {
var port = parseInt(val, 10)

if (isNaN(port)) {
// named pipe
return val
}

if (port >= 0) {
// port number
return port
}

return false
}

/**
* Event listener for HTTP server "error" event.
*/

function onError (error) {
if (error.syscall !== 'listen') {
throw error
}

var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port

// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges')
process.exit(1)
case 'EADDRINUSE':
console.error(bind + ' is already in use')
process.exit(1)
default:
throw error
}
}

/**
* Event listener for HTTP server "listening" event.
*/

function onListening () {
var addr = server.address()
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port
debug('Listening on ' + bind)
}
@@ -0,0 +1,17 @@
/*
* @Author: luoquanquan
* @Date: 2018-10-29 12:56:52
* @Last Modified by: luoquanquan
* @Last Modified time: 2018-10-29 17:59:30
*/
module.exports = {
log: true,
// 数据库配置
mongo: {
host: '127.0.0.1',
db: 'demo',
port: 27017,
pass: '',
user: ''
}
}
@@ -0,0 +1,16 @@
/*
* @Author: luoquanquan
* @Date: 2018-10-26 17:23:39
* @Last Modified by: luoquanquan
* @Last Modified time: 2018-10-29 12:54:34
*/
console.log(process.env.NODE_ENV)

const dev = require('./dev')
const prod = require('./prod')
const test = require('./test')
module.exports = {
dev,
prod,
test
}[process.env.NODE_ENV || 'dev']
@@ -0,0 +1,60 @@
/**
* @Author: 罗圈圈
* @Date: 2018-10-28 17:06:35
* @Last Modified by: 罗圈圈
* @Last Modified time: 2018-10-28 21:43:56
*/

const path = require('path')

// 日志根目录
const baseLogPath = path.resolve(__dirname, '../../logs')

// 错误日志目录
const errorPath = '/error'
// 错误日志文件名
const errorFileName = 'error'
// 错误日志输出完整路径
const errorLogPath = `${baseLogPath + errorPath}/${errorFileName}`
// var errorLogPath = path.resolve(__dirname, "../logs/error/error");

// 响应日志目录
const responsePath = '/response'
// 响应日志文件名
const responseFileName = 'response'
// 响应日志输出完整路径
const responseLogPath = `${baseLogPath + responsePath}/${responseFileName}`

module.exports = {
appenders: {
// 错误日志
errorLogger: {
type: 'console', // 日志类型
filename: errorLogPath, // 日志输出位置
alwaysIncludePattern: true, // 是否总是有后缀名
pattern: '-yyyy-MM-dd-hh.log', // 后缀,每小时创建一个新的日志文件
path: errorPath // 自定义属性,错误日志的根目录
},
// 响应日志
resLogger: {
type: 'console',
filename: responseLogPath,
alwaysIncludePattern: true,
pattern: '-yyyy-MM-dd-hh.log',
path: responsePath
},
// 响应日志
test: {
type: 'stdout',
filename: responseLogPath,
alwaysIncludePattern: true,
pattern: '-yyyy-MM-dd-hh.log',
path: responsePath
}
},
categories: {
default: { appenders: ['test'], level: 'debug' },
errorLogger: { appenders: ['errorLogger'], level: 'error' },
resLogger: { appenders: ['resLogger'], level: 'debug' }
}
}
@@ -0,0 +1,17 @@
/*
* @Author: luoquanquan
* @Date: 2018-10-29 12:56:52
* @Last Modified by: luoquanquan
* @Last Modified time: 2018-10-29 17:59:30
*/
module.exports = {
log: true,
// 数据库配置
mongo: {
host: '127.0.0.1',
db: 'demo',
port: 27017,
pass: '',
user: ''
}
}
@@ -0,0 +1,17 @@
/*
* @Author: luoquanquan
* @Date: 2018-10-29 12:56:52
* @Last Modified by: luoquanquan
* @Last Modified time: 2018-10-29 17:59:54
*/
module.exports = {
log: true,
// 数据库配置
mongo: {
host: '127.0.0.1',
db: 'demo',
port: 27017,
pass: '',
user: ''
}
}
No changes.
@@ -0,0 +1,36 @@
[2018-10-28T17:08:50.791] [INFO] resLogger -
*************** response log start ***************
request method: GET
request originalUrl: /api/demo
request client ip: ::1
request query: {}
response time: 20
response status: 200
response body:
{"_id":"5bd336fb0047b84b9711a017","sex":"male"}
*************** response log end ***************

[2018-10-28T17:09:10.007] [INFO] resLogger -
*************** response log start ***************
request method: GET
request originalUrl: /api/demo
request client ip: ::1
request query: {}
response time: 20
response status: 200
response body:
{"_id":"5bd336fb0047b84b9711a017","sex":"male"}
*************** response log end ***************

[2018-10-28T17:09:37.250] [INFO] resLogger -
*************** response log start ***************
request method: GET
request originalUrl: /api/demo
request client ip: ::1
request query: {}
response time: 19
response status: 200
response body:
{"_id":"5bd336fb0047b84b9711a017","sex":"male"}
*************** response log end ***************

Oops, something went wrong.

0 comments on commit ad976c7

Please sign in to comment.