Skip to content

Commit

Permalink
Add health-check path (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuhdev authored Jan 5, 2025
1 parent b82c1b1 commit 60d8987
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Caddyfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
}

{$HOST_ADDRESS:localhost} {
redir /abc https://example.com
respond /health-check "OK"

@snapshot path_regexp ^/snapshot/(\d\d\d\d-\d\d-\d\d)/(.*)$
redir @snapshot https://raw.githubusercontent.com/delpa-org/melpa-snapshot-{re.1}/refs/heads/master/packages/{re.2} permanent

respond "404 Not Found" 404 {
close
}
Expand Down
11 changes: 9 additions & 2 deletions index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

const domain = "localhost" as const;
const hostAddress = "https://localhost:3001" as const;
const delpaGitHubRawBaseUrl =
"https://raw.githubusercontent.com/delpa-org" as const;

test("/health-check", async () => {
const response = await fetch(`${hostAddress}/health-check`, {
redirect: "manual",
});
expect(response.status).toBe(200);
expect(await response.text()).toBe("OK");
});

describe("/snapshot", () => {
const hostAddress = `https://${domain}:3001`;
const snapshotFirstPathComp = "snapshot" as const;
for (const [name, path] of [
["valid with a one-level subdir", "2025-01-02/a"],
Expand Down

0 comments on commit 60d8987

Please sign in to comment.