Skip to content

Instantly share code, notes, and snippets.

View waynesbrain's full-sized avatar
😄
Class-2 psychic mutant / mentalist

Waynesbrain waynesbrain

😄
Class-2 psychic mutant / mentalist
View GitHub Profile
@waynesbrain
waynesbrain / _package.json
Created August 1, 2025 03:00
Script to generate some JSON Schemas from OpenAPI 3.1
{
"scripts": {
"generate-api": "openapi-typescript http://localhost:54321/api/yada/v1/openapi/schema.json -o ./src/platform/client/api.gen.ts",
"generate-client": "npm run generate-api && node ./bin/generate-client-schemas.mjs",
},
"dependencies": {
"openapi-fetch": "^0.14.0",
},
"devDependencies": {
"openapi-typescript": "^7.8.0",
@waynesbrain
waynesbrain / 1-resource.ts
Last active July 18, 2025 04:17
Generic resource functions for Drizzle.
/** @file Resource helpers. */
import {
type QueryPromise,
type SelectedFields,
and,
asc,
desc,
count,
eq,
ilike,
@waynesbrain
waynesbrain / README.md
Last active July 15, 2025 15:29
My OpenAPI, Scalar setup for Hono

My OpenAPI Scalar setup for Hono

You can see how Scalar is integrated on line ~125 of lib/openapi/docs.ts (Shown here as lib-openapi-docs.ts)

I may have not included every module that's needed for this system because it's unreleased.

Also, hono-openapi is not being used at all, I developed my own system which is included below.

But, that should not matter too much - the principles should be the same.

JSON Server Resource Helpers for Drizzle ORM

The REST Dialect used by this project is inspired by the current stable version of JSON Server similarly to how it's implemented in the React Admin ra-data-json-server package.

It is NOT REQUIRED to match the ra-data-json-server method names such as getList,getOne, etc. in any server/client function/operation identifier/etc.

@waynesbrain
waynesbrain / generate-client-schemas.mjs
Last active May 11, 2025 01:23
Script to generate AJV compatible JSON Schema typescript object modules from an OpenAPI 3 schema.
#! /usr/bin/env node
/**
* @file Generates ajv compatible JSON Schema definitions for combining schemas
* with $ref. Required by the frontend for form validation with ajv. See:
*
* - https://ajv.js.org/guide/combining-schemas.html#combining-schemas-with-ref
*
* Modules generated into frontend/src/platform/client/schemas/ should import
* the `operations` from "../api.gen" as shown below, with any related,
* referenced schemas defined in a `definitions` property. See also, existing