-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Thinkful-Ed/update-dependencies
update dependencies
- Loading branch information
Showing
6 changed files
with
3,752 additions
and
2,372 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 |
---|---|---|
@@ -1,14 +1,16 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
PORT: process.env.PORT || 8080, | ||
CLIENT_ORIGIN: process.env.CLIENT_ORIGIN || 'http://localhost:3000', | ||
DATABASE_URL: | ||
PORT: process.env.PORT || 8080, | ||
CLIENT_ORIGIN: process.env.CLIENT_ORIGIN || 'http://localhost:3000', | ||
DATABASE_URL: | ||
process.env.DATABASE_URL || 'mongodb://localhost/thinkful-backend', | ||
TEST_DATABASE_URL: | ||
TEST_DATABASE_URL: | ||
process.env.TEST_DATABASE_URL || | ||
'mongodb://localhost/thinkful-backend-test' | ||
// DATABASE_URL: | ||
// process.env.DATABASE_URL || 'postgres://localhost/thinkful-backend', | ||
// TEST_DATABASE_URL: | ||
// process.env.TEST_DATABASE_URL || | ||
// 'postgres://localhost/thinkful-backend-test' | ||
// DATABASE_URL: | ||
// process.env.DATABASE_URL || 'postgres://localhost/thinkful-backend', | ||
// TEST_DATABASE_URL: | ||
// process.env.TEST_DATABASE_URL || | ||
// 'postgres://localhost/thinkful-backend-test' | ||
}; |
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,26 +1,28 @@ | ||
'use strict'; | ||
|
||
const createKnex = require('knex'); | ||
|
||
const {DATABASE_URL} = require('./config'); | ||
|
||
let knex = null; | ||
|
||
function dbConnect(url = DATABASE_URL) { | ||
knex = createKnex({ | ||
client: 'pg', | ||
connection: url | ||
}); | ||
knex = createKnex({ | ||
client: 'pg', | ||
connection: url | ||
}); | ||
} | ||
|
||
function dbDisconnect() { | ||
return knex.destroy(); | ||
return knex.destroy(); | ||
} | ||
|
||
function dbGet() { | ||
return knex; | ||
return knex; | ||
} | ||
|
||
module.exports = { | ||
dbConnect, | ||
dbDisconnect, | ||
dbGet | ||
dbConnect, | ||
dbDisconnect, | ||
dbGet | ||
}; |
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,39 +1,41 @@ | ||
'use strict'; | ||
|
||
const express = require('express'); | ||
const cors = require('cors'); | ||
const morgan = require('morgan'); | ||
|
||
const {PORT, CLIENT_ORIGIN} = require('./config'); | ||
const {dbConnect} = require('./db-mongoose'); | ||
const { PORT, CLIENT_ORIGIN } = require('./config'); | ||
const { dbConnect } = require('./db-mongoose'); | ||
// const {dbConnect} = require('./db-knex'); | ||
|
||
const app = express(); | ||
|
||
app.use( | ||
morgan(process.env.NODE_ENV === 'production' ? 'common' : 'dev', { | ||
skip: (req, res) => process.env.NODE_ENV === 'test' | ||
}) | ||
morgan(process.env.NODE_ENV === 'production' ? 'common' : 'dev', { | ||
skip: (req, res) => process.env.NODE_ENV === 'test' | ||
}) | ||
); | ||
|
||
app.use( | ||
cors({ | ||
origin: CLIENT_ORIGIN | ||
}) | ||
cors({ | ||
origin: CLIENT_ORIGIN | ||
}) | ||
); | ||
|
||
function runServer(port = PORT) { | ||
const server = app | ||
.listen(port, () => { | ||
console.info(`App listening on port ${server.address().port}`); | ||
}) | ||
.on('error', err => { | ||
console.error('Express failed to start'); | ||
console.error(err); | ||
}); | ||
const server = app | ||
.listen(port, () => { | ||
console.info(`App listening on port ${server.address().port}`); | ||
}) | ||
.on('error', err => { | ||
console.error('Express failed to start'); | ||
console.error(err); | ||
}); | ||
} | ||
|
||
if (require.main === module) { | ||
dbConnect(); | ||
runServer(); | ||
dbConnect(); | ||
runServer(); | ||
} | ||
|
||
module.exports = {app}; | ||
module.exports = { app }; |
Oops, something went wrong.