-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
32 lines (25 loc) · 784 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
global.SERVICE_NAME = 'hello-jaeger';
const resolve = require('path').resolve;
const Koa = require('koa');
const app = new Koa();
const port = 3000;
const router = require('./router');
// middlewares
const koaJaeger = require(resolve(__dirname, 'middlewares/koa-jaeger'));
app.use(async (ctx, next) => {
// const start = Date.now();
await next();
// const ms = Date.now() - start;
// console.log(`${ctx.method} ${ctx.url} - ${ctx.status} ${ms}ms`);
});
// jaeger client
const configJaeger = require(resolve(__dirname, 'configs/jaeger'));
if (configJaeger) {
console.log('加载 jaeger 中间件');
app.use(koaJaeger(configJaeger));
}
// load router
app.use(router);
app.listen(port, function () {
console.log(`Listen on https://${port}.preview.lowcode.com`);
});