@ -6,6 +6,7 @@ import Koa from "koa";
|
||||
import compress from "koa-compress";
|
||||
import helmet from "koa-helmet";
|
||||
import logger from "koa-logger";
|
||||
import Router from "koa-router";
|
||||
import { uniq } from "lodash";
|
||||
import stoppable from "stoppable";
|
||||
import throng from "throng";
|
||||
@ -40,7 +41,9 @@ async function start(id, disconnect) {
|
||||
const server = stoppable(http.createServer(app.callback()));
|
||||
const httpLogger = debug("http");
|
||||
const log = debug("server");
|
||||
const router = new Router();
|
||||
|
||||
// install basic middleware shared by all services
|
||||
app.use(logger((str, args) => httpLogger(str)));
|
||||
app.use(compress());
|
||||
app.use(helmet());
|
||||
@ -56,6 +59,10 @@ async function start(id, disconnect) {
|
||||
await init(app, server);
|
||||
}
|
||||
|
||||
// install health check endpoint for all services
|
||||
router.get("/_health", (ctx) => (ctx.body = "OK"));
|
||||
app.use(router.routes());
|
||||
|
||||
server.on("error", (err) => {
|
||||
throw err;
|
||||
});
|
||||
|
@ -93,8 +93,6 @@ koa.use(
|
||||
})
|
||||
);
|
||||
|
||||
router.get("/_health", (ctx) => (ctx.body = "OK"));
|
||||
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
router.get("/static/*", async (ctx) => {
|
||||
ctx.set({
|
||||
|
Reference in New Issue
Block a user