Website Structure

This commit is contained in:
supalerk-ar66 2026-01-13 10:46:40 +07:00
parent 62812f2090
commit 71f0676a62
22365 changed files with 4265753 additions and 791 deletions

View file

@ -0,0 +1,53 @@
const Koa = require('koa')
const serve = require('koa-static')
const Router = require('@koa/router')
const portfinder = require('portfinder')
const open = require('open')
const { resolveConfig } = require('../lib/tailwindConfigUtils')
function createServer ({
port = 3000,
tailwindConfigProvider,
shouldOpen,
routerPrefix = ''
}) {
const app = new Koa()
const router = new Router({ prefix: routerPrefix })
router.get('/config.json', async (ctx) => {
const config = await tailwindConfigProvider()
ctx.body = resolveConfig(config)
})
app
.use(serve(`${__dirname}/../dist`))
.use(router.routes())
.use(router.allowedMethods())
return {
app,
asMiddleware: () => {
return app.callback()
},
start: () => {
portfinder.getPort({
port
}, (err, port) => {
if (err) {
throw (err)
}
app.listen(port, async () => {
console.log('Server Started ∹ http://localhost:' + port.toString())
if (shouldOpen) {
open('http://localhost:' + port.toString())
}
})
})
}
}
}
module.exports = createServer