Skip to content

Commit 3dceeef

Browse files
committed
Changed event store to PostgreSQL
1 parent c7ba62d commit 3dceeef

File tree

8 files changed

+726
-991
lines changed

8 files changed

+726
-991
lines changed

.github/workflows/build_and_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and test Sample - WebApi with Express.js and EventStoreDB
1+
name: Build and test Sample - WebApi with Express.js and PostgreSQL
22

33
on:
44
# run it on push to the default repository branch

.http

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,45 @@
1-
@clientId = dummy
2-
@productId = dummy
3-
@unitPrice = 100
1+
@guestId = dummy
2+
@roomId = dummy
43

5-
### Add Product
4+
### Check In
65

7-
POST http://localhost:3000/clients/{{clientId}}/shopping-carts/current/product-items HTTP/1.1
6+
# @name checkin
7+
POST http://localhost:3000/guests/{{guestId}}/stays/{{roomId}} HTTP/1.1
88
content-type: application/json
99

10-
{
11-
"productId": "{{productId}}",
12-
"quantity": 10
13-
}
10+
### No body passed
11+
12+
### Capture and parse the Location header
13+
@location = {{checkin.response.headers.Location}}
1414

1515
### Get State
1616

17-
GET http://localhost:3000/clients/{{clientId}}/shopping-carts/current HTTP/1.1
17+
GET http://localhost:3000{{location}} HTTP/1.1
1818
content-type: application/json
1919

20+
### Record Charge
2021

21-
### Remove Product
22+
@amount = 10
2223

23-
@quantity = 1
24-
25-
DELETE http://localhost:3000/clients/{{clientId}}/shopping-carts/current/product-items?productId={{productId}}&quantity={{quantity}}&unitPrice={{unitPrice}} HTTP/1.1
24+
POST http://localhost:3000{{location}}/charges HTTP/1.1
2625
content-type: application/json
2726

28-
### CONFIRM
27+
{
28+
"amount": {{amount}}
29+
}
30+
31+
### Record Payment
32+
33+
@amount = 10
2934

30-
POST http://localhost:3000/clients/{{clientId}}/shopping-carts/current/confirm HTTP/1.1
35+
POST http://localhost:3000{{location}}/payments HTTP/1.1
3136
content-type: application/json
3237

38+
{
39+
"amount": {{amount}}
40+
}
3341

34-
### Cancel
42+
### Checkout
3543

36-
POST http://localhost:3000/clients/{{clientId}}/shopping-carts/current HTTP/1.1
44+
DELETE http://localhost:3000{{location}} HTTP/1.1
3745
content-type: application/json

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![](./docs/public/logo.png)
44

5-
# Emmett - template showing event-sourced WebApi with Express.js and EventStoreDB
5+
# Emmett - template showing event-sourced WebApi with Express.js and PostgreSQL
66

77
Read more in [Emmett getting started guide](https://event-driven-io.github.io/emmett/getting-started.html).
88

@@ -16,7 +16,7 @@ npm install
1616

1717
## Running
1818

19-
Sample require EventStoreDB, you can start it by running
19+
Sample require PostgreSQL, you can start it by running
2020

2121
```bash
2222
docker-compose up

docker-compose.yml

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,49 @@ services:
99
container_name: emmett_api
1010
profiles: [app]
1111
environment:
12-
- ESDB_CONNECTION_STRING=esdb://eventstoredb:2113?tls=false
12+
- POSTGRESQL_CONNECTION_STRING=postgresql://postgres:postgres@postgres:5432/postgres
1313
networks:
14-
- esdb_network
14+
- postgresql_network
1515
ports:
1616
- '3000:3000'
1717

1818
#######################################################
19-
# EventStoreDB
19+
# PostgreSQL
2020
#######################################################
21-
eventstoredb:
22-
image: eventstore/eventstore:23.10.0-bookworm-slim
23-
# use this image if you're running ARM-based proc like Apple M1
24-
# image: eventstore/eventstore:23.10.0-alpha-arm64v8
25-
container_name: eventstoredb
21+
postgres:
22+
image: postgres:15.1-alpine
23+
ports:
24+
- '5432:5432'
25+
environment:
26+
- POSTGRES_DB=postgres
27+
- POSTGRES_PASSWORD=postgres
28+
- POSTGRES_USER=postgres
29+
networks:
30+
- postgresql_network
31+
32+
pgadmin:
33+
container_name: pgadmin_container
34+
image: dpage/pgadmin4
2635
environment:
27-
- EVENTSTORE_CLUSTER_SIZE=1
28-
- EVENTSTORE_RUN_PROJECTIONS=All
29-
- EVENTSTORE_START_STANDARD_PROJECTIONS=true
30-
- EVENTSTORE_EXT_TCP_PORT=1113
31-
- EVENTSTORE_HTTP_PORT=2113
32-
- EVENTSTORE_INSECURE=true
33-
- EVENTSTORE_ENABLE_EXTERNAL_TCP=true
34-
- EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP=true
36+
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org}
37+
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD:-postgres}
38+
- PGADMIN_CONFIG_SERVER_MODE=False
39+
- PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED=False
3540
ports:
36-
- '1113:1113'
37-
- '2113:2113'
41+
- '${PGADMIN_PORT:-5050}:80'
42+
entrypoint: /bin/sh -c "chmod 600 /pgpass; /entrypoint.sh;"
43+
user: root
3844
volumes:
39-
- type: volume
40-
source: eventstore-volume-data
41-
target: /var/lib/eventstore
42-
- type: volume
43-
source: eventstore-volume-logs
44-
target: /var/log/eventstore
45+
- ./docker/pgAdmin/pgpass:/pgpass
46+
- ./docker/pgAdmin/servers.json:/pgadmin4/servers.json
47+
depends_on:
48+
- postgres
49+
restart: unless-stopped
4550
networks:
46-
- esdb_network
51+
- postgresql_network
4752

4853
networks:
49-
esdb_network:
54+
postgresql_network:
5055
driver: bridge
5156

5257
volumes:

0 commit comments

Comments
 (0)