@storecraft/database-postgres 1.0.12 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -27,8 +27,6 @@ import { migrateToLatest } from '@storecraft/database-sql-base/migrate.js'
27
27
  const app = new App(
28
28
  {
29
29
  auth_admins_emails: ['admin@sc.com'],
30
- auth_secret_access_token: 'auth_secret_access_token',
31
- auth_secret_refresh_token: 'auth_secret_refresh_token'
32
30
  }
33
31
  )
34
32
  .withPlatform(new NodePlatform())
@@ -56,16 +54,31 @@ const server = http.createServer(app.handler).listen(
56
54
 
57
55
  ```
58
56
 
57
+ Storecraft will search the following `env` variables
58
+
59
+ ```bash
60
+ POSTGRES_USER='admin'
61
+ POSTGRES_PASSWORD='admin'
62
+ POSTGRES_PORT=6432
63
+ POSTGRES_HOST='localhost'
64
+ ```
65
+
66
+ So, you can instantiate with empty config
67
+ ```ts
68
+ .withDatabase(
69
+ new Postgres()
70
+ )
71
+ ```
72
+
73
+
59
74
  ## Testing Locally
60
75
 
61
- 1. First setup a `postgres` server
76
+ 1. First start a `postgres` server
77
+ First, make sure you have `docker` installed,
78
+ Then, run
62
79
 
63
- ```zsh
64
- docker pull postgres
65
- docker run --name some-postgres -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=admin \
66
- -e PGDATA=/var/lib/postgresql/data/pgdata \
67
- -v $(pwd):/var/lib/postgresql/data \
68
- -p 5432:5432 -d postgres
80
+ ```bash
81
+ npm run database-postgres:docker-compose-up
69
82
  ```
70
83
 
71
84
  2. create Environment
@@ -73,9 +86,9 @@ docker run --name some-postgres -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=admi
73
86
  create `.env` file with
74
87
 
75
88
  ```bash
76
- POSTGRES_USER='user'
77
- POSTGRES_PASSWORD='password'
78
- POSTGRES_PORT=5432
89
+ POSTGRES_USER='admin'
90
+ POSTGRES_PASSWORD='admin'
91
+ POSTGRES_PORT=6432
79
92
  POSTGRES_HOST='localhost'
80
93
  ```
81
94
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storecraft/database-postgres",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "Official Postgres Database driver for storecraft",
5
5
  "license": "MIT",
6
6
  "author": "Tomer Shalev (https://github.com/store-craft)",
@@ -29,6 +29,7 @@
29
29
  }
30
30
  },
31
31
  "scripts": {
32
+ "database-postgres:docker-compose-up": "docker compose -f ./tests/docker-compose.yml up -d ",
32
33
  "database-postgres:test": "node ./tests/runner.test.js",
33
34
  "test": "npm run database-postgres:test",
34
35
  "prepublishOnly": "npm version patch --force"
@@ -0,0 +1,23 @@
1
+ services:
2
+ db:
3
+ image: postgres
4
+ container_name: test-postgres
5
+ restart: always
6
+ extra_hosts:
7
+ - "host.docker.internal:host-gateway"
8
+ environment:
9
+ POSTGRES_USER: admin
10
+ POSTGRES_PASSWORD: admin
11
+ volumes:
12
+ - pgdata:/var/lib/postgresql/data
13
+ healthcheck:
14
+ test: ["CMD-SHELL", "pg_isready"]
15
+ interval: 1s
16
+ timeout: 5s
17
+ retries: 10
18
+ ports:
19
+ - 6432:5432
20
+
21
+
22
+ volumes:
23
+ pgdata:
@@ -11,7 +11,9 @@ export const create_app = async () => {
11
11
  {
12
12
  auth_admins_emails: ['admin@sc.com'],
13
13
  auth_secret_access_token: 'auth_secret_access_token',
14
- auth_secret_refresh_token: 'auth_secret_refresh_token'
14
+ auth_secret_refresh_token: 'auth_secret_refresh_token',
15
+ auth_secret_confirm_email_token: 'auth_secret_confirm_email_token',
16
+ auth_secret_forgot_password_token: 'auth_secret_forgot_password_token',
15
17
  }
16
18
  )
17
19
  .withPlatform(new NodePlatform())