Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ backend/src/
loaders.ts DataLoader batching
wine-query.ts builds the SQL for search, filtering and sorting
auth/ user accounts, passwords and sessions
scripts/ import of X-Wines
scripts/ import of X-Wines, the demo user, and cleanup of test users
backend/migrations/ database migrations (node-pg-migrate)
```

Expand Down
12 changes: 0 additions & 12 deletions backend/db.js

This file was deleted.

112 changes: 0 additions & 112 deletions backend/src/scripts/wine-stats.st

This file was deleted.

13 changes: 3 additions & 10 deletions backend/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,11 @@ async function main() {
const createContext = createContextFactory(createAuthService(createPgUserStore(pool)));
await apollo.start();

// Database check, same as before: shows that the backend can reach PostgreSQL.
// Health check: says only whether the backend can reach the database.
app.get('/', async (_req, res) => {
try {
const { rows } = await pool.query(
'SELECT current_database() AS database, current_user AS username, now() AS time',
);
const info = rows[0];
res
.type('text')
.send(
`Hello from PostgreSQL!\nDatabase: ${info.database}\nUser: ${info.username}\nServer time: ${info.time.toISOString()}\n`,
);
await pool.query('SELECT 1');
res.type('text').send('OK\n');
} catch (error) {
console.error('Database query failed:', error instanceof Error ? error.message : error);
res.status(503).type('text').send('Database unavailable\n');
Expand Down
3 changes: 1 addition & 2 deletions docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ npm run dev
```

Open the frontend at [localhost:5173](http://localhost:5173/).
Open [localhost:3001](http://localhost:3001/) to check the backend's database connection.
Open [localhost:3001](http://localhost:3001/) to check the backend. It answers `OK` when it can reach the database, and HTTP 503 when it cannot.
Open [localhost:3001/graphql](http://localhost:3001/graphql) to try GraphQL queries.
It shows the database name, user, and server time. A failed query returns HTTP 503.
The frontend requests `/graphql`. Vite forwards that request to the backend during local development.

To update an existing checkout, stop the development servers and run these commands from the project folder:
Expand Down
12 changes: 4 additions & 8 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Frontend

The page displays the greeting returned by the backend after querying PostgreSQL.
The React app for Kork & Krone. See the [main README](../README.md) for what it does and how it is built.

Start PostgreSQL and the backend using the [setup guide](../docs/setup.md).
Then, from `frontend/`, run:
Expand All @@ -10,13 +10,9 @@ npm ci
npm run dev
```

Open the local URL printed by Vite. Vite proxies `/api/hello` to the backend at
`http://localhost:3001/`. The page shows a loading message while fetching and an
error message if the request fails.

For production hosting, configure the web server to forward `/api/hello` to the
backend's `/` endpoint as well.
Open the local URL printed by Vite. Vite forwards `/project2/graphql` to the backend at
`http://localhost:3001/graphql`.

To build and publish on the VM, run `./scripts/deploy.sh` from the repository root on the VM.
It builds for `/project2/` and uses `sudo` to copy the output into `/var/www/html/project2`.
See the [VM guide](../docs/vm.md).
See the [VM guide](../docs/vm.md).
4 changes: 0 additions & 4 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ export default defineConfig({
plugins: [react(), babel({ presets: [reactCompilerPreset()] })],
server: {
proxy: {
'/api/hello': {
target: backend,
rewrite: () => '/',
},
// BASE_URL is part of the path, so the frontend calls /project2/graphql.
'/project2/graphql': {
target: backend,
Expand Down
5 changes: 0 additions & 5 deletions scripts/.env.example

This file was deleted.

63 changes: 0 additions & 63 deletions scripts/README.md

This file was deleted.

Loading