Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/frameworks.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"focusedFramework": false,
"starter": {
"package": "starter-mastro",
"buildScript": "generate",
"buildScript": "build",
"buildOutputDir": "generated",
"measurements": [
{
Expand All @@ -94,7 +94,17 @@
"package": "app-mastro",
"buildScript": "build",
"buildOutputDir": "generated",
"measurements": []
"measurements": [
{
"type": "ssrRequestThroughput"
},
{
"type": "serverSideRendered"
},
{
"type": "ssrLoad"
}
]
}
},
{
Expand Down
7 changes: 7 additions & 0 deletions packages/app-mastro/handlers/detail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { getParams, html, htmlToResponse } from '@mastrojs/mastro'

export const GET = (request: Request) => {
const { id } = getParams(request)

return htmlToResponse(html`<p id="detail-id">${id}</p>`)
}
11 changes: 8 additions & 3 deletions packages/app-mastro/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as http from 'node:http'
import { createRequestListener } from '@remix-run/node-fetch-server'
import { Mastro } from '@mastrojs/mastro/server-programmatic'
import { GET as getDetail } from './handlers/detail.ts'
import { GET as getHome } from './handlers/home.ts'

// This is using Mastro's programmatic (Express-like) router
Expand All @@ -10,9 +11,13 @@ import { GET as getHome } from './handlers/home.ts'

export const handler = new Mastro<unknown, void>()
.get('/', getHome)
.get('/ssr-throughput', getHome)
.get('/server-side-rendered', getHome)
.get('/server-side-rendered/:id', getDetail)
.createHandler()

const port = 8000
const host = process.env.HOST ?? '127.0.0.1'
const port = Number.parseInt(process.env.PORT ?? '8000', 10)

if (import.meta.main) {
const server = http.createServer(createRequestListener(handler))
Expand All @@ -21,7 +26,7 @@ if (import.meta.main) {
console.error(e)
})

server.listen(port, () => {
console.log(`Server running at http://localhost:${port}`)
server.listen(port, host, () => {
console.log(`Server running at http://${host}:${port}`)
})
}
17 changes: 17 additions & 0 deletions packages/stats-generator/src/serve/mastro.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { join } from 'node:path'
import {
getHost,
getPort,
parseAppDir,
spawnProductionServer,
} from './common.ts'

const appDir = parseAppDir()
const HOST = getHost()
const PORT = getPort(8000)
const entryPath = join(appDir, 'server.ts')

spawnProductionServer([entryPath], appDir, {
HOST,
PORT: String(PORT),
})
6 changes: 6 additions & 0 deletions packages/stats-generator/src/serverSideRendered/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ const SERVER_SIDE_RENDERED_FRAMEWORKS: ServerSideRenderedFrameworkConfig[] = [
package: 'app-astro',
serveScript: 'astro.ts',
},
{
name: 'mastro-server-side-rendered',
displayName: 'Mastro Server Side Rendered',
package: 'app-mastro',
serveScript: 'mastro.ts',
},
{
name: 'next-server-side-rendered',
displayName: 'Next.js Server Side Rendered',
Expand Down
6 changes: 6 additions & 0 deletions packages/stats-generator/src/ssrLoad/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ const SSR_LOAD_FRAMEWORKS: SSRLoadFrameworkConfig[] = [
package: 'app-astro',
serveScript: 'astro.ts',
},
{
name: 'mastro-ssr-load',
displayName: 'Mastro SSR Load',
package: 'app-mastro',
serveScript: 'mastro.ts',
},
{
name: 'next-ssr-load',
displayName: 'Next.js SSR Load',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@ export async function buildMastroHandler(): Promise<ServerRenderHandler> {
const entryPath = join(packagesDir, 'app-mastro', 'server.ts')
const entryUrl = pathToFileURL(entryPath).href
const { handler } = await import(entryUrl)
return { type: 'web', handler }
return {
type: 'web',
handler: (request) => {
const url = new URL(request.url)
url.hostname = '127.0.0.1'
return handler(new Request(url, request))
},
}
}
7 changes: 7 additions & 0 deletions packages/stats-generator/src/ssrRequestThroughput/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { runBenchmark } from './run-benchmark.ts'
import { buildAstroHandler } from './handlers/astro.ts'
import { buildBaselineHtmlHandler } from './handlers/baseline-html.ts'
import { buildMastroHandler } from './handlers/mastro.ts'
import { buildNuxtHandler } from './handlers/nuxt.ts'
import { buildSvelteKitHandler } from './handlers/sveltekit.ts'
import { buildNextJSHandler } from './handlers/nextjs.ts'
Expand Down Expand Up @@ -34,6 +35,12 @@ const SSR_REQUEST_THROUGHPUT_FRAMEWORKS: SSRRequestThroughputFrameworkConfig[] =
package: 'app-astro',
buildHandler: buildAstroHandler,
},
{
name: 'mastro-ssr-request-throughput',
displayName: 'Mastro SSR Request Handler Throughput',
package: 'app-mastro',
buildHandler: buildMastroHandler,
},
{
name: 'nuxt-ssr-request-throughput',
displayName: 'Nuxt SSR Request Handler Throughput',
Expand Down
Loading