-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
55 lines (47 loc) · 1.08 KB
/
app.js
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require('dotenv').config()
const port = process.env.PORT
const cors = require('cors');
const express = require('express');
const Auth_Middleware = require('./Middleware/Firebase/Firebase_Auth');
const resetUplods = require('./Database/resetUploads');
const router = require('./Router/router')
const app = express()
app.use(cors())
//Json parser for reading post request data
app.use(express.json())
app.use(express.urlencoded({
extended: false
}))
app.get('/', (req, res) => {
try {
res.send({
error:true,
msg: 'Welcome to the Anki to JSON API.'
})
} catch (error) {
console.log(error)
res.status(500).send({
error:true,
msg: 'Internal error in API'
})
}
})
app.use('/', router)
app.get('*', (req, res) => {
try {
res.status(404).send({
error:true,
message: ['Endpoint not found.']
})
} catch (error) {
console.log(error)
res.status(500).send({
error:true,
message: 'Internal error in API'
})
}
})
resetUplods()
app.listen(port, 'localhost', () => {
console.log(`app running on port ${port}`)
})