Skip to content

Commit 305e090

Browse files
authored
fix for deno 2 (#180)
* fix for deno 2 * Fix node version
1 parent 153d417 commit 305e090

4 files changed

Lines changed: 62 additions & 63 deletions

File tree

.github/workflows/build-frontend.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ on:
55
branches:
66
- "*"
77
schedule:
8-
- cron: "39 12 * * 6"
8+
- cron: "39 12 * * 6"
99

1010
jobs:
11-
run-linter:
11+
run-frontend-linter:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout repository
1515
uses: actions/checkout@v2
1616

1717
- uses: actions/setup-node@v3
1818
with:
19-
node-version: 'latest'
20-
19+
node-version: "16"
20+
2121
- name: Install dependencies
2222
run: npm install
2323
working-directory: ./app/frontend
@@ -29,4 +29,3 @@ jobs:
2929
# - name: Build
3030
# run: npm run lint
3131
# working-directory: ./app/frontend
32-

.github/workflows/lint-backend.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ on:
55
branches:
66
- "*"
77
schedule:
8-
- cron: "39 12 * * 6"
8+
- cron: "39 12 * * 6"
99

1010
jobs:
11-
run-linter:
11+
run-backend-linter:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout repository

app/backend/deploy.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ const values = Deno.env.toObject();
44
const port = values.PORT || 80;
55
const vapidKey = values.VAPID_KEY || 'eyJrdHkiOiJFQyIsImNydiI6IlAtMjU2IiwiYWxnIjoiRVMyNTYiLCJ4IjoiUV92WlVXUExOUlFMRnU5QWRNaGRDQlFpY1FKamxYajVHZ2lwY19BS1E5USIsInkiOiJILXlDUF9hZ3FzRmpGMmgtZ2dNTTdVT1UxdktJN1JTcU1XSVhfZjBJekhnIiwiZCI6IjVXdzg1TnFxN09lY0pyaDN5MDl6a1JLWWR3TEhUVTVObjlNZUNqMkh6Y2MiLCJrZXlfb3BzIjpbInNpZ24iXSwiZXh0Ijp0cnVlfQ==';
66
const sub = values.SUB || 'mailto:example@example.com';
7-
const cors = values.CORS || false;
7+
const cors = Boolean(values.CORS) || false;
88
const frontend = values.FRONTEND ?? 'static-site';
99
const sendkey = values.SENDKEY || undefined;
1010
const loginkey = values.LOGINKEY || undefined;
1111

1212

1313
await serve({
14-
port: Number(port),
15-
sub: sub,
16-
vapidKey: vapidKey,
17-
cors: cors,
18-
frontend: frontend,
19-
sendkey: sendkey,
20-
loginkey: loginkey,
14+
port: Number(port),
15+
sub: sub,
16+
vapidKey: vapidKey,
17+
cors: cors,
18+
frontend: frontend,
19+
sendkey: sendkey,
20+
loginkey: loginkey,
2121
})

app/backend/main.ts

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,66 @@ import { validateEmail, validatePort } from "./util/commandvalidator.ts";
44
import { notify } from "./client/mod.ts";
55

66
async function generateVapidKey() {
7-
const key = await window.crypto.subtle.generateKey({ name: "ECDSA", namedCurve: "P-256" }, true, ["sign", "verify"]);
8-
const serverKey = await window.crypto.subtle.exportKey("jwk", key.privateKey);
9-
const serverKeyString = JSON.stringify(serverKey, null, 0);
10-
const vapidKey = btoa(serverKeyString);
11-
return vapidKey;
7+
const key = await crypto.subtle.generateKey({ name: "ECDSA", namedCurve: "P-256" }, true, ["sign", "verify"]);
8+
const serverKey = await crypto.subtle.exportKey("jwk", key.privateKey);
9+
const serverKeyString = JSON.stringify(serverKey, null, 0);
10+
const vapidKey = btoa(serverKeyString);
11+
return vapidKey;
1212
}
1313

1414
export const program = new Denomander({
15-
app_name: "Notify",
16-
app_description: ``,
17-
app_version: "1.0.0"
15+
app_name: "Notify",
16+
app_description: ``,
17+
app_version: "1.0.0"
1818
});
1919

2020

2121
program
22-
.command('run', 'Run the server')
23-
.requiredOption("--vapidkey", `vapid key, you can use notify generate to generate a new one - warning a new key means that clients need to subscribe to it again!`)
24-
.requiredOption("--sub", `Set the vapid subscription information (email of the owner of the site)`, validateEmail)
25-
// .option("-s --store", `Store messages, so clients can request past messages that might be lost when device is not online for a long time.`, Boolean)
26-
.option("-c --cors", `Enable CORS`, Boolean)
27-
.option("-f --frontend", `if set the frontend will be served (this needs to point to the build directory of the frontend)`, undefined, './frontend/build')
28-
.option("--sendkey", `Set the api key (for sending a new request)`, String)
29-
.option("--loginkey", `Set the api key (for login into the ui)`, String)
30-
.option("-p --port", `Set the api url (for this request)`, validatePort, 8787)
31-
.action(async (ctx: Denomander) =>
32-
await serve({
33-
port: Number(ctx.port),
34-
sub: ctx.sub,
35-
vapidKey: ctx.vapidkey,
36-
cors: ctx.cors,
37-
frontend: ctx.frontend,
38-
sendkey: ctx.sendkey,
39-
loginkey: ctx.loginkey,
40-
}));
22+
.command('run', 'Run the server')
23+
.requiredOption("--vapidkey", `vapid key, you can use notify generate to generate a new one - warning a new key means that clients need to subscribe to it again!`)
24+
.requiredOption("--sub", `Set the vapid subscription information (email of the owner of the site)`, validateEmail)
25+
// .option("-s --store", `Store messages, so clients can request past messages that might be lost when device is not online for a long time.`, Boolean)
26+
.option("-c --cors", `Enable CORS`, Boolean)
27+
.option("-f --frontend", `if set the frontend will be served (this needs to point to the build directory of the frontend)`, undefined, './frontend/build')
28+
.option("--sendkey", `Set the api key (for sending a new request)`, String)
29+
.option("--loginkey", `Set the api key (for login into the ui)`, String)
30+
.option("-p --port", `Set the api url (for this request)`, validatePort, 8787)
31+
.action(async (ctx: Denomander) =>
32+
await serve({
33+
port: Number(ctx.port),
34+
sub: ctx.sub,
35+
vapidKey: ctx.vapidkey,
36+
cors: ctx.cors,
37+
frontend: ctx.frontend,
38+
sendkey: ctx.sendkey,
39+
loginkey: ctx.loginkey,
40+
}));
4141

4242

4343
program.
44-
command('generate', 'Generate a new vapid key')
45-
.action(async () => {
46-
const vapidKey = await generateVapidKey();
47-
console.log(vapidKey);
48-
});
44+
command('generate', 'Generate a new vapid key')
45+
.action(async () => {
46+
const vapidKey = await generateVapidKey();
47+
console.log(vapidKey);
48+
});
4949

5050
program.
51-
command('notify', 'Send a test notification to all clients')
52-
.requiredOption("-t --title", `Set the title of the notification`, String)
53-
.requiredOption("-m --message", `Set the body of the notification`, String)
54-
.option("-i --icon", `Set the icon of the notification`, String)
55-
.option("-t --tags", `Comma separated list of all tags`, String)
56-
.option("-r --remote", `Set the remote url of the notification`, String, 'http://localhost:8787')
57-
.option("-k --key", `Set the api key (for this request)`, String)
58-
.action(async (ctx: Denomander) => {
59-
await notify(ctx.remote, {
60-
title: ctx.title,
61-
message: ctx.message,
62-
iconUrl: ctx.icon,
63-
tags: ctx.tags ? ctx.tags.split(',') : [],
64-
}, ctx.key);
65-
console.log('Notification sent');
66-
});
51+
command('notify', 'Send a test notification to all clients')
52+
.requiredOption("-t --title", `Set the title of the notification`, String)
53+
.requiredOption("-m --message", `Set the body of the notification`, String)
54+
.option("-i --icon", `Set the icon of the notification`, String)
55+
.option("-t --tags", `Comma separated list of all tags`, String)
56+
.option("-r --remote", `Set the remote url of the notification`, String, 'http://localhost:8787')
57+
.option("-k --key", `Set the api key (for this request)`, String)
58+
.action(async (ctx: Denomander) => {
59+
await notify(ctx.remote, {
60+
title: ctx.title,
61+
message: ctx.message,
62+
iconUrl: ctx.icon,
63+
tags: ctx.tags ? ctx.tags.split(',') : [],
64+
}, ctx.key);
65+
console.log('Notification sent');
66+
});
6767

6868

6969
await program.parse(Deno.args);

0 commit comments

Comments
 (0)