feat: connect analytics to mongo

This commit is contained in:
wancat committed 2023-10-14 16:03:44 +08:00
1 parent fb687094ee
commit add6bfd100
3 files changed
+22 -11

No files matched your search

+1
View File
@@ -10,6 +10,7 @@
"dev": "nodemon src/index.js"
},
"dependencies": {
"@linux-odyssey/models": "*",
"express": "^4.18.2",
"express-handlebars": "^7.1.2"
},
+3
View File
@@ -0,0 +1,3 @@
export default {
db: process.env.MONGO_URL || 'mongodb://localhost:27017/odyssey-test',
}
+18 -11
View File
@@ -1,17 +1,24 @@
import connectDB from '@linux-odyssey/models'
import express from 'express'
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
app.engine('handlebars', engine())
app.set('view engine', 'handlebars')
app.set('views', './views')
// Setting up Handlebars as templating engine
app.engine('handlebars', engine())
app.set('view engine', 'handlebars')
app.set('views', './views')
app.get('/', (req, res) => {
res.render('home', { title: 'Linux Odyssey Admin' })
})
app.get('/', (req, res) => {
res.render('home', { title: 'Linux Odyssey Admin' })
})
app.listen(3001, () => {
console.log('Server started on http://localhost:3001')
})
app.listen(3001, () => {
console.log('Server started on http://localhost:3001')
})
}
main().catch(console.error)