Skip to content

Instantly share code, notes, and snippets.

@tostu
tostu / compose.yml
Created August 13, 2025 16:45
Zigbee2MQTT
version: '3.8'
services:
mqtt:
image: eclipse-mosquitto:2.0
restart: unless-stopped
volumes:
- './mosquitto-data:/mosquitto'
ports:
- '1883:1883'
- '9001:9001'
gsettings set org.gnome.desktop.input-sources show-all-sources true
@tostu
tostu / +server.ts
Created January 15, 2023 18:28
Cloudflare pages d1 database query endpoint
import type { RequestHandler } from '@sveltejs/kit';
export const GET = (async ({ platform }) => {
const ps = platform.env.db.prepare('SELECT * from test');
const data = await ps.first();
return new Response(data)
}) satisfies RequestHandler;
@tostu
tostu / [...route].ts
Last active January 15, 2023 18:24
Middleware to route single page requests with additional api key and mask origin address on edge hosting(vercel, cloudflare pages)
//currently not working with cloudflare pages due to a bug
import type { NextRequest } from 'next/server'
export default async function handler(req: NextRequest) {
const { searchParams } = new URL(req.url)
const route = searchParams.getAll('route').join('/')
if (req.method === "GET"){
console.log(process.env.REST_API_URL)