Skip to content

Commit df9d5c0

Browse files
authored
Merge pull request #1 from codeday/dependency-update
Dependency update with testing capabilities and README documentation.
2 parents 9c580d8 + cdd7f6c commit df9d5c0

22 files changed

Lines changed: 1604 additions & 1572 deletions

.node-version

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

.nvmrc

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

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
FROM node:14-alpine
1+
FROM node:20-alpine3.18
22

33
ENV NODE_ENV=production
44
RUN mkdir /app
55
COPY yarn.lock /app
66
COPY package.json /app
77
WORKDIR /app
88

9+
RUN apk add --no-cache postgresql-client
910
RUN NODE_ENV=development yarn install
1011
COPY . /app
1112
RUN yarn run build
13+
RUN mkdir -p /app/dist
1214
COPY ./docker-entrypoint.sh /docker-entrypoint.sh
13-
CMD /docker-entrypoint.sh
15+
RUN chmod +x /docker-entrypoint.sh
16+
CMD ["/docker-entrypoint.sh"]

README.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Local Development and Full Test
2+
3+
This runbook gives you one reliable path to boot the stack and verify GraphQL flows end to end.
4+
5+
## 1) Runtime and install
6+
7+
```bash
8+
nvm use
9+
# or: asdf shell nodejs 20.19.6
10+
11+
yarn install
12+
```
13+
14+
Node version targets:
15+
- `.nvmrc`: `20.19.6`
16+
- `.node-version`: `20`
17+
18+
## 2) Start dependencies
19+
20+
Start PostgreSQL + Elasticsearch first:
21+
22+
```bash
23+
docker compose up -d postgres elasticsearch
24+
```
25+
26+
Check health:
27+
28+
```bash
29+
docker compose ps
30+
```
31+
32+
Both services should be `healthy` before launching the app.
33+
34+
## 3) App environment variables
35+
36+
Set these variables in your shell (or `.env`) before starting the app.
37+
38+
```bash
39+
export NODE_ENV=development
40+
export PORT=5000
41+
export DATABASE_URL='postgresql://advisors:advisors@localhost:55432/advisors?schema=public'
42+
export DISABLE_AUTOMATION=true
43+
44+
export AUTH_SECRET='local-dev-secret'
45+
export AUTH_AUDIENCE='event-test-2025'
46+
47+
export UPLOADER_BASE='http://localhost:3000'
48+
export UPLOADER_SECRET='local-dev-secret'
49+
export GOTENBERG_BASE='http://localhost:3001'
50+
51+
export EMAIL_HOST='localhost'
52+
export EMAIL_PORT='1025'
53+
export EMAIL_USER='local'
54+
export EMAIL_PASS='local'
55+
export EMAIL_FROM='local@example.com'
56+
57+
export TWILIO_ACCOUNT_SID='AC00000000000000000000000000000000'
58+
export TWILIO_AUTH_TOKEN='local-dev-secret'
59+
export TWILIO_PHONE='+15555555555'
60+
```
61+
62+
Notes:
63+
- `AUTH_SECRET` and `AUTH_AUDIENCE` must match what your local token/test scripts use.
64+
- `DATABASE_URL` should use `localhost:55432` when running the app outside Docker.
65+
66+
## 4) Build and start app
67+
68+
```bash
69+
yarn build
70+
yarn dev
71+
```
72+
73+
GraphQL endpoint:
74+
- `http://localhost:5000/graphql`
75+
76+
## 5) Seed test data
77+
78+
In another terminal:
79+
80+
```bash
81+
yarn seed-dummy
82+
```
83+
84+
This creates deterministic local test records, including:
85+
- advisor id `advisor-alice-test`
86+
- advisor id `advisor-bob-test`
87+
- request id `request-test-2025`
88+
89+
## 6) Run full local end-to-end test
90+
91+
With the app running, execute:
92+
93+
```bash
94+
yarn test-local
95+
```
96+
97+
This runs:
98+
1. `yarn seed-dummy`
99+
2. Public GraphQL query
100+
3. Admin-auth query (`submittedRequests`)
101+
4. Advisor-auth query (`getRequest`)
102+
5. Advisor mutation (`respondRequest`)
103+
6. Verification query (`getRequestAssignment`)
104+
105+
If all pass, your local backend path is working end to end.
106+
107+
## 7) Quick troubleshooting
108+
109+
- `Prisma` connection errors:
110+
- Confirm Postgres is healthy: `docker compose ps`
111+
- Re-check `DATABASE_URL` host/port (`localhost:55432` outside Docker)
112+
113+
- Auth errors (`Unauthorized`, audience/secret issues):
114+
- Re-check `AUTH_SECRET`
115+
- Re-check `AUTH_AUDIENCE`
116+
117+
- GraphQL upload typing/build issues:
118+
- Re-run `yarn install`
119+
- Re-run `yarn build`
120+
121+
- Seed/test query failures:
122+
- Ensure app is running on port `5000`
123+
- Re-run `yarn seed-dummy`

docker-compose.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
services:
2+
postgres:
3+
image: postgres:15-alpine
4+
ports:
5+
- "55432:5432"
6+
environment:
7+
POSTGRES_DB: advisors
8+
POSTGRES_USER: advisors
9+
POSTGRES_PASSWORD: advisors
10+
volumes:
11+
- postgres_data:/var/lib/postgresql/data
12+
healthcheck:
13+
test: ["CMD-SHELL", "pg_isready -U advisors -d advisors"]
14+
interval: 5s
15+
timeout: 5s
16+
retries: 20
17+
18+
elasticsearch:
19+
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.9
20+
ports:
21+
- "9200:9200"
22+
environment:
23+
discovery.type: single-node
24+
xpack.security.enabled: "false"
25+
ES_JAVA_OPTS: -Xms512m -Xmx512m
26+
volumes:
27+
- elasticsearch_data:/usr/share/elasticsearch/data
28+
healthcheck:
29+
test: ["CMD-SHELL", "curl -fs http://localhost:9200/_cluster/health >/dev/null"]
30+
interval: 10s
31+
timeout: 5s
32+
retries: 30
33+
34+
app:
35+
build: .
36+
ports:
37+
- "5000:5000"
38+
depends_on:
39+
postgres:
40+
condition: service_healthy
41+
elasticsearch:
42+
condition: service_healthy
43+
environment:
44+
NODE_ENV: development
45+
PORT: 5000
46+
DATABASE_URL: postgresql://advisors:advisors@postgres:5432/advisors?schema=public
47+
DISABLE_AUTOMATION: "true"
48+
AUTH_SECRET: local-dev-secret
49+
AUTH_AUDIENCE: event-test-2025
50+
UPLOADER_BASE: http://localhost:3000
51+
UPLOADER_SECRET: local-dev-secret
52+
GOTENBERG_BASE: http://localhost:3001
53+
EMAIL_HOST: localhost
54+
EMAIL_PORT: 1025
55+
EMAIL_USER: local
56+
EMAIL_PASS: local
57+
EMAIL_FROM: local@example.com
58+
TWILIO_ACCOUNT_SID: AC00000000000000000000000000000000
59+
TWILIO_AUTH_TOKEN: local-dev-secret
60+
TWILIO_PHONE: +15555555555
61+
healthcheck:
62+
test:
63+
[
64+
"CMD-SHELL",
65+
"node -e \"fetch('http://localhost:5000/graphql', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ query: '{__typename}' }) }).then((response) => process.exit(response.ok ? 0 : 1)).catch(() => process.exit(1))\"",
66+
]
67+
interval: 10s
68+
timeout: 5s
69+
retries: 30
70+
71+
volumes:
72+
postgres_data:
73+
elasticsearch_data:

package.json

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,20 @@
88
"start": "node dist",
99
"clean": "rm -rf dist",
1010
"prisma": "prisma format && prisma generate",
11-
"build": "npm -s run clean && yarn run prisma && tsc && cpy '**/*' '!**/*.ts' ../dist/ --cwd=src/ --no-overwrite --parents",
11+
"build": "yarn clean && yarn prisma && tsc && cp -r src/. dist/ && find dist -name '*.ts' -delete",
1212
"dev": "ts-node-dev --no-notify --respawn --exit-child --transpile-only src",
13-
"debug": "ts-node-dev --no-notify --respawn src"
13+
"debug": "ts-node-dev --no-notify --respawn src",
14+
"seed-dummy": "ts-node scripts/seedDummy.ts",
15+
"generate-token": "ts-node scripts/generateToken.ts",
16+
"test-queries": "ts-node scripts/testQueries.ts",
17+
"test-local": "yarn seed-dummy && ts-node scripts/fullLocalTest.ts"
1418
},
1519
"dependencies": {
1620
"@codeday/eslint-config-typescript": "^2.1.7",
1721
"@codeday/uploader-node": "^1.0.1",
18-
"@prisma/client": "^4.3.1",
22+
"@prisma/client": "^6.16.0",
1923
"@types/email-validator": "^1.0.6",
20-
"apollo-server": "^2.16.1",
21-
"apollo-server-express": "^2.16.1",
24+
"apollo-server-express": "^3.13.0",
2225
"class-validator": "^0.12.2",
2326
"dotenv": "^8.2.0",
2427
"email-validator": "^2.0.4",
@@ -27,7 +30,7 @@
2730
"front-matter": "^4.0.2",
2831
"graphql": "^15.3.0",
2932
"graphql-type-json": "^0.3.2",
30-
"graphql-upload": "^12.0.0",
33+
"graphql-upload": "^13.0.0",
3134
"handlebars": "^4.7.7",
3235
"html-entities": "^2.3.2",
3336
"ical-expander": "^3.0.0",
@@ -38,7 +41,7 @@
3841
"node-fetch": "^2.6.0",
3942
"nodemailer": "^6.6.2",
4043
"pdfkit": "^0.12.3",
41-
"prisma": "^4.3.1",
44+
"prisma": "^6.16.0",
4245
"reflect-metadata": "^0.1.13",
4346
"twilio": "^3.65.0",
4447
"type-graphql": "^1.0.0-rc.3",
@@ -54,10 +57,9 @@
5457
"@types/nodemailer": "^6.4.2",
5558
"@types/pdfkit": "^0.12.0",
5659
"@types/phone": "^2.4.1",
57-
"cpy-cli": "^3.1.1",
5860
"eslint": "^7.6.0",
59-
"ts-node": "^8.10.2",
61+
"ts-node": "^10.9.2",
6062
"ts-node-dev": "^1.0.0-pre.56",
61-
"typescript": "^4.3.4"
63+
"typescript": "^5.7.3"
6264
}
63-
}
65+
}

prisma/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ model RequestAssignment {
6262
requestId String
6363
6464
responseFile String?
65-
response Json?
65+
response Json?
6666
6767
@@id([advisorId, requestId])
6868
}

0 commit comments

Comments
 (0)