Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lienren committed May 11, 2018
1 parent 21699fa commit 44ccb77
Show file tree
Hide file tree
Showing 19 changed files with 695 additions and 240 deletions.
18 changes: 14 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: Lienren
* @Date: 2018-01-02 14:28:21
* @Last Modified by: Lienren
* @Last Modified time: 2018-01-24 14:44:59
* @Last Modified time: 2018-03-28 22:42:50
*/
'use strict';
const http = require('http');
Expand All @@ -29,6 +29,10 @@ app.context.db = sqlhelper;
// mongodb初始化
// sudo mongod --config /usr/local/etc/mongod.conf --auth

// 加载API数据配置
const api_data = require('./routers/api_data');
app.context.api_data = api_data;

// 静态存放地址
const staticPath = './static';
app.use(koastatic(path.join(__dirname, staticPath)));
Expand All @@ -37,7 +41,11 @@ app.use(koastatic(path.join(__dirname, staticPath)));
app.use(cors());

// 使用koa-bodyparser中间件
app.use(bodyParser());
app.use(
bodyParser({
enableTypes: ['json', 'form']
})
);

// 全局处理异常
app.use(async (ctx, next) => {
Expand All @@ -53,8 +61,10 @@ app.use(async (ctx, next) => {
});

// 使用路由
const router = require('./router');
const router = require('./routers/router');
const api = require('./routers/api');
app.use(router);
app.use(api);

// 绑定访问端口
http.createServer(app.callback()).listen(3000);
http.createServer(app.callback()).listen(13000);
Binary file removed fonts/PingFang.ttc
Binary file not shown.
7 changes: 1 addition & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
"description": "koa demo",
"main": "app.js",
"dependencies": {
"async": "^2.6.0",
"axios": "^0.17.1",
"barcode": "^0.1.0",
"gm": "^1.23.1",
"ioredis": "^3.2.2",
"koa": "^2.4.1",
"koa-bodyparser": "^4.2.0",
Expand All @@ -27,9 +24,7 @@
"type": "git",
"url": "git+https://github.com/lienren/koademo.git"
},
"keywords": [
"koa"
],
"keywords": ["koa"],
"author": "lienren",
"license": "ISC",
"bugs": {
Expand Down
143 changes: 0 additions & 143 deletions router.js

This file was deleted.

Loading

0 comments on commit 44ccb77

Please sign in to comment.