mirror of
https://github.com/kou029w/_.git
synced 2025-02-02 15:18:37 +00:00
Compare commits
5 commits
e52b79a88b
...
4e2ec1a156
Author | SHA1 | Date | |
---|---|---|---|
|
4e2ec1a156 | ||
07d437da3d | |||
6a43e9ddbe | |||
c5b6327a2e | |||
|
bfe725b2dc |
14 changed files with 9119 additions and 9 deletions
19
astro-fastify-ssg/package.json
Normal file
19
astro-fastify-ssg/package.json
Normal 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
4440
astro-fastify-ssg/pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load diff
1
astro-fastify-ssg/public/public.txt
Normal file
1
astro-fastify-ssg/public/public.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
public
|
25
astro-fastify-ssg/server.js
Normal file
25
astro-fastify-ssg/server.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
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
Normal file
1
astro-fastify-ssg/src/env.d.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/// <reference types="astro/client" />
|
1
astro-fastify-ssg/src/pages/index.md
Normal file
1
astro-fastify-ssg/src/pages/index.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
**Hello, World!**
|
9
astro-fastify/astro.config.ts
Normal file
9
astro-fastify/astro.config.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import { defineConfig } from "astro/config";
|
||||||
|
import node from "@astrojs/node";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
output: "server",
|
||||||
|
adapter: node({
|
||||||
|
mode: "middleware",
|
||||||
|
}),
|
||||||
|
});
|
21
astro-fastify/package.json
Normal file
21
astro-fastify/package.json
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"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
Normal file
4553
astro-fastify/pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load diff
1
astro-fastify/public/public.txt
Normal file
1
astro-fastify/public/public.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
public
|
29
astro-fastify/server.js
Normal file
29
astro-fastify/server.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
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
Normal file
1
astro-fastify/src/env.d.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/// <reference types="astro/client" />
|
9
astro-fastify/src/pages/index.ts
Normal file
9
astro-fastify/src/pages/index.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import type { APIRoute } from "astro";
|
||||||
|
|
||||||
|
export const GET: APIRoute = () => {
|
||||||
|
return new Response(
|
||||||
|
JSON.stringify({
|
||||||
|
number: Math.random(),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
};
|
|
@ -2995,19 +2995,19 @@ saxes@^5.0.1:
|
||||||
xmlchars "^2.2.0"
|
xmlchars "^2.2.0"
|
||||||
|
|
||||||
"semver@2 || 3 || 4 || 5", semver@^5.5.0:
|
"semver@2 || 3 || 4 || 5", semver@^5.5.0:
|
||||||
version "5.7.1"
|
version "5.7.2"
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8"
|
||||||
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
|
integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==
|
||||||
|
|
||||||
semver@^6.0.0, semver@^6.3.0:
|
semver@^6.0.0, semver@^6.3.0:
|
||||||
version "6.3.0"
|
version "6.3.1"
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
|
||||||
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==
|
||||||
|
|
||||||
semver@^7.3.2:
|
semver@^7.3.2:
|
||||||
version "7.3.5"
|
version "7.5.4"
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
|
||||||
integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==
|
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
|
||||||
dependencies:
|
dependencies:
|
||||||
lru-cache "^6.0.0"
|
lru-cache "^6.0.0"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue