// 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)

export default adminRouter

 

//routes/admin/category.js
import express from 'express'
const categoryRouter = express.Router()
import category from '../../controllers/admin/category.js'

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

export default categoryRouter

 

// controllers/admin/category.js
import config from "../../config.js"

class Category{
    async getItem(req,res){
        this.config = await config()
        this.config.pageTitle = 'ទំព័រ​ប្រភេទ​ទំនិញ'
        this.config.route = '/admin/category'
        this.config.type = 'category'

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

export default new Category()

 

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