Compare commits

4 Commits

Author SHA1 Message Date
Dylan Pizzo
07595c31ef prettier i guess 2026-01-14 12:44:20 -08:00
Dylan Pizzo
db2007e4b0 Update the readme 2025-02-19 19:54:07 -08:00
dylan
a343f74821 comment out more websocket stuff 2024-05-11 18:04:44 -07:00
dylan
ac5f4d2c1e make links green 2024-05-11 17:45:08 -07:00
4 changed files with 50 additions and 45 deletions

View File

@@ -1,12 +1,6 @@
# Firstack
# Picobook
Firstack is a template repo for a tech stack. This stack includes
- [react](https://react.dev/)
- [emotion](https://emotion.sh/)
- [fastify](https://fastify.dev/)
- [postgres](https://www.postgresql.org/)
- [typescript](https://www.typescriptlang.org/)
A website for hosting pico8 projects.
## Dependencies

View File

@@ -12,29 +12,29 @@ type Info = {
export const GamePage = () => {
const {author, slug} = useParams();
const [searchParams, setSearchParams] = useSearchParams();
const room = searchParams.get('room');
// const [searchParams, setSearchParams] = useSearchParams();
// const room = searchParams.get('room');
const picoRef = useRef<Pico8ConsoleImperatives>(null);
const socket = useWebsocket({
url: `/api/ws/room?room=${room}`,
// url: "wss://echo.websocket.org",
onMessage({message}) {
// const msg = message as any;
// if (msg.type === "gpio") {
// if (picoRef.current) {
// const handle = picoRef.current.getPicoConsoleHandle();
// if (handle) {
// console.log("updating pico gpio");
// (handle.gpio as any).dontSend = true;
// handle.gpio.length = 0;
// handle.gpio.push(...msg.gpio);
// (handle.gpio as any).dontSend = false;
// const socket = useWebsocket({
// url: `/api/ws/room?room=${room}`,
// // url: "wss://echo.websocket.org",
// onMessage({message}) {
// // const msg = message as any;
// // if (msg.type === "gpio") {
// // if (picoRef.current) {
// // const handle = picoRef.current.getPicoConsoleHandle();
// // if (handle) {
// // console.log("updating pico gpio");
// // (handle.gpio as any).dontSend = true;
// // handle.gpio.length = 0;
// // handle.gpio.push(...msg.gpio);
// // (handle.gpio as any).dontSend = false;
// // }
// // }
// // }
// console.log('message', message);
// }
// }
// }
console.log('message', message);
}
})
// })
// const version = searchParams.get('v');
const [v, setVersion] = useState<string | null>(null);
const [info, setInfo] = useState<Info | null>(null);

View File

@@ -1,13 +1,13 @@
// Import the framework and instantiate it
import Fastify from 'fastify'
import fastifyStatic from '@fastify/static'
import {fastifyWebsocket} from '@fastify/websocket';
import Fastify from "fastify";
import fastifyStatic from "@fastify/static";
import { fastifyWebsocket } from "@fastify/websocket";
import { routeList } from "./routelist.ts";
import { attachRoute } from "./util/routewrap.ts";
import { git } from './util/git.ts';
import { git } from "./util/git.ts";
import path from "path";
import {fileURLToPath} from 'url';
const __dirname = fileURLToPath(new URL('.', import.meta.url));
import { fileURLToPath } from "url";
const __dirname = fileURLToPath(new URL(".", import.meta.url));
await git.clone({
from: "https://github.com/thisismypassport/shrinko8",
@@ -15,23 +15,23 @@ await git.clone({
});
const server = Fastify({
logger: true
logger: true,
});
server.register(fastifyWebsocket);
server.register(fastifyStatic, {
root: new URL('public', import.meta.url).toString().slice("file://".length),
prefix: '/',
root: new URL("public", import.meta.url).toString().slice("file://".length),
prefix: "/",
});
routeList.forEach(firRoute => {
routeList.forEach((firRoute) => {
attachRoute(server, firRoute);
});
server.setNotFoundHandler((req, res) => {
if (!req.url.startsWith("/api")) {
res.sendFile('index.html');
res.sendFile("index.html");
}
});
@@ -40,8 +40,11 @@ try {
// Note: host needs to be 0.0.0.0 rather than omitted or localhost, otherwise
// it always returns an empty reply when used inside docker...
// See: https://github.com/fastify/fastify/issues/935
await server.listen({ port: parseInt(process.env["PORT"] ?? "3000"), host: "0.0.0.0" })
await server.listen({
port: parseInt(process.env["PORT"] ?? "3000"),
host: "0.0.0.0",
});
} catch (err) {
server.log.error(err)
process.exit(1)
server.log.error(err);
process.exit(1);
}

View File

@@ -40,6 +40,14 @@
footer {
max-inline-size: none;
}
a,
a:hover,
a:focus,
a:active,
a:visited {
color: lime;
}
</style>
</head>
<body>