-
Notifications
You must be signed in to change notification settings - Fork 0
feat: API monitoring #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+201
−3
Closed
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
816d98d
feat: api monitoring
wylited 39fb600
chore: clean-up imports and usage
wylited 6057846
feat: limit /metrics to local networks using plugins
wylited de287f1
Revert "feat: limit /metrics to local networks using plugins"
wylited 8860921
feat: prometheus key to access /metrics
wylited c1d65cc
chore: fix linting
wylited 18d4a1b
Apply suggestions from code review
wylited 8dda6cb
chore: fix linting
wylited 2fd7a85
Merge branch 'main' into feat/monitoring
wylited f84f5e8
fix: merge logger and error message
wylited 7df60af
chore: fix linting
wylited 9016534
fix(auth): correctly parse `AUTH_SKIP` environment variable
wylited c36e5b3
chore(gitignore): ignore `.env*` but keep `.env.example`
polyipseity 4719ccf
Merge branch 'feat/monitoring' of https://github.com/USThing/template…
wylited File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { build } from "../helper.js"; | ||
| import * as assert from "node:assert"; | ||
| import { test } from "node:test"; | ||
|
|
||
| test("metrics route without key", async (t) => { | ||
| const app = await build(t); | ||
|
|
||
| const response = await app.inject({ | ||
| url: "/metrics", | ||
| }); | ||
|
|
||
| assert.equal(response.statusCode, 200); | ||
| }); | ||
wylited marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| test("metrics route with key", async (t) => { | ||
| const app = await build(t, { prometheusKey: "secret" }); | ||
|
|
||
| // Without auth header | ||
| const response = await app.inject({ | ||
| url: "/metrics", | ||
| }); | ||
| assert.equal(response.statusCode, 401); | ||
|
|
||
| // With correct auth header | ||
| const responseAuth = await app.inject({ | ||
| url: "/metrics", | ||
| headers: { | ||
| authorization: "Bearer secret", | ||
| }, | ||
| }); | ||
| assert.equal(responseAuth.statusCode, 200); | ||
wylited marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // With incorrect auth header | ||
| const responseBadAuth = await app.inject({ | ||
| url: "/metrics", | ||
| headers: { | ||
| authorization: "Bearer wrong", | ||
| }, | ||
| }); | ||
| assert.equal(responseBadAuth.statusCode, 401); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.