text: import express from 'express'
  import morgan from 'morgan'
  import cookieParser from 'cookie-parser'
  import config from '../config/index.js'
  import session from 'express-session'
  import MongoStore from 'connect-mongo'
  import { logger } from '../logger.js'
  import passport from '../auth/passport/index.js'
  
  
  const initMiddleware = (app) => {
    app.use(morgan('dev'))
    app.use(express.json())
    app.use(express.urlencoded({ extended: true }))
    app.use(cookieParser())
  }
  
  const initSession = (app) => {
    app.use(
      session({
        secret: config.session.secret,
        resave: false,
        saveUninitialized: false,
        store: MongoStore.create({
          mongoUrl: config.db.mongoURI,
          collectionName: config.session.collection
        }),
        rolling: config.session.rolling,
        cookie: config.session.cookie,
        name: config.session.name
      })
    )
  }
  
  const initAuth = (app) => {
    passport(app)
  }
  
  export function initExpress (app) {
    initMiddleware(app)
    initSession(app)
    initAuth(app)
    app.listen(config.port, () => logger.info(`Server running on port ${config.port}`))
  }
  