blob: 3ff5de7a6266c54f00bee2553e20fe52899fc520 (
plain)
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
|
import { App } from "@tinyhttp/app";
import { logger } from "@tinyhttp/logger";
import { auth } from "./middleware";
const app = new App();
const port = process.env.PORT ? Number(process.env.PORT) : 3000;
app
.use(logger({
timestamp: {
format: "YYYY-MM-DDTHH:mm:ssZ[Z]",
},
}))
.use(auth)
.get("/", (_, res) => {
res.send({ foo: "bar" });
})
.post("/webhook/start", (_req, res) => {
res.send({ webhook: "start" });
})
.post("/webhook/stop", (_req, res) => {
res.send({ webhook: "stop" });
})
.post("/scheduler/trigger", (_req, res) => {
res.send({ scheduler: "trigger" });
});
console.log(`Serving on http://localhost:${port}`);
app.listen(port);
|