Skip to content

Commit c712ce0

Browse files
committed
Create dev mode
- Minimal dev/hot-reload with vscode mode - Still WIP
1 parent 47c4cd3 commit c712ce0

File tree

13 files changed

+105
-15
lines changed

13 files changed

+105
-15
lines changed

.vscode/tasks.json

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
"dependsOn": [
1010
"npm: dev - packages/frontend",
1111
"npm: dev - packages/backend",
12+
"npm: dev - packages/interface",
1213
],
14+
"problemMatcher": [],
1315
},
1416
{
1517
"type": "npm",
1618
"script": "dev",
1719
"isBackground": true,
1820
"path": "packages/frontend",
19-
// See here https://stackoverflow.com/a/72655542/7346915
2021
"problemMatcher": [
2122
{
2223
"owner": "typescript",
@@ -25,8 +26,8 @@
2526
"applyTo": "allDocuments",
2627
"background": {
2728
"activeOnStart": true,
28-
// "beginsPattern": "sd",
29-
// "endsPattern": " > "
29+
"beginsPattern": "ready",
30+
"endsPattern": "ready",
3031
},
3132
"pattern": [
3233
{
@@ -50,10 +51,46 @@
5051
"type": "npm",
5152
"script": "dev",
5253
"isBackground": true,
54+
"dependsOn": ["compose: database"],
5355
"path": "packages/backend",
54-
"problemMatcher": ["$tsc-watch"],
56+
"problemMatcher": [
57+
{
58+
"owner": "typescript",
59+
"source": "ts",
60+
"applyTo": "allDocuments",
61+
"background": {
62+
"activeOnStart": true,
63+
"beginsPattern": ".*starting.*",
64+
"endsPattern": ".*running.*",
65+
},
66+
},
67+
],
5568
"label": "npm: dev - packages/backend",
56-
"detail": "tsc-watch --onSuccess 'node .'",
69+
},
70+
{
71+
"type": "npm",
72+
"script": "dev",
73+
"isBackground": true,
74+
"path": "packages/interface",
75+
"problemMatcher": ["$tsc-watch"],
76+
"label": "npm: dev - packages/interface",
77+
},
78+
{
79+
"type": "shell",
80+
"command": "docker",
81+
"args": [
82+
"compose",
83+
"-f",
84+
"compose.yaml",
85+
"-f",
86+
"compose.debug.yaml",
87+
"up",
88+
"db",
89+
"-d",
90+
],
91+
"isBackground": false,
92+
"problemMatcher": [],
93+
"label": "compose: database",
5794
},
5895
],
5996
}

README.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,58 @@
11
# Example
22

3+
In order do as follows
4+
5+
## Build
6+
7+
```bash
8+
npm run build -ws
9+
```
10+
11+
## Test
12+
13+
```bash
14+
npm run test -ws
15+
```
16+
17+
## Prepare database
18+
19+
```bash
20+
# at a separate terminal run this and keep running
21+
docker compose -f compose.yaml -f compose.debug.yaml up db
22+
# In a separate terminal
23+
npm run db:prepare -w backend
24+
```
25+
326
## Launch
427

28+
### *production mode*
29+
530
```bash
631
docker compose up
732
```
833

934
App will be accessible on port 8080
1035

11-
### Launch development environment
36+
### Hot-reload mode
1237

1338
In `vscode` use the task labeled `dev`.
1439

40+
In the terminal you want to open two terminals, opening a database and the development environment
41+
42+
```bash
43+
# Then keep this process running
44+
npm run dev
45+
```
46+
47+
Clean resources
48+
49+
```bash
50+
docker compose -f compose.yaml -f compose.debug.yaml down -v db
51+
npm run clean -ws --if-present
52+
```
53+
54+
Access `http://localhost:3000/tasks/debug/populate` to populate a few tasks
55+
1556
### Launch in debug mode
1657

1758
TODO, WIP

compose.debug.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ services:
77
POSTGRES_HOST_AUTH_METHOD: trust
88
ports:
99
- 5432:5432
10+
volumes:
11+
- db-debug:/var/lib/postgresql/data
12+
volumes:
13+
db-debug:

compose.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ services:
4848
volumes:
4949
- db-data:/var/lib/postgresql/data
5050
environment:
51-
- POSTGRES_DB=example
52-
- POSTGRES_PASSWORD_FILE=/run/secrets/db-password
51+
POSTGRES_DB: taskdb
52+
POSTGRES_PASSWORD_FILE: /run/secrets/db-password
5353
expose:
5454
- 5432
5555
healthcheck:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"packages/backend"
1919
],
2020
"scripts": {
21-
"dev": "concurrently -k -n backend,frontend -c magenta,blue \"npm run dev -w backend\" \"npm run dev -w frontend\"",
21+
"dev": "npm run build -ws --if-present && concurrently -k -n backend,frontend,interface -c magenta,blue,grey \"npm run dev -w backend\" \"npm run dev -w frontend\" \"npm run dev -w interface\"",
2222
"test": "npm run test -ws --if-present",
2323
"start:all": "echo REDO npm run build && node . serve",
2424
"watch": "echo REDO tsc-watch --onSuccess 'node .'",

packages/backend/.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PGPASSWORDFILE=../../db/password.txt
2+
DEBUG=*

packages/backend/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!.env

packages/backend/db/create.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.

packages/backend/nodemon.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
{
22
"watch": [
3-
"src"
3+
"src",
4+
".env",
5+
"../../interface/src"
46
],
7+
"env": {
8+
"NODE_OPTIONS": "--no-warnings=ExperimentalWarning"
9+
},
510
"ext": "ts",
611
"execMap": {
7-
"ts": "node --no-warnings=ExperimentalWarning --loader ts-node/esm"
12+
"ts": "node --loader ts-node/esm -r tsconfig-paths/register src/index.ts serve"
813
}
914
}

0 commit comments

Comments
 (0)