-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathapp.ts
More file actions
32 lines (29 loc) · 892 Bytes
/
app.ts
File metadata and controls
32 lines (29 loc) · 892 Bytes
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
import express, { Router, text } from "express";
import morgan from "morgan";
import { ENV } from "./env";
import { notFound } from "./res";
import bundle from "./routes/bundle";
import preview from "./routes/preview";
import schema from "./routes/schema";
import githubWebhook from "./routes/webhooks.github";
const PORT = ENV.PORT;
const app = express();
app.use(text());
app.use(morgan("dev"));
app.use(express.json());
app.use(
express.urlencoded({
extended: true,
}),
);
const router = Router();
router.get("/status", (_, res) => res.status(200).send("OK"));
router.get("/schema.json", schema);
router.post("/preview", preview);
router.get("/bundle", bundle);
router.post("/webhooks/github", githubWebhook);
router.all("*", (_, res) => notFound(res));
app.use(router);
app.listen(PORT, () => {
console.log(`docs.page api server is running at http://localhost:${PORT}`);
});