-
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
chukwuka-emi
committed
Sep 13, 2023
0 parents
commit 25e9338
Showing
54 changed files
with
11,905 additions
and
0 deletions.
There are no files selected for viewing
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,2 @@ | ||
~/.env | ||
~/node_modules |
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,3 @@ | ||
node_modules | ||
.env | ||
build |
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,5 @@ | ||
GENERATE MIGRATION - example | ||
npx typeorm migration:generate src/migration/AddedNewTables -d build/ormconfig.js | ||
|
||
RUN MIGRATION - example | ||
npx typeorm migration:run -d build/ormconfig.js |
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,35 @@ | ||
import { DataSource } from "typeorm"; | ||
import { config } from "dotenv"; | ||
import { User } from "./src/Entities/User"; | ||
import { Topic } from "./src/Entities/Topic"; | ||
import { Subscription } from "./src/Entities/Subscription"; | ||
|
||
config(); | ||
|
||
// const { PGHOST, PGDATABASE, PGUSER, PGPASSWORD, ENDPOINT_ID } = process.env; | ||
// const databaseUrl = `postgres://${PGUSER}:${PGPASSWORD}@${PGHOST}/${PGDATABASE}?options=project%3D${ENDPOINT_ID}`; | ||
|
||
const dataSource = new DataSource({ | ||
type: "postgres", | ||
url: process.env.DATABASE_URL, | ||
// url: databaseUrl, | ||
synchronize: false, | ||
logging: true, | ||
migrationsRun: false, | ||
entities: [User, Topic, Subscription], | ||
migrations: ["build/src/migration/*.js"], | ||
ssl: { | ||
rejectUnauthorized: false, | ||
}, | ||
}); | ||
|
||
if (!dataSource.isInitialized) { | ||
dataSource | ||
.initialize() | ||
.then(() => console.log(`Database connected.`)) | ||
.catch((err) => | ||
console.log(`Error initializing database connection : ${err}`) | ||
); | ||
} | ||
|
||
export default dataSource; |
Oops, something went wrong.