12345678910111213141516171819202122232425 |
- const express = require("express")
- const mongoose = require("mongoose")
- const config = require("config")
- const authRouter = require("./router/authorization")
- const corsMiddleware = require("./middleware/cors")
- const PORT = config.get('serverPort')
- const app = express()
- app.use(express.json())
- app.use('/api/authorization',authRouter)
- app.use(corsMiddleware)
- const start = async() =>{
- try{
- await mongoose.connect(config.get("mongodb"),{
- useNewUrlParser:true,
- useUnifiedTopology:true
- })
- app.listen(PORT,()=>{console.log("server listen:",PORT)})
- }catch(e){
- console.log("error:",e)
- }
- }
- start()
|