filesharing/server.js

19 lines
589 B
JavaScript

const { SERVER_HOST, SERVER_PORT, MONGDB_URL } = require('./config')
const express = require('express')
const mongoose = require('mongoose')
mongoose.connect(MONGDB_URL, (error) => {
if (error) {
console.error(error)
} else {
console.info('mongodb connected successfully')
}
})
const app = express()
app.set('view engine', 'pug')
app.get('/', async (req, res) => {
res.render('index', { title: 'hello, world!' })
})
const server = app.listen(SERVER_PORT, SERVER_HOST, () => {
console.info(`server is running at http://${SERVER_HOST}:${SERVER_PORT}`)
})