Skip to content

Instantly share code, notes, and snippets.

View matthewmorek's full-sized avatar
🙈
Breaking builds

Matthew Morek matthewmorek

🙈
Breaking builds
View GitHub Profile
@matthewmorek
matthewmorek / readme.md
Created March 7, 2023 17:31
API Documentation

Tramspotter API

Tramspotter API provides endpoints for serving Metrolink tram data to Tramspotter apps. It kinda acts as a Metrolink API proxy, as it provides data in a more readable JSON format.

Dependencies

This project is build with Deno. Make sure Deno is installed on your machine, if not you can always refer to

@matthewmorek
matthewmorek / ContentView.swift
Created July 12, 2023 19:52
Triggering sheet using buttons inside NavigationStack ToolbarItem
//
// SampleView.swift
// iOS
//
// Created by Matthew Morek on 12/07/2023.
//
import SwiftUI
struct SampleView: View {
@matthewmorek
matthewmorek / global.css
Last active August 9, 2023 16:53
Tailwind Auto Dark Mode
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
/* Light colors */
--color-light-surface-100: #ffffff;
--color-light-surface-200: #fafafa;
--color-light-surface-300: #f6f6f6;
import SwiftUI
struct LayeredButton: View {
@Environment(\.colorScheme) var colorScheme
var body: some View {
Text("Get departures")
.font(.system(.title3, design: .rounded, weight: .bold))
.foregroundStyle(Gradient(colors: [.black.opacity(0.85), .black.opacity(0.65)]))
.padding()
@matthewmorek
matthewmorek / api-error.ts
Created April 5, 2024 20:21
Next.js API Route Handler with error handling
/**
* Represents an error that occurs when data fails to validate against the API's expected schema or requirements.
* This class extends the native JavaScript `Error` class, adding a `statusCode` property to facilitate API error handling.
*
* @example
* // Throws an APIValidationError with a custom message and a 400 Bad Request status code.
* throw new APIValidationError('Invalid user input', 400);
*
* @extends Error
*/
@matthewmorek
matthewmorek / constants.ts
Last active April 13, 2024 23:09
Handling BASE_URLs in Vercel env
const { CI, PORT = 3000, VERCEL_ENV, NEXT_PUBLIC_VERCEL_ENV, VERCEL_URL, NEXT_PUBLIC_VERCEL_URL } = process.env;
export const ENVIRONMENT = VERCEL_ENV || NEXT_PUBLIC_VERCEL_ENV;
const baseDomainSource = CI ? VERCEL_URL : NEXT_PUBLIC_VERCEL_URL;
const baseDomain = baseDomainSource;
let BASE_URL: string;
if (ENVIRONMENT === 'preview') {