Skip to content

Commit 3f62d65

Browse files
committed
setting up project
1 parent a24bd5e commit 3f62d65

File tree

5 files changed

+103
-1
lines changed

5 files changed

+103
-1
lines changed

knexfile.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Update with your config settings.
2+
3+
module.exports = {
4+
5+
development: {
6+
client: 'sqlite3',
7+
connection: {
8+
filename: './dev.sqlite3'
9+
}
10+
},
11+
12+
staging: {
13+
client: 'postgresql',
14+
connection: {
15+
database: 'my_db',
16+
user: 'username',
17+
password: 'password'
18+
},
19+
pool: {
20+
min: 2,
21+
max: 10
22+
},
23+
migrations: {
24+
tableName: 'knex_migrations'
25+
}
26+
},
27+
28+
production: {
29+
client: 'postgresql',
30+
connection: {
31+
database: 'my_db',
32+
user: 'username',
33+
password: 'password'
34+
},
35+
pool: {
36+
min: 2,
37+
max: 10
38+
},
39+
migrations: {
40+
tableName: 'knex_migrations'
41+
}
42+
}
43+
44+
};

package.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,16 @@
1616
"bugs": {
1717
"url": "https://github.com/marcpre/learning_jquery_repeater-field/issues"
1818
},
19-
"homepage": "https://github.com/marcpre/learning_jquery_repeater-field#readme"
19+
"homepage": "https://github.com/marcpre/learning_jquery_repeater-field#readme",
20+
"dependencies": {
21+
"cookie-parser": "^1.4.3",
22+
"express": "^4.16.2",
23+
"knex": "^0.14.0",
24+
"morgan": "^1.9.0",
25+
"pg": "^7.4.0",
26+
"pug": "^2.0.0-rc.4"
27+
},
28+
"devDependencies": {
29+
"nodemon": "^1.12.1"
30+
}
2031
}

src/app.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
require('dotenv').config()
2+
const express = require('express')
3+
const path = require('path')
4+
const logger = require('morgan')
5+
const bodyParser = require('body-parser')
6+
const cookieParser = require('cookie-parser')
7+
const session = require('express-session')
8+
const passport = require('passport')
9+
10+
const index = require('./routes/index')
11+
12+
const app = express()
13+
14+
// view engine setup
15+
app.set('views', path.join(__dirname, 'views'))
16+
app.set('view engine', 'pug')
17+
app.use(logger(process.env.LOG_ENV))
18+
app.use(bodyParser.json())
19+
app.use(bodyParser.urlencoded({
20+
extended: false,
21+
}))
22+
app.use(express.static(path.join(__dirname, '/../public')))
23+
app.use(cookieParser())
24+
25+
// routes
26+
app.use('/', index)
27+
28+
// Start Server
29+
const port = process.env.APP_PORT || 8080
30+
const host = process.env.APP_URL || '0.0.0.0'
31+
32+
app.listen(port, host, () => {
33+
console.log(`Listening on ${host}:${port}/login`)
34+
})
35+
36+
module.exports = app

src/connection/db.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Loading from an external file
2+
const config = require('../../knexfile')
3+
4+
const env = process.env.DB_ENV
5+
const knex = require('knex')(config[env])
6+
7+
knex.on('query', (queryData) => {
8+
console.log(queryData)
9+
})
10+
11+
module.exports = knex

src/views/index.pug

Whitespace-only changes.

0 commit comments

Comments
 (0)