Skip to content

Commit

Permalink
Improve info
Browse files Browse the repository at this point in the history
  • Loading branch information
hakanensari committed Jul 18, 2024
1 parent c26aecd commit c33fa62
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@ app.use(express.static("public"))

app.get("/info", (req, res) => {
res.json({
cloudflare: req.headers["cf-ipcountry"] !== undefined,
maxmind: lookup.metadata.buildEpoch.toISOString().substring(0, 10),
cloudflare: {
enabled: req.headers["cf-ipcountry"] !== undefined,
},
maxmind: {
enabled: true,
build: lookup.metadata.buildEpoch.toISOString().substring(0, 10),
},
})
})

Expand Down
4 changes: 2 additions & 2 deletions app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ describe("GET /info", () => {

it("returns maxmind", async () => {
const res = await req
expect(res.body.maxmind).toBeDefined()
expect(res.body.maxmind.enabled).toBeTruthy()
})

it("returns cloudflare", async () => {
const res = await req.set("cf-ipcountry", "DE")
expect(res.body.cloudflare).toBeTruthy()
expect(res.body.cloudflare.enabled).toBeTruthy()
})

it("sets cache-control to public", async () => {
Expand Down

0 comments on commit c33fa62

Please sign in to comment.