()
| 28 | } |
| 29 | |
| 30 | export async function createStartServer() { |
| 31 | const distServerEntryPath = resolveDistServerEntryPath() |
| 32 | const server = (await import(distServerEntryPath)).default |
| 33 | const nodeHandler = toNodeHandler(server.fetch) |
| 34 | |
| 35 | const app = express() |
| 36 | |
| 37 | // to keep testing uniform stop express from redirecting /posts to /posts/ |
| 38 | // when serving pre-rendered pages |
| 39 | app.use(express.static(distClientDir, { redirect: !isPrerender })) |
| 40 | |
| 41 | app.use(async (req, res, next) => { |
| 42 | try { |
| 43 | await nodeHandler(req, res) |
| 44 | } catch (error) { |
| 45 | next(error) |
| 46 | } |
| 47 | }) |
| 48 | |
| 49 | return { app } |
| 50 | } |
| 51 | |
| 52 | export async function createSpaServer() { |
| 53 | const app = express() |
no test coverage detected