Instead of checks like:
if (value === null) {
throw new Error("missing value")
}
doSomethingThatNeedsValue(value)| <link rel="shortcut icon" width=32px> | |
| <canvas style="display: none" id="loader" width="16" height="16"></canvas> | |
| <script> | |
| class Loader { | |
| constructor(link, canvas) { | |
| this.link = link; | |
| this.canvas = canvas; | |
| this.context = canvas.getContext('2d'); | |
| this.context.lineWidth = 2; |
| ":" //#;exec /usr/bin/env node --input-type=module - $@<$0 | |
| import process from 'process' | |
| const { argv } = process | |
| console.log(argv) |
| /* Using a JavaScript proxy for a super low code REST client */ | |
| // via https://dev.to/dipsaus9/javascript-lets-create-aproxy-19hg | |
| // also see https://towardsdatascience.com/why-to-use-javascript-proxy-5cdc69d943e3 | |
| // also see https://github.com/fastify/manifetch | |
| // also see https://github.com/flash-oss/allserver | |
| // and https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb | |
| const createApi = (url) => { | |
| return new Proxy({}, { | |
| get(target, key) { |
| let fs = require("fs"); | |
| // TODO: Make it configurable based on publicPath and assetsBuildDirectory | |
| function inlineCssMiddleware() { | |
| /** | |
| * | |
| * @param {import("express").Request} req | |
| * @param {import("express").Response} res | |
| * @param {import("express").NextFunction} next | |
| */ |
| #!/usr/bin/env bash | |
| npm outdated | grep -Eo '@remix-run/[-a-z]+' | uniq | xargs npm up |
| import { riff, route, html, indexRoute } from "../riff/riff.mjs"; | |
| import { serve } from "../riff/riff-express.mjs"; | |
| import { | |
| deleteTask, | |
| getProjects, | |
| getTasks, | |
| getUser, | |
| sendEmail, | |
| updateTask, | |
| createTask, |
| // https://crontab.guru/ | |
| // https://www.typescriptlang.org/play?ts=4.9.5#code/C4TwDgpgBAwgSgeQHJQLxQAYBIDe9kB0AogB5gBOEAzlQJYD2AdgL5S75LFmU0Mtt5EnUhWp0mrdkK6jeEgRxk9xLDAG4AUAHotUPVAB6Afg0bQkKABVqwAIxpY0gBIBXALYBDRgB4ARAGYABigATigAKgiI3wA+TR19QxMzcGhrKmAAJgdFV08fX0iwyJLY+N19Y1NzNJt-HOd3Lz9wrXriqPCy7Qq9KpSLdOAAFgbCPObCtoitUZLouJ7E-pqrGwBWMc4Jgtb6+dLFhMrk1aGANi2CHZaZ-c7u477T1LWMgHYrm99bTdbsg6PXpJaqvIYADi+TV2UXuXSOwJWYJsYXQuWhtxK00O5WWL0GNlswTRjXymKg+y0AKBeNBBIytnsJPGGMKsJm2WGNJOdNqDOyzO2rOCmUpAOxs25z15bzs9UF11ZYVFHLuUC5CNpAz5dlGCu+rV+M0ukX2UpB2tlRv1rIOFIWuJ5SwAtK6AMYuYCu52mAAmEDdABsPJQoIwPG5qGAPG7oBwoDgNHoIGR6ORgFBViJlHwHABycJ5qAAHzD7gARhByCXMK1cIwK1XmOpTMnU+nM68bpYoCngBBGL6qI5kDEHEnElZeyR+4Ph9gcLRGAAzKtQACykkXK7XTi3S9X1YAIpuBAe1+vT7hz8eAOrNieTqBGKy0SPeJwAGnXY77A6HmDXju1Y9n+c5QBk5BLgA5g+T6JC+R4eCA3iXp+UAnuhR63r+M7-vOQGHhh06zgBkEwXB8EIcRYEAb4vhQI+VH6C+lhMcxUAAFyATglisEwAhHpRHHcYwEAAG5Vuxk6iRJUlUbJknkJoE4JN6jETmcb4QB+9AuOQ6HrkunoQGO6BMUZDb9iR+FQAWRbSS+Th6dWtHDvZegvnmcnkCAUBuMZ-ZFgk8wAPpQOFoXSdxzn6TZ4ELjeUBOPFAENm4 |
| export type PerformanceServerTimings = Record< | |
| string, | |
| Array<PerformanceServerTiming> | |
| > | |
| /** | |
| * Run this on the server to get a `time` function that can be used to time | |
| * server-side operations and add them to the `Server-Timing` header. | |
| */ | |
| export function getServerTiming() { |
| import { useCallback, useMemo, useState } from 'react'; | |
| const useValidator = <T extends Record<string, string>>(validator: () => T) => { | |
| const [errors, setErrors] = useState<Partial<T>>({}) | |
| return useMemo(() => ({ | |
| validate: () => { | |
| setErrors(validator()) | |
| return Object.values(errors).every((x) => !x) | |
| }, |