Skip to content

Commit 55fc658

Browse files
Add logs
1 parent 7d674e1 commit 55fc658

5 files changed

Lines changed: 43 additions & 37 deletions

File tree

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"lorem-ipsum": "^2.0.8",
99
"typescript": "^5.0.3",
1010
"vitest": "^0.30.0",
11-
"wrangler": "^3.0.1"
11+
"wrangler": "^3.1.1"
1212
},
1313
"private": true,
1414
"scripts": {

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ export class ActivityDurableObject {
133133

134134
async fetch(request: Request) {
135135
try {
136+
await triggerAlarm(this.env, "Alarm", `${request.method} ${request.url}`);
137+
136138
const { activityId } = await request.json() as {
137139
activityId?: string;
138140
};

src/routes/activities/create.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,19 @@ export async function handleCreateActivityRequest(request: RequestWithKey, env:
119119
}
120120
}, env);*/
121121

122+
console.log("call durable object");
123+
122124
const durableObjectId = env.ACTIVITY_DURABLE_OBJECT.idFromName("default");
125+
console.log("id from name " + durableObjectId);
126+
123127
const durableObject = env.ACTIVITY_DURABLE_OBJECT.get(durableObjectId);
124128

125-
context.waitUntil(durableObject.fetch(request.url, {
129+
await durableObject.fetch(request.url, {
126130
method: "POST",
127131
body: JSON.stringify({
128132
activityId: activity.id
129133
})
130-
}));
134+
});
131135

132136
return Response.json({
133137
success: true,

tests/data.test.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,8 @@ describe("Populate mock data", async () => {
4545
}
4646
}, 60 * 1000);
4747

48-
test("Create user avatars", async () => {
49-
expect(tokens.length).toBeTruthy();
50-
51-
for(let token of tokens) {
52-
const client = new Client(`${name}-${version}`, process.env.VITEST_SERVICE_API_URL, token);
53-
54-
const response = await fetch("https://staging.avatar-service.ridetracker.app/api/avatars/render/random", {
55-
method: "GET",
56-
headers: {
57-
Accept: "application/json",
58-
Authorization: `Bearer ${client.token}`
59-
}
60-
});
61-
62-
const result = await response.json() as any;
63-
expect(result.success).toBe(true);
64-
65-
const userAvatarResult = await uploadUserAvatar(client, result.base64Image, "{}");
66-
expect(userAvatarResult.success).toBe(true);
67-
68-
userAvatars.push(userAvatarResult.userAvatar.id);
69-
}
70-
}, 60 * 1000);
71-
7248
test("Create activities", async () => {
73-
expect(userAvatars.length).toBeTruthy();
49+
expect(tokens.length).toBeTruthy();
7450

7551
for(let index = 0; index < 10; index++) {
7652
const token = tokens[Math.floor(Math.random() * tokens.length)];
@@ -119,4 +95,28 @@ describe("Populate mock data", async () => {
11995
expect(activityCommentResult.success).toBe(true);
12096
}
12197
}, 60 * 1000);
98+
99+
test("Create user avatars", async () => {
100+
expect(tokens.length).toBeTruthy();
101+
102+
for(let token of tokens) {
103+
const client = new Client(`${name}-${version}`, process.env.VITEST_SERVICE_API_URL, token);
104+
105+
const response = await fetch("https://staging.avatar-service.ridetracker.app/api/avatars/render/random", {
106+
method: "GET",
107+
headers: {
108+
Accept: "application/json",
109+
Authorization: `Bearer ${client.token}`
110+
}
111+
});
112+
113+
const result = await response.json() as any;
114+
expect(result.success).toBe(true);
115+
116+
const userAvatarResult = await uploadUserAvatar(client, result.base64Image, "{}");
117+
expect(userAvatarResult.success).toBe(true);
118+
119+
userAvatars.push(userAvatarResult.userAvatar.id);
120+
}
121+
}, 60 * 1000);
122122
});

0 commit comments

Comments
 (0)