Configure posgres DB

This commit is contained in:
KS Jannette
2026-05-18 18:16:14 -04:00
parent cbb76fd72d
commit f32c6d55f0
4 changed files with 6 additions and 41 deletions

View File

@@ -1,3 +1,3 @@
DATABASE_URL=postgres://app:app@localhost:5432/app
DATABASE_URL=postgres://localhost:5432/generic_typescript_server
PORT=3000
DEBUG=

View File

@@ -7,30 +7,11 @@ Express + TypeScript REST API with PostgreSQL.
```bash
cp .env.example .env
npm install
```
## Database
Start Postgres:
```bash
npm run db:up
```
Run migrations:
```bash
createdb generic_typescript_server # one-time, uses your local Postgres user
npm run db:migrate
```
Stop Postgres:
```bash
npm run db:down
```
## Dev server
```bash
npm run dev
```
Requires a local Postgres install (e.g. `brew install postgresql@16 && brew services start postgresql@16`).
Update `DATABASE_URL` in `.env` if your user, host, or database name differs.

View File

@@ -1,14 +0,0 @@
services:
postgres:
image: postgres:16
ports:
- "5432:5432"
environment:
POSTGRES_USER: app
POSTGRES_PASSWORD: app
POSTGRES_DB: app
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata:

View File

@@ -6,8 +6,6 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "tsx src/index.ts",
"db:up": "docker compose up -d",
"db:down": "docker compose down",
"db:migrate": "tsx scripts/migrate.ts"
},
"keywords": [],