Skip to content

Commit

Permalink
Merge pull request #544 from Ulisseus/dbload/main
Browse files Browse the repository at this point in the history
Closes #551, #550 - add DB_PORT variable
  • Loading branch information
anthonykhoa committed Mar 15, 2021
2 parents 2aa7057 + 7cdb66d commit dc53cb4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 55 deletions.
34 changes: 0 additions & 34 deletions helpers/dbload.test.js

This file was deleted.

38 changes: 17 additions & 21 deletions helpers/dbload.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Options, Sequelize } from 'sequelize'
import { Sequelize } from 'sequelize'
import { Lesson, LessonTypes } from './models/Lesson'
import { User, UserTypes } from './models/User'
import { UserLessonTypes, UserLesson } from './models/UserLesson'
Expand All @@ -7,26 +7,22 @@ import { ChallengeTypes, Challenge } from './models/Challenge'
import { AlertTypes, Alert } from './models/Alert'
import { StarTypes, Star } from './models/Star'

const options: Options = {
host: process.env.DB_HOST || 'city',
logging: false,
dialect: 'postgres',
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
}
}

if (process.env.NODE_ENV != 'production') {
options.port = ((process.env.DB_PORT as unknown) as number) || 5432
}
const sequelize = new Sequelize(
process.env.DB_NAME || 'you',
process.env.DB_USER || 'failed',
process.env.DB_PW || 'this',
options
process.env.DB_NAME as string,
process.env.DB_USER as string,
process.env.DB_PW,
{
host: process.env.DB_HOST,
logging: false,
port: parseInt(process.env.DB_PORT as string),
dialect: 'postgres',
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
}
}
)

Alert.init(AlertTypes, {
Expand Down Expand Up @@ -113,4 +109,4 @@ export default {
sequelize
}

export { User, UserLesson, options }
export { User, UserLesson }
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = withSass({
DB_NAME: process.env.DB_NAME || 'c0d3dev6',
DB_USER: process.env.DB_USER || 'c0d3db',
DB_PW: process.env.DB_PW || 'letmein2',
DB_PORT: process.env.DB_PORT || '5432',
DB_HOST: process.env.DB_HOST || 'freedomains.dev',
MAILGUN_API_KEY: process.env.MAILGUN_API_KEY,
MAILGUN_DOMAIN: process.env.MAILGUN_DOMAIN,
Expand Down

1 comment on commit dc53cb4

@vercel
Copy link

@vercel vercel bot commented on dc53cb4 Mar 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.