//routes/admin.js
import express from 'express'
const admin = express.Router()
import loginRoute from './admin/login.js'
admin.use('/login', loginRoute)
import categoryRoute from './admin/category.js'
admin.use('/category', categoryRoute)
import postRoute from './admin/post.js'
admin.use('/post', postRoute)
import bookRoute from './admin/book.js'
admin.use('/book', bookRoute)
import uploadRoute from './admin/upload.js'
admin.use('/upload', uploadRoute)
import userRoute from './admin/user.js'
admin.use('/user', userRoute)
import settingRoute from './admin/setting.js'
admin.use('/setting', settingRoute)
export default admin
//routes/admin/setting.js
import express from 'express'
const settingRoute = express.Router()
settingRoute.get('/',async function(req,res){
if(req.session.user){
const module = await import('../../controllers/admin/setting/read.js')
module.default(req,res)
}else{
res.redirect('/admin/login')
}
})
export default settingRoute
//controllers/admin/setting/read.js
import settings from '../../../settings.js'
import read from '../../../models/setting/read.js'
let mySettings = JSON.parse(JSON.stringify(settings))
export default async (req,res)=>{
mySettings.pageTitle = 'ទំព័រ Setting'
mySettings.route = '/admin/setting'
res.render('base',{data:mySettings})
}
<!--views/admin/setting.ejs-->
<link href="/styles/admin/category.css" rel="stylesheet"></link>
<div class='content'>
<form action='/admin/setting' method='post' >
<a>ឈ្មោះគេហទំព័រ</a><input type='text' value="" name='siteTitle' required />
<a>អំពីគេហទំព័រ</a><input type='text' value="" name='description' required />
<a>ទិន្នន័យក្នុង</a><input type='text' value="" name='dItemLimit' required />
<a>ទិន្នន័យមុខ</a><input type='text' value="" name='indexPostLimit' required />
<a>ទិន្នន័យប្រភេទ</a><input type='text' value="" name='categoryPostLimit' required />
</form>
</div>