// server/index.jsconstNextKoa=require('next-koa')constKoa=require('koa')constRouter=require('koa2-router')constpath=require('path')constapp=newKoa()constrouter=newRouter()constnextApp=NextKoa({dev: process.env.NODE_ENV !== 'production',dir: path.resolve(__dirname,'..')})// console nextConfigconsole.log(nextApp.nextConfig)app.use(nextApp.middleware)app.use((ctx,next)=>{ctx.state.homepage='/'returnnext()})app.use(router)// using renderer of next.js to emit pages/about.tsx// the state can be captured by next-koa/getstate package// and is rendered as ctx.state merged by this data// here data usually is a plain objectrouter.get('/about',ctx=>ctx.render('about',{title: 'about us'}))// if nextConfig.useFileSystemPublicRoutes is missing or true// then you can get any page under `pages` by directly fetching// the pathname without defining the koa routesapp.listen(3000)
The Tidelift Subscription provides access to a continuously curated stream of human-researched and maintainer-verified data on open source packages and their licenses, releases, vulnerabilities, and development practices.