Skip to content

Commit 15e497c

Browse files
committed
Use Git connect instead of CI deploy
1 parent af00307 commit 15e497c

File tree

17 files changed

+56
-57
lines changed

17 files changed

+56
-57
lines changed

.circleci/config.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ jobs:
1717
paths:
1818
- node_modules
1919
- run: npm t
20-
- run: npm run lint
21-
publish:
20+
- run: npx prettier -c .
21+
deploy:
2222
<<: *defaults
2323
steps:
2424
- checkout
@@ -30,14 +30,14 @@ jobs:
3030
echo 'export CLOUDFLARE_ACCOUNT_ID=$CF_ACCOUT_ID' >> $BASH_ENV
3131
echo 'export CLOUDFLARE_API_TOKEN=$CF_WORKERS_API_TOKEN' >> $BASH_ENV
3232
- run:
33-
name: Publish the worker code
34-
command: npm run publish
33+
name: Deploy the worker code
34+
command: npm run deploy
3535
workflows:
36-
publish:
36+
deploy:
3737
jobs:
3838
- test:
3939
context: org-global
40-
- publish:
40+
- deploy:
4141
context: org-global
4242
requires:
4343
- test

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
node_modules
2-
/index.js
2+
.wrangler

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18
1+
stable

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Cloudflare Health Check → Splunk On-Call [![](https://circleci.com/gh/fiverr/health-check-to-splunk-on-call/tree/master.svg?style=svg)](https://circleci.com/gh/fiverr/health-check-to-splunk-on-call/tree/master)
1+
# Cloudflare Health Check → Splunk On-Call
22

33
☁️ Cloudflare Edge Worker to relay Health Check messages to Splunk On-Call (FKA Victorops)
44

package.json

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,16 @@
1313
],
1414
"author": "Fiverr",
1515
"license": "Unlicense",
16-
"main": "index.js",
1716
"type": "module",
1817
"scripts": {
19-
"build": "esbuild src/index.ts --outfile=index.js --format=esm --bundle",
2018
"format": "prettier -w .",
21-
"lint": "prettier -c .",
22-
"pretest": "npm run build",
23-
"publish": "wrangler publish",
24-
"start": "wrangler dev src/index.ts",
25-
"test": "node --test tests/index.js",
26-
"wrangler": "wrangler"
19+
"deploy": "npx wrangler deploy",
20+
"start": "npx wrangler dev src/index.ts",
21+
"test": "node --test --experimental-strip-types tests/index.ts"
2722
},
2823
"devDependencies": {
29-
"@cloudflare/workers-types": "^3.11.0",
30-
"esbuild": "^0.14.43",
31-
"prettier": "^2.7.0",
32-
"wrangler": "^2.0.12"
24+
"@cloudflare/workers-types": "^4.20250321.0",
25+
"prettier": "^3.5.3",
26+
"wrangler": "^4.5.0"
3327
}
3428
}
File renamed without changes.

src/forward/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import { Request } from "@cloudflare/workers-types";
2-
import { IncomingPayload } from "../types";
3-
import { REST_ENDPOINT } from "../constants";
4-
import { transformMessage } from "../transformMessage";
5-
import { post } from "../post";
1+
import type { IncomingPayload } from "../types.d.ts";
2+
import { REST_ENDPOINT } from "../constants/index.ts";
3+
import { transformMessage } from "../transformMessage/index.ts";
4+
import { post } from "../post/index.ts";
65

76
export async function forward(
87
request: Request,
98
routingKey: string,
10-
secret: string
9+
secret: string,
1110
): Promise<Response> {
1211
const payload: IncomingPayload = await request.json();
1312
const body = transformMessage(payload);

src/getRoutingDetails/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { SECRET_HEADER } from "../constants";
1+
import { URLPattern } from "node:url";
2+
import { SECRET_HEADER } from "../constants/index.ts";
23

34
export function getRoutingDetails(request: Request): [string, string] {
4-
const url = new URL(request.url);
55
const secret = request.headers.get(SECRET_HEADER);
6-
const routingKey = url.pathname.split("/").filter(Boolean).pop();
6+
const routingKey = new URLPattern({ pathname: "/:routingKey" }).exec(
7+
request.url,
8+
)?.pathname?.groups?.routingKey;
79
return [secret, routingKey];
810
}

src/handle/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { getRoutingDetails } from "../getRoutingDetails";
2-
import { forward } from "../forward";
3-
import { createResponse } from "../createResponse";
1+
import { getRoutingDetails } from "../getRoutingDetails/index.ts";
2+
import { forward } from "../forward/index.ts";
3+
import { createResponse } from "../createResponse/index.ts";
44

55
export function handle(request: Request): [Response, Promise<any>?] {
66
if (request.method?.toUpperCase() !== "POST") {

src/index.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { Env, EventContext, Request } from "@cloudflare/workers-types";
2-
import { handle } from "./handle";
3-
4-
export default {
5-
async fetch(
6-
request: Request,
7-
env: Env,
8-
ctx: EventContext
9-
): Promise<Response> {
1+
import { handle } from "./handle/index.ts";
2+
3+
type Env = Record<string, string>;
4+
5+
const handler: ExportedHandler<Env> = {
6+
async fetch(request, env, ctx) {
107
const [response, ...promises] = handle(request);
118

129
promises.forEach((promise) => ctx.waitUntil(promise));
1310
return response;
1411
},
1512
};
13+
14+
export default handler;

0 commit comments

Comments
 (0)