server/src/app.ts

25 lines
806 B
TypeScript
Raw Normal View History

2020-06-27 21:23:09 +00:00
import express from 'express'
import DefaultController from './controllers/DefaultController'
import AdminTagController from './controllers/AdminTagController'
import mongoose from 'mongoose'
import bodyParser from 'body-parser'
const app: express.Application = express()
const host: string = "0.0.0.0"
const port: number = 8001
mongoose.connect('mongodb://localhost:27017/forumvirt', {useNewUrlParser: true, useUnifiedTopology: true});
app.use(bodyParser.json())
app.get('/', DefaultController.home)
app.get('/api/tags', AdminTagController.getTags)
app.put('/api/tags/:id', AdminTagController.updateTag)
app.post('/api/tags', AdminTagController.storeTag)
app.delete('/api/tags/:id', AdminTagController.destroyTag)
app.listen(port, host, () => {
console.log(`API listening on ${host}:${port}`)
})