blob: 7c56c4e0ee0fda834c47e120f4131fab44e6c54f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
const express = require('express')
const app = express()
const cors = require('cors')
const Blog = require('../models/blog.js')
const blogsRouter = require('../controllers/blogs')
const mongoose = require('mongoose')
const logger = require('../utils/logger.js')
logger.info("Connecting to mongo server")
const mongoUrl = 'hello'
mongoose.connect(mongoUrl)
logger.info("Successfully connected to mongo server")
app.use(cors())
app.use(express.json())
app.get('/api/blogs', blogsRouter)
app.post('/api/blogs', blogsRouter)
const PORT = 3003
app.listen(PORT, () => {
logger.info(`Server running on port ${PORT}`)
})
|