mirror of
https://github.com/AtHeartEngineering/bandada.git
synced 2026-01-09 20:58:08 -05:00
chore: add postgres integration
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
import { Module } from "@nestjs/common"
|
||||
import { TypeOrmModule } from "@nestjs/typeorm"
|
||||
import "pg" // This is required for NX to include pg in api package.json during build
|
||||
import { AccountModule } from "./accounts/account.module"
|
||||
import { AuthModule } from "./auth/auth.module"
|
||||
import { GroupsModule } from "./groups/groups.module"
|
||||
import { InvitesModule } from "./invites/invites.module"
|
||||
|
||||
type DB_TYPE = 'mysql' | 'sqlite' | 'postgres';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
AuthModule,
|
||||
@@ -12,11 +15,13 @@ import { InvitesModule } from "./invites/invites.module"
|
||||
InvitesModule,
|
||||
GroupsModule,
|
||||
TypeOrmModule.forRoot({
|
||||
type: "sqlite",
|
||||
database: process.env.DB_NAME,
|
||||
type: process.env.DB_TYPE as DB_TYPE || 'postgres',
|
||||
url: process.env.DB_URL,
|
||||
...process.env.DB_TYPE === 'sqlite' && { database: process.env.DB_URL },
|
||||
autoLoadEntities: true,
|
||||
synchronize: process.env.NODE_ENV === "production" ? false : true
|
||||
})
|
||||
]
|
||||
})
|
||||
|
||||
export class AppModule {}
|
||||
|
||||
58
database/seed.sql
Normal file
58
database/seed.sql
Normal file
@@ -0,0 +1,58 @@
|
||||
-- Table Definition ----------------------------------------------
|
||||
|
||||
CREATE TABLE accounts (
|
||||
id SERIAL PRIMARY KEY,
|
||||
service text NOT NULL,
|
||||
"userId" character varying NOT NULL,
|
||||
"accessToken" character varying NOT NULL,
|
||||
"refreshToken" character varying,
|
||||
username character varying NOT NULL,
|
||||
"fullName" character varying,
|
||||
"avatarURL" character varying NOT NULL,
|
||||
"createdAt" timestamp without time zone NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
-- Indices -------------------------------------------------------
|
||||
|
||||
CREATE UNIQUE INDEX "PK_5a7a02c20412299d198e097a8fe" ON accounts(id int4_ops);
|
||||
CREATE UNIQUE INDEX "IDX_477e3187cedfb5a3ac121e899c" ON accounts(username text_ops);
|
||||
|
||||
|
||||
-- DDL generated by Postico 2.0 RC 6
|
||||
-- Not all database features are supported. Do not use for backup.
|
||||
|
||||
-- Table Definition ----------------------------------------------
|
||||
|
||||
CREATE TABLE groups (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name character varying NOT NULL,
|
||||
description character varying NOT NULL,
|
||||
admin character varying NOT NULL,
|
||||
"treeDepth" integer NOT NULL,
|
||||
members text NOT NULL,
|
||||
"createdAt" timestamp without time zone NOT NULL DEFAULT now(),
|
||||
tag integer NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
-- Indices -------------------------------------------------------
|
||||
|
||||
CREATE UNIQUE INDEX "PK_659d1483316afb28afd3a90646e" ON groups(id int4_ops);
|
||||
CREATE UNIQUE INDEX "IDX_664ea405ae2a10c264d582ee56" ON groups(name text_ops);
|
||||
|
||||
|
||||
-- DDL generated by Postico 2.0 RC 6
|
||||
-- Not all database features are supported. Do not use for backup.
|
||||
|
||||
-- Table Definition ----------------------------------------------
|
||||
|
||||
CREATE TABLE invites (
|
||||
id SERIAL PRIMARY KEY,
|
||||
code character varying NOT NULL,
|
||||
redeemed boolean NOT NULL DEFAULT false,
|
||||
"groupId" integer REFERENCES groups(id)
|
||||
);
|
||||
|
||||
-- Indices -------------------------------------------------------
|
||||
|
||||
CREATE UNIQUE INDEX "PK_aa52e96b44a714372f4dd31a0af" ON invites(id int4_ops);
|
||||
CREATE UNIQUE INDEX "IDX_33fd8a248db1cd832baa8aa25b" ON invites(code text_ops);
|
||||
@@ -1,52 +1,86 @@
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
api:
|
||||
container_name: api
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: ./apps/api/Dockerfile
|
||||
image: ${DOMAIN}-api:latest
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- DB_NAME="/home/node/api/zk-groups.db"
|
||||
volumes:
|
||||
- sqlite:/home/node/api/zk-groups.db
|
||||
ports:
|
||||
- "3333:3333"
|
||||
networks:
|
||||
- zk-groups
|
||||
postgres:
|
||||
container_name: postgres
|
||||
image: postgres
|
||||
environment:
|
||||
POSTGRES_USER: root
|
||||
POSTGRES_PASSWORD: helloworld
|
||||
POSTGRES_DB: zk-groups
|
||||
PGDATA: /data/postgres
|
||||
volumes:
|
||||
- postgres:/data/postgres
|
||||
- ./database/seed.sql:/docker-entrypoint-initdb.d/seed.sql
|
||||
ports:
|
||||
- "5432:5432"
|
||||
restart: unless-stopped
|
||||
command: postgres -c listen_addresses='*'
|
||||
networks:
|
||||
- zk-groups
|
||||
|
||||
client:
|
||||
container_name: client
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: ./apps/client/Dockerfile
|
||||
image: ${DOMAIN}-client:latest
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
ports:
|
||||
- "3002:80"
|
||||
networks:
|
||||
- zk-groups
|
||||
api:
|
||||
container_name: api
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: ./apps/api/Dockerfile
|
||||
image: ${DOMAIN}-api:latest
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- DB_TYPE=postgres
|
||||
- DB_URL=postgres://root:helloworld@postgres:5432/zk-groups
|
||||
- JWT_SECRET_KEY=zk_groups_jwt_secret
|
||||
- SESSION_SECRET=keyboard cat
|
||||
- GITHUB_CLIENT_ID=sample
|
||||
- GITHUB_CLIENT_SECRET=sample
|
||||
- TWITTER_CONSUMER_KEY=sample
|
||||
- TWITTER_CONSUMER_SECRET=sample
|
||||
- REDDIT_CLIENT_ID=sample
|
||||
- REDDIT_CLIENT_SECRET=sample
|
||||
- BACKEND_PRIVATE_KEY=
|
||||
- INFURA_API_KEY=
|
||||
- COINMARKETCAP_API_KEY=
|
||||
- ETHERSCAN_API_KEY=
|
||||
- ZKGROUPS_GOERLI_ADDRESS=
|
||||
ports:
|
||||
- "3000:3333"
|
||||
networks:
|
||||
- zk-groups
|
||||
depends_on:
|
||||
- postgres
|
||||
|
||||
dashboard:
|
||||
container_name: dashboard
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: ./apps/dashboard/Dockerfile
|
||||
image: ${DOMAIN}-dashboard:latest
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
ports:
|
||||
- "3001:80"
|
||||
networks:
|
||||
- zk-groups
|
||||
client:
|
||||
container_name: client
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: ./apps/client/Dockerfile
|
||||
image: ${DOMAIN}-client:latest
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
ports:
|
||||
- "3002:80"
|
||||
networks:
|
||||
- zk-groups
|
||||
depends_on:
|
||||
- api
|
||||
|
||||
dashboard:
|
||||
container_name: dashboard
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: ./apps/dashboard/Dockerfile
|
||||
image: ${DOMAIN}-dashboard:latest
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
ports:
|
||||
- "3001:80"
|
||||
networks:
|
||||
- zk-groups
|
||||
depends_on:
|
||||
- api
|
||||
|
||||
networks:
|
||||
zk-groups:
|
||||
@@ -54,4 +88,4 @@ networks:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
sqlite:
|
||||
postgres:
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
"passport-jwt": "^4.0.0",
|
||||
"passport-oauth2": "^1.6.1",
|
||||
"passport-twitter": "^1.0.4",
|
||||
"pg": "^8.8.0",
|
||||
"react": "18.1.0",
|
||||
"react-cookie": "^4.1.1",
|
||||
"react-dom": "18.1.0",
|
||||
|
||||
88
yarn.lock
88
yarn.lock
@@ -6075,6 +6075,11 @@ buffer-to-arraybuffer@^0.0.5:
|
||||
resolved "https://registry.yarnpkg.com/buffer-to-arraybuffer/-/buffer-to-arraybuffer-0.0.5.tgz#6064a40fa76eb43c723aba9ef8f6e1216d10511a"
|
||||
integrity sha512-3dthu5CYiVB1DEJp61FtApNnNndTckcqe4pFcLdvHtrpG+kcyekCJKg4MRiDcFW7A6AODnXB9U4dwQiCW5kzJQ==
|
||||
|
||||
buffer-writer@2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/buffer-writer/-/buffer-writer-2.0.0.tgz#ce7eb81a38f7829db09c873f2fbb792c0c98ec04"
|
||||
integrity sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw==
|
||||
|
||||
buffer-xor@^1.0.3:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9"
|
||||
@@ -13016,6 +13021,11 @@ p-try@^2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
|
||||
integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==
|
||||
|
||||
packet-reader@1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/packet-reader/-/packet-reader-1.0.0.tgz#9238e5480dedabacfe1fe3f2771063f164157d74"
|
||||
integrity sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ==
|
||||
|
||||
parent-module@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2"
|
||||
@@ -13243,6 +13253,57 @@ performance-now@^2.1.0:
|
||||
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
|
||||
integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=
|
||||
|
||||
pg-connection-string@^2.5.0:
|
||||
version "2.5.0"
|
||||
resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.5.0.tgz#538cadd0f7e603fc09a12590f3b8a452c2c0cf34"
|
||||
integrity sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ==
|
||||
|
||||
pg-int8@1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/pg-int8/-/pg-int8-1.0.1.tgz#943bd463bf5b71b4170115f80f8efc9a0c0eb78c"
|
||||
integrity sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==
|
||||
|
||||
pg-pool@^3.5.2:
|
||||
version "3.5.2"
|
||||
resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-3.5.2.tgz#ed1bed1fb8d79f1c6fd5fb1c99e990fbf9ddf178"
|
||||
integrity sha512-His3Fh17Z4eg7oANLob6ZvH8xIVen3phEZh2QuyrIl4dQSDVEabNducv6ysROKpDNPSD+12tONZVWfSgMvDD9w==
|
||||
|
||||
pg-protocol@^1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.5.0.tgz#b5dd452257314565e2d54ab3c132adc46565a6a0"
|
||||
integrity sha512-muRttij7H8TqRNu/DxrAJQITO4Ac7RmX3Klyr/9mJEOBeIpgnF8f9jAfRz5d3XwQZl5qBjF9gLsUtMPJE0vezQ==
|
||||
|
||||
pg-types@^2.1.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-2.2.0.tgz#2d0250d636454f7cfa3b6ae0382fdfa8063254a3"
|
||||
integrity sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==
|
||||
dependencies:
|
||||
pg-int8 "1.0.1"
|
||||
postgres-array "~2.0.0"
|
||||
postgres-bytea "~1.0.0"
|
||||
postgres-date "~1.0.4"
|
||||
postgres-interval "^1.1.0"
|
||||
|
||||
pg@^8.8.0:
|
||||
version "8.8.0"
|
||||
resolved "https://registry.yarnpkg.com/pg/-/pg-8.8.0.tgz#a77f41f9d9ede7009abfca54667c775a240da686"
|
||||
integrity sha512-UXYN0ziKj+AeNNP7VDMwrehpACThH7LUl/p8TDFpEUuSejCUIwGSfxpHsPvtM6/WXFy6SU4E5RG4IJV/TZAGjw==
|
||||
dependencies:
|
||||
buffer-writer "2.0.0"
|
||||
packet-reader "1.0.0"
|
||||
pg-connection-string "^2.5.0"
|
||||
pg-pool "^3.5.2"
|
||||
pg-protocol "^1.5.0"
|
||||
pg-types "^2.1.0"
|
||||
pgpass "1.x"
|
||||
|
||||
pgpass@1.x:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/pgpass/-/pgpass-1.0.5.tgz#9b873e4a564bb10fa7a7dbd55312728d422a223d"
|
||||
integrity sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==
|
||||
dependencies:
|
||||
split2 "^4.1.0"
|
||||
|
||||
picocolors@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c"
|
||||
@@ -13603,6 +13664,28 @@ postcss@^8.2.13, postcss@^8.3.5, postcss@^8.4.7:
|
||||
picocolors "^1.0.0"
|
||||
source-map-js "^1.0.2"
|
||||
|
||||
postgres-array@~2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/postgres-array/-/postgres-array-2.0.0.tgz#48f8fce054fbc69671999329b8834b772652d82e"
|
||||
integrity sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==
|
||||
|
||||
postgres-bytea@~1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/postgres-bytea/-/postgres-bytea-1.0.0.tgz#027b533c0aa890e26d172d47cf9ccecc521acd35"
|
||||
integrity sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==
|
||||
|
||||
postgres-date@~1.0.4:
|
||||
version "1.0.7"
|
||||
resolved "https://registry.yarnpkg.com/postgres-date/-/postgres-date-1.0.7.tgz#51bc086006005e5061c591cee727f2531bf641a8"
|
||||
integrity sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==
|
||||
|
||||
postgres-interval@^1.1.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/postgres-interval/-/postgres-interval-1.2.0.tgz#b460c82cb1587507788819a06aa0fffdb3544695"
|
||||
integrity sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==
|
||||
dependencies:
|
||||
xtend "^4.0.0"
|
||||
|
||||
prelude-ls@^1.2.1:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
|
||||
@@ -15105,6 +15188,11 @@ split2@^3.0.0:
|
||||
dependencies:
|
||||
readable-stream "^3.0.0"
|
||||
|
||||
split2@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/split2/-/split2-4.1.0.tgz#101907a24370f85bb782f08adaabe4e281ecf809"
|
||||
integrity sha512-VBiJxFkxiXRlUIeyMQi8s4hgvKCSjtknJv/LVYbrgALPwf5zSKmEwV9Lst25AkvMDnvxODugjdl6KZgwKM1WYQ==
|
||||
|
||||
sprintf-js@~1.0.2:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
|
||||
|
||||
Reference in New Issue
Block a user