index.js 701 B

12345678910111213141516171819202122232425
  1. const express = require('express')
  2. const mongoose = require('mongoose')
  3. const User = require('./models/User')
  4. const app = express()
  5. const config = require('config')
  6. app.use(express.json({extended:true}))
  7. app.use('/api/authorization', require('./router/router'))
  8. const PORT = 4000
  9. async function start() {
  10. try {
  11. await mongoose.connect(
  12. 'mongodb+srv://king:LjeEojWE550bhRFv@cluster0.44osb.mongodb.net/SBox',
  13. {
  14. useNewUrlParser: true,
  15. useUnifiedTopology: true,
  16. useCreateIndex: true
  17. }
  18. )
  19. app.listen(PORT, () => {console.log('Server has been started...',PORT)})
  20. }catch (e) {
  21. console.log('error:',e)
  22. }
  23. }
  24. start()