You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
579 B
29 lines
579 B
import express from "express"; |
|
import cors from "cors"; |
|
import router from "./routes/api_router.js"; |
|
import config from './config/config.js'; |
|
|
|
const app = express(); |
|
app.use(express.json()); |
|
app.use(cors({ |
|
origin: config.CORS_ORIGIN, |
|
methods: ["GET", "POST"], |
|
allowedHeaders: ["Content-Type"] |
|
})); |
|
|
|
const onListening =() => { |
|
console.log("Listening on port 5000"); |
|
} |
|
|
|
app.use("/api", router); |
|
|
|
app.listen(5000, onListening) |
|
|
|
app.all('*', (req, res) => { |
|
res |
|
.status(404) |
|
.json({ |
|
success: false, |
|
message: 'Route not found!', |
|
}); |
|
}); |