mirror of
https://github.com/kou029w/_.git
synced 2025-02-02 15:18:37 +00:00
Compare commits
1 commit
7e7a61c0f1
...
222c1f82b8
Author | SHA1 | Date | |
---|---|---|---|
|
222c1f82b8 |
13 changed files with 0 additions and 9110 deletions
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
"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
4440
astro-fastify-ssg/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
@ -1 +0,0 @@
|
|||
public
|
|
@ -1,25 +0,0 @@
|
|||
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({
|
||||
root: fileURLToPath(import.meta.resolve(".")),
|
||||
});
|
||||
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
1
astro-fastify-ssg/src/env.d.ts
vendored
|
@ -1 +0,0 @@
|
|||
/// <reference types="astro/client" />
|
|
@ -1 +0,0 @@
|
|||
**Hello, World!**
|
|
@ -1,9 +0,0 @@
|
|||
import { defineConfig } from "astro/config";
|
||||
import node from "@astrojs/node";
|
||||
|
||||
export default defineConfig({
|
||||
output: "server",
|
||||
adapter: node({
|
||||
mode: "middleware",
|
||||
}),
|
||||
});
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
"name": "@kou029w/astro-fastify",
|
||||
"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": {
|
||||
"@astrojs/node": "^8.2.5",
|
||||
"@fastify/http-proxy": "^9.5.0",
|
||||
"@fastify/middie": "^8.3.0",
|
||||
"@fastify/static": "^7.0.1",
|
||||
"astro": "^4.5.9",
|
||||
"fastify": "^4.26.2",
|
||||
"fastify-cli": "^6.1.1"
|
||||
}
|
||||
}
|
4553
astro-fastify/pnpm-lock.yaml
generated
4553
astro-fastify/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
@ -1 +0,0 @@
|
|||
public
|
|
@ -1,29 +0,0 @@
|
|||
import fastifyMiddie from "@fastify/middie";
|
||||
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({
|
||||
root: fileURLToPath(import.meta.resolve(".")),
|
||||
});
|
||||
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/client")),
|
||||
});
|
||||
await fastify.register(fastifyMiddie);
|
||||
const astroServer = await import("./dist/server/entry.mjs");
|
||||
fastify.use(astroServer.handler);
|
||||
}
|
||||
|
||||
fastify.get("/world", async () => "world");
|
||||
};
|
||||
|
||||
export default app;
|
1
astro-fastify/src/env.d.ts
vendored
1
astro-fastify/src/env.d.ts
vendored
|
@ -1 +0,0 @@
|
|||
/// <reference types="astro/client" />
|
|
@ -1,9 +0,0 @@
|
|||
import type { APIRoute } from "astro";
|
||||
|
||||
export const GET: APIRoute = () => {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
number: Math.random(),
|
||||
}),
|
||||
);
|
||||
};
|
Loading…
Add table
Reference in a new issue