Configure posgres DB
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
DATABASE_URL=postgres://app:app@localhost:5432/app
|
||||
DATABASE_URL=postgres://localhost:5432/generic_typescript_server
|
||||
PORT=3000
|
||||
DEBUG=
|
||||
|
||||
29
README.md
29
README.md
@@ -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.
|
||||
|
||||
@@ -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:
|
||||
@@ -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": [],
|
||||
|
||||
Reference in New Issue
Block a user