feat: build as middleware & use fastify

This commit is contained in:
Ayo Ayco 2024-07-27 08:43:58 +02:00
parent 173d584d80
commit d3abab1efc
4 changed files with 615 additions and 12 deletions

View file

@ -6,6 +6,6 @@ import node from "@astrojs/node";
export default defineConfig({ export default defineConfig({
output: "server", output: "server",
adapter: node({ adapter: node({
mode: "standalone" mode: "middleware"
}) })
}); });

View file

@ -21,9 +21,12 @@
}, },
"dependencies": { "dependencies": {
"@astrojs/node": "^8.3.2", "@astrojs/node": "^8.3.2",
"@ayco/astro-resume": "^0.4.0", "@ayco/astro-resume": "^0.4.1",
"@extractus/article-extractor": "^8.0.10", "@extractus/article-extractor": "^8.0.10",
"@fastify/middie": "^8.3.1",
"@fastify/static": "^7.0.4",
"astro-iconify": "^1.2.0", "astro-iconify": "^1.2.0",
"fastify": "^4.28.1",
"sass": "^1.77.8", "sass": "^1.77.8",
"ultrahtml": "^1.5.3" "ultrahtml": "^1.5.3"
} }

File diff suppressed because it is too large Load diff

16
server.mjs Normal file
View file

@ -0,0 +1,16 @@
import Fastify from 'fastify';
import fastifyMiddie from '@fastify/middie';
import fastifyStatic from '@fastify/static';
import { fileURLToPath } from 'node:url';
import { handler as ssrHandler } from './dist/server/entry.mjs';
const app = Fastify({ logger: true });
await app
.register(fastifyStatic, {
root: fileURLToPath(new URL('./dist/client', import.meta.url)),
})
.register(fastifyMiddie);
app.use(ssrHandler);
app.listen({ port: 8080 });