-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9254510
commit 2d9123d
Showing
23 changed files
with
2,803 additions
and
5,200 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,32 +44,20 @@ services: | |
cms: | ||
image: ghcr.io/yes-theory-fam/yestheory-family-cms:COMMIT_HASH | ||
environment: | ||
MONGODB_URI: mongodb://mongo/cms | ||
DATABASE_URI: "postgresql://ytfe2e:ytfe2e@postgres:5432/payload?schema=public" | ||
ENABLE_DATASEEDER: "true" | ||
PAYLOAD_SECRET: asdfghjkl | ||
INITIAL_ADMIN_MAIL: [email protected] | ||
INITIAL_ADMIN_PASSWORD: example | ||
MONGO_USERNAME: ytfe2e | ||
MONGO_PASSWORD: ytfe2e | ||
TYPESENSE_API_KEY: 1234567890 | ||
TYPESENSE_API_URL: http://typesense:8108 | ||
SERVER_URL: http://localhost:3001 | ||
FRONTEND_URL: http://localhost:3000 | ||
ports: | ||
- "3001:3001" | ||
depends_on: | ||
- mongo | ||
- typesense | ||
|
||
mongo: | ||
image: mongo:6.0.5 | ||
restart: unless-stopped | ||
environment: | ||
MONGO_INITDB_ROOT_USERNAME: ytfe2e | ||
MONGO_INITDB_ROOT_PASSWORD: ytfe2e | ||
ports: | ||
- "27017:27017" | ||
|
||
typesense: | ||
image: typesense/typesense:0.25.1 | ||
restart: unless-stopped | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
PAYLOAD_SECRET=asdfghjkl | ||
MONGODB_URI=mongodb://localhost:27017/payload-12345 | ||
DATABASE_URI=postgres://username:password@localhost:5433/payload | ||
|
||
TYPESENSE_API_URL=http://localhost:8108 | ||
TYPESENSE_API_KEY=1234567890 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,18 @@ | ||
import { config } from "dotenv"; | ||
import payload from "payload"; | ||
import { type InitOptions } from "payload/config"; | ||
import { ensureDbExists } from "./utils/ensure-db-exists"; | ||
|
||
export const initPayload = async (additionalOptions?: Partial<InitOptions>) => { | ||
config(); | ||
|
||
if (!process.env.PAYLOAD_SECRET) throw new Error("Missing PAYLOAD_SECRET"); | ||
if (!process.env.MONGODB_URI) throw new Error("Missing MONGODB_URI"); | ||
console.info("Ensuring database exists"); | ||
await ensureDbExists(); | ||
|
||
const mongoOptions = process.env.MONGO_PASSWORD | ||
? { | ||
authSource: "admin", | ||
user: process.env.MONGO_USERNAME, | ||
pass: process.env.MONGO_PASSWORD, | ||
} | ||
: undefined; | ||
if (!process.env.PAYLOAD_SECRET) throw new Error("Missing PAYLOAD_SECRET"); | ||
|
||
return await payload.init({ | ||
secret: process.env.PAYLOAD_SECRET, | ||
mongoURL: process.env.MONGODB_URI, | ||
mongoOptions, | ||
...additionalOptions, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { parse } from "pg-connection-string"; | ||
import { Client } from "pg"; | ||
|
||
export const ensureDbExists = async () => { | ||
const uri = process.env.DATABASE_URI; | ||
const { database, user, password, host, port } = parse(uri); | ||
|
||
const postgresUri = `postgres://${user}:${password}@${host}:${port}/postgres`; | ||
const client = new Client(postgresUri); | ||
|
||
await client.connect(); | ||
const existingDatabase = await client.query( | ||
`SELECT FROM pg_database WHERE datname = $1`, | ||
[database], | ||
); | ||
if (existingDatabase.rowCount == 0) { | ||
console.info(`Database ${database} not found! Creating new database!`); | ||
await client.query(`CREATE DATABASE ${database}`); | ||
console.info(`Database ${database} created!`); | ||
} | ||
|
||
await client.end(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.