1
0
Fork 0
mirror of https://github.com/kou029w/_.git synced 2025-01-30 13:58:08 +00:00

create astro-fastify-ssg

This commit is contained in:
Nebel 2024-03-23 19:49:38 +09:00
parent c5b6327a2e
commit 6a43e9ddbe
Signed by: nebel
GPG key ID: 79807D08C6EF6460
6 changed files with 4485 additions and 0 deletions

View file

@ -0,0 +1,19 @@
{
"name": "@kou029w/astro-fastify-ssg",
"version": "0.0.0",
"private": true,
"license": "MIT",
"type": "module",
"scripts": {
"dev": "fastify start --log-level=info --debug --watch server.js -- --dev",
"build": "astro build",
"start": "fastify start server.js"
},
"devDependencies": {
"@fastify/http-proxy": "^9.5.0",
"@fastify/static": "^7.0.1",
"astro": "^4.5.9",
"fastify": "^4.26.2",
"fastify-cli": "^6.1.1"
}
}

4440
astro-fastify-ssg/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
public

View file

@ -0,0 +1,23 @@
import fastifyStatic from "@fastify/static";
import { fileURLToPath } from "node:url";
/** @type {import("fastify").FastifyPluginAsync} */
const app = async (fastify, opts) => {
fastify.get("/hello", async () => "hello");
if (opts.dev) {
const astro = await import("astro");
const astroDevServer = await astro.dev();
await fastify.register(await import("@fastify/http-proxy"), {
upstream: `http://localhost:${astroDevServer.address.port}`,
});
} else {
await fastify.register(fastifyStatic, {
root: fileURLToPath(import.meta.resolve("./dist")),
});
}
fastify.get("/world", async () => "world");
};
export default app;

1
astro-fastify-ssg/src/env.d.ts vendored Normal file
View file

@ -0,0 +1 @@
/// <reference types="astro/client" />

View file

@ -0,0 +1 @@
**Hello, World!**