// package.json

{
  "name": "sale_products_online",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon index.js"
  },
  "author": "Sokhavuth",
  "license": "ISC",
  "dependencies": {
    "express": "^4.18.1",
    "nodemon": "^2.0.16"
  }
}

 

// index.js
// npm install express

import express from 'express'
const app = express()

import frontRouter from './routes/front.js'
import adminRouter from './routes/admin.js'

app.use('/',frontRouter)
app.use('/admin',adminRouter)

const port = process.env.PORT || 8000
app.listen(port, ()=>{
  console.log(`This app is listening to the port ${port}`)
})

 

// routes/front.js
import express from 'express'
const frontRouter = express.Router()

frontRouter.get('/',async (req,res)=>{
    res.send('កម្មវិធី Express តូច​បំផុត!')
})

export default frontRouter

 

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