Skip to content

Commit

Permalink
Frontend package updates (#172)
Browse files Browse the repository at this point in the history
* Update package-lock.json

* Update deno deps

* Update readme and docs

* Fix docker file

* Fix relative path in docker copy

* Fix frontend settings

* Add check for production mode that frontend settings do not throw erros.
  • Loading branch information
K0IN authored Jun 23, 2024
1 parent ce9c630 commit 98b02c4
Show file tree
Hide file tree
Showing 8 changed files with 2,589 additions and 2,339 deletions.
76 changes: 38 additions & 38 deletions app/backend/deno.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
{
"imports": {
"std/": "https://deno.land/std@0.194.0/",
"oak": "https://deno.land/x/oak@v12.6.0/mod.ts",
"oak_logger": "https://deno.land/x/oak_logger@1.0.0/mod.ts",
"cors": "https://deno.land/x/cors@v1.2.2/mod.ts",
"zod": "https://deno.land/x/zod@v3.20.0/mod.ts",
"denomander": "https://deno.land/x/denomander@0.9.3/mod.ts"
},
"tasks": {
"dev": "deno run --watch main.ts"
},
"fmt": {
"useTabs": false,
"lineWidth": 80,
"indentWidth": 4,
"semiColons": true,
"singleQuote": false,
"proseWrap": "preserve",
"include": [
"./**/*.ts"
],
"exclude": []
},
"lint": {
"include": [
"./**/*.ts"
],
"exclude": [],
"rules": {
"tags": [
"recommended"
],
"include": [],
"exclude": [
"ban-untagged-todo",
"import-prefix-missing"
]
}
"imports": {
"std/": "https://deno.land/std@0.218.0/",
"oak": "https://deno.land/x/oak@v12.6.2/mod.ts",
"oak_logger": "https://deno.land/x/oak_logger@1.0.0/mod.ts",
"cors": "https://deno.land/x/cors@v1.2.2/mod.ts",
"zod": "https://deno.land/x/zod@v3.22.4/mod.ts",
"denomander": "https://deno.land/x/denomander@0.9.3/mod.ts"
},
"tasks": {
"dev": "deno run --watch main.ts"
},
"fmt": {
"useTabs": false,
"lineWidth": 80,
"indentWidth": 4,
"semiColons": true,
"singleQuote": false,
"proseWrap": "preserve",
"include": [
"./**/*.ts"
],
"exclude": []
},
"lint": {
"include": [
"./**/*.ts"
],
"exclude": [],
"rules": {
"tags": [
"recommended"
],
"include": [],
"exclude": [
"ban-untagged-todo",
"import-prefix-missing"
]
}
}
}
434 changes: 283 additions & 151 deletions app/backend/deno.lock

Large diffs are not rendered by default.

4,373 changes: 2,226 additions & 2,147 deletions app/frontend/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/frontend/src/staticsettings.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const DBNAME = 'notify-db';
export const DBVERSION = 1;
// if you want to run the gui separate from the api, change this to to your api location example: "http://localhost:8787/api"
export const APIBASE = process ? process?.env?.PREACT_APP_BACKEND_URL ?? "/api" : "/api";
export const APIBASE = (typeof process !== 'undefined') ? process?.env?.PREACT_APP_BACKEND_URL ?? "/api" : "/api";
6 changes: 6 additions & 0 deletions doc/baremetal.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ deno run --allow-net --allow-read --allow-write --unstable ./deploy/main.ts run
deno run --allow-net --allow-read --allow-write --unstable ./deploy/main.ts generate
```

or if you do not want to checkout this repository you can use the following command:

```bash
deno run -A --unstable --import-map https://raw.githubusercontent.com/K0IN/Notify/deno-port/app/backend/deno.json https://raw.githubusercontent.com/K0IN/Notify/deno-port/app/backend/main.ts generate
```

### Send a notification (using the cli)

* `--remote` Set the remote url of the notification
Expand Down
23 changes: 23 additions & 0 deletions doc/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,26 @@ Hint: If you are really lazy we provide precompiled deploy packages in the branc
3. Create a deploy folder `mkdir deploy`
4. Copy the backend into a new folder `cp -r ./app/backend/* deploy`
5. Copy the frontend build into the backend folder `cp -r ./app/frontend/build ./deploy/static-site`

## Set the following environment variables in the webui

| Name | Description | Default |
| --- | --- | --- |
| PORT | Port to listen | 8787 |
| VAPID_KEY | Vapid key for the app, [see generate](#generate-vapid-key) | undefined |
| SUB | Admin email in format "mailto:aa@bbb.ccc" | undefined |
| CORS | Enable cors, if your frontend is served on a different domain | false |
| SENDKEY | Key to send notifications | undefined |
| LOGINKEY | Key to login to the ui | undefined |

### Generate Vapid key

```bash
deno run --allow-net --allow-read --allow-write --unstable ./deploy/main.ts generate
```

or if you do not want to checkout this repository you can use the following command:

```bash
deno run -A --unstable --import-map https://raw.githubusercontent.com/K0IN/Notify/deno-port/app/backend/deno.json https://raw.githubusercontent.com/K0IN/Notify/deno-port/app/backend/main.ts generate
```
2 changes: 1 addition & 1 deletion dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:alpine AS frontend_builder
WORKDIR /usr/src
COPY app/frontend app
COPY app/frontend /usr/src/app
WORKDIR /usr/src/app
RUN npm install
RUN npm run build
Expand Down
12 changes: 11 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,19 @@ I know this looks scary on first glance but i swear it makes sense.
2. Start the docker (fill in the vapid key from step 1.) `docker run -p 8787:8787 -e VAPID_KEY=<vapidkey> -e SUB=mailto:admin@admin.com -e SENDKEY=mypassword ghcr.io/k0in/notify:latest`
3. Start sending notifications
`curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer mypassword" -d '{"title":"Hello", "message":"World"}' http://localhost:8787/api/notify`
or use our cli

by the way, you can also use the deno cli to send notifications

`deno run --allow-net --unstable --import-map https://raw.githubusercontent.com/K0IN/Notify/main/app/backend/deno.json https://raw.githubusercontent.com/K0IN/Notify/main/app/backend/main.ts notify -r http://localhost:8787/api/notify -t test -m world --key mypassword`

(which can be build into a single binary)

```bash
deno compile --allow-net --unstable --import-map https://raw.githubusercontent.com/K0IN/Notify/main/app/backend/deno.json --output notify https://raw.githubusercontent.com/K0IN/Notify/main/app/backend/main.ts

./notify notify -r http://localhost:8787/api/notify -t test -m world --key mypassword
```

## Need Help? 🤔

- Refer to our great [documentation](doc/install.md)
Expand Down

0 comments on commit 98b02c4

Please sign in to comment.