mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 06:20:02 -04:00
Add format script to package.json and format with prettier.
This commit is contained in:
parent
61bd33845b
commit
be3b87e795
39 changed files with 1732 additions and 1734 deletions
80
server.js
80
server.js
|
@ -14,71 +14,71 @@ import { libcurlPath } from "@mercuryworkshop/libcurl-transport";
|
|||
import { bareModulePath } from "@mercuryworkshop/bare-as-module3";
|
||||
|
||||
const bare = createBareServer("/bare/", {
|
||||
logErrors: true,
|
||||
logErrors: true,
|
||||
});
|
||||
|
||||
const fastify = Fastify({
|
||||
serverFactory: (handler) => {
|
||||
return createServer()
|
||||
.on("request", (req, res) => {
|
||||
if (bare.shouldRoute(req)) {
|
||||
bare.routeRequest(req, res);
|
||||
} else {
|
||||
handler(req, res);
|
||||
}
|
||||
})
|
||||
.on("upgrade", (req, socket, head) => {
|
||||
if (bare.shouldRoute(req)) {
|
||||
bare.routeUpgrade(req, socket, head);
|
||||
} else {
|
||||
socket.end();
|
||||
}
|
||||
});
|
||||
},
|
||||
serverFactory: (handler) => {
|
||||
return createServer()
|
||||
.on("request", (req, res) => {
|
||||
if (bare.shouldRoute(req)) {
|
||||
bare.routeRequest(req, res);
|
||||
} else {
|
||||
handler(req, res);
|
||||
}
|
||||
})
|
||||
.on("upgrade", (req, socket, head) => {
|
||||
if (bare.shouldRoute(req)) {
|
||||
bare.routeUpgrade(req, socket, head);
|
||||
} else {
|
||||
socket.end();
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
fastify.register(fastifyStatic, {
|
||||
root: join(fileURLToPath(new URL(".", import.meta.url)), "./static"),
|
||||
decorateReply: false,
|
||||
root: join(fileURLToPath(new URL(".", import.meta.url)), "./static"),
|
||||
decorateReply: false,
|
||||
});
|
||||
fastify.register(fastifyStatic, {
|
||||
root: join(fileURLToPath(new URL(".", import.meta.url)), "./dist"),
|
||||
prefix: "/scram/",
|
||||
decorateReply: false,
|
||||
root: join(fileURLToPath(new URL(".", import.meta.url)), "./dist"),
|
||||
prefix: "/scram/",
|
||||
decorateReply: false,
|
||||
});
|
||||
fastify.register(fastifyStatic, {
|
||||
root: baremuxPath,
|
||||
prefix: "/baremux/",
|
||||
decorateReply: false,
|
||||
root: baremuxPath,
|
||||
prefix: "/baremux/",
|
||||
decorateReply: false,
|
||||
});
|
||||
fastify.register(fastifyStatic, {
|
||||
root: epoxyPath,
|
||||
prefix: "/epoxy/",
|
||||
decorateReply: false,
|
||||
root: epoxyPath,
|
||||
prefix: "/epoxy/",
|
||||
decorateReply: false,
|
||||
});
|
||||
fastify.register(fastifyStatic, {
|
||||
root: libcurlPath,
|
||||
prefix: "/libcurl/",
|
||||
decorateReply: false,
|
||||
root: libcurlPath,
|
||||
prefix: "/libcurl/",
|
||||
decorateReply: false,
|
||||
});
|
||||
fastify.register(fastifyStatic, {
|
||||
root: bareModulePath,
|
||||
prefix: "/baremod/",
|
||||
decorateReply: false,
|
||||
root: bareModulePath,
|
||||
prefix: "/baremod/",
|
||||
decorateReply: false,
|
||||
});
|
||||
fastify.listen({
|
||||
port: process.env.PORT || 1337,
|
||||
port: process.env.PORT || 1337,
|
||||
});
|
||||
|
||||
const watch = spawn("pnpm", ["rspack", "-w"], {
|
||||
detached: true,
|
||||
cwd: process.cwd(),
|
||||
detached: true,
|
||||
cwd: process.cwd(),
|
||||
});
|
||||
|
||||
watch.stdout.on("data", (data) => {
|
||||
console.log(`${data}`);
|
||||
console.log(`${data}`);
|
||||
});
|
||||
|
||||
watch.stderr.on("data", (data) => {
|
||||
console.log(`${data}`);
|
||||
console.log(`${data}`);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue