-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.js
47 lines (39 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
const path = require("path")
const config = require("./utils/config")
const logger = require("./utils/logger")
const express = require("express")
const cors = require("cors")
const mongoose = require("mongoose")
const app = express()
const authRouter = require("./controllers/auth")
const collectionRouter = require("./controllers/collection")
// Connect to MongoDB
logger.info("Connecting to MongoDB...")
mongoose
.connect(config.MONGODB_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
})
.then(() => {
logger.info("Connected to MongoDB.")
})
.catch(error => {
logger.error("Error connection to MongoDB:", error.message)
})
// User Middleware
app.use(cors())
app.use(express.static("build"))
app.use(express.json())
// Routes
app.use("/api/auth", authRouter)
app.use("/api/collection", collectionRouter)
app.use(
"/api/pokeml/classify",
express.static(path.join(__dirname, "classifier_models/original/model.json"))
)
app.use(
"/api/pokeml",
express.static(path.join(__dirname, "classifier_models/original"))
)
module.exports = app