mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30:12 +08:00
feat: connect analytics to mongo
This commit is contained in:
1 parent
fb687094ee
commit
add6bfd100
3 files changed
+20
-9
No files matched your search
@@ -10,6 +10,7 @@
|
|||||||
"dev": "nodemon src/index.js"
|
"dev": "nodemon src/index.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@linux-odyssey/models": "*",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"express-handlebars": "^7.1.2"
|
"express-handlebars": "^7.1.2"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
db: process.env.MONGO_URL || 'mongodb://localhost:27017/odyssey-test',
|
||||||
|
}
|
||||||
@@ -1,17 +1,24 @@
|
|||||||
|
import connectDB from '@linux-odyssey/models'
|
||||||
import express from 'express'
|
import express from 'express'
|
||||||
import { engine } from 'express-handlebars'
|
import { engine } from 'express-handlebars'
|
||||||
|
import config from './config.js'
|
||||||
|
|
||||||
const app = express()
|
async function main() {
|
||||||
|
await connectDB(config.db)
|
||||||
|
const app = express()
|
||||||
|
|
||||||
// Setting up Handlebars as templating engine
|
// Setting up Handlebars as templating engine
|
||||||
app.engine('handlebars', engine())
|
app.engine('handlebars', engine())
|
||||||
app.set('view engine', 'handlebars')
|
app.set('view engine', 'handlebars')
|
||||||
app.set('views', './views')
|
app.set('views', './views')
|
||||||
|
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
res.render('home', { title: 'Linux Odyssey Admin' })
|
res.render('home', { title: 'Linux Odyssey Admin' })
|
||||||
})
|
})
|
||||||
|
|
||||||
app.listen(3001, () => {
|
app.listen(3001, () => {
|
||||||
console.log('Server started on http://localhost:3001')
|
console.log('Server started on http://localhost:3001')
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch(console.error)
|
||||||
Reference in new issue
Block a user