2020-08-18 11:13:12 -05:00
|
|
|
import * as express from 'express'
|
|
|
|
|
import * as bodyParser from 'body-parser'
|
|
|
|
|
import routes from './routes/index'
|
|
|
|
|
import { createConnection } from 'typeorm'
|
2020-08-26 17:10:35 -05:00
|
|
|
import * as cors from 'cors'
|
|
|
|
|
|
2020-08-18 11:13:12 -05:00
|
|
|
const PORT = 3000
|
2020-07-24 01:32:59 -05:00
|
|
|
createConnection()
|
|
|
|
|
.then(async (connection) => {
|
2020-08-18 11:13:12 -05:00
|
|
|
const app = express()
|
|
|
|
|
// configure multer
|
2020-08-26 17:10:35 -05:00
|
|
|
app.use(cors())
|
2020-08-18 11:13:12 -05:00
|
|
|
app.use(bodyParser.urlencoded({ extended: false }))
|
|
|
|
|
app.use(bodyParser.json())
|
2020-07-24 01:32:59 -05:00
|
|
|
|
2020-08-18 11:13:12 -05:00
|
|
|
app.get('/', (req, res) => res.send('Hello World!'))
|
2020-07-24 01:32:59 -05:00
|
|
|
|
2020-08-18 11:13:12 -05:00
|
|
|
app.use('/', routes)
|
2020-07-24 01:32:59 -05:00
|
|
|
|
2020-08-18 11:13:12 -05:00
|
|
|
app.listen(PORT, () =>
|
|
|
|
|
console.log(`Example app listening at http://localhost:${PORT}`)
|
|
|
|
|
)
|
2020-07-24 01:32:59 -05:00
|
|
|
})
|
2020-08-18 11:13:12 -05:00
|
|
|
.catch((error) => console.log('TypeORM connection error: ', error))
|