1234567891011121314151617181920212223242526 |
- 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(corsMiddleware)
- 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()
|