// routes/admin.js
import express from 'express'
const adminRouter = express.Router()

import postRouter from './admin/post.js'
adminRouter.use('/post',postRouter)

import categoryRouter from './admin/category.js'
adminRouter.use('/category',categoryRouter)

import uploadRouter from './admin/upload.js'
adminRouter.use('/upload',uploadRouter)

export default adminRouter

 

// routes/admin/upload.js
// npm install multer
import path from 'path'
import express from 'express'
const uploadRouter = express.Router()
import upload from '../../controllers/admin/upload.js'

uploadRouter.get('/',async (req,res)=>{
    if(req.session.user){
        upload.getItem(req,res)
    }else{
        res.redirect('/login')
    }
})

export default uploadRouter

 

// controller/admin/upload.js
import config from '../../config.js'

class Upload{
    async getItem(req,res){
        this.config = await config()
        this.config.pageTitle = 'ទំព័រ Upload'
        this.config.route = '/admin/upload'

        res.render('base',{data:this.config})
    }
}

export default new Upload()

 

Heroku: https://khmerweb-sale.herokuapp.com/login