Skip to content

Commit

Permalink
chore: use Server from useful-typescript-function
Browse files Browse the repository at this point in the history
  • Loading branch information
jschirrmacher committed Oct 24, 2023
1 parent 8f2d849 commit 5be731d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
9 changes: 0 additions & 9 deletions gateway/HTTPServer.ts

This file was deleted.

10 changes: 7 additions & 3 deletions gateway/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { config } from "dotenv-flow"
config()
import readConfig from "./Config"
import { httpServer } from "./HTTPServer"
import getMetrics from "./MetricsGenerator"
import setupMQTTClient from "./MQTTClient"
import { routerBuilder, setupServer } from "useful-typescript-functions"

async function setup() {
const config = await readConfig()
setupMQTTClient(config)
httpServer.get("/metrics", async (req, res) => {
res.header("Content-Type", "text/plain").send(getMetrics(config))
setupServer({
middlewares: [
routerBuilder("/metrics", "metrics")
.get("/", (req) => getMetrics(config))
.build(),
],
})
}

Expand Down
1 change: 1 addition & 0 deletions test.http
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GET http://localhost:8080/metrics

0 comments on commit 5be731d

Please sign in to comment.