Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18.1.0-alpine
FROM oven/bun:alpine

RUN apk update \
&& apk --no-cache --update add bash
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ The JSON schemas for the CLI related entities and the schema model.

## Host schema locally

To host this schema locally, have Node (v14.2.0) installed and run `npm start` from the root of this project.
You can then visit http://localhost:9797/bettyblocks/json-schema/master/schemas/actions/function.json to view the schema in the browser.
To host this schema locally, have [Bun](https://bun.com/docs/installation) installed and run `bun run start` from the root of this project.
You can then visit http://localhost:9797/schemas/actions/function.json to view the schema in the browser.

## VSC

Expand Down
174 changes: 174 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"name": "json-schema",
"module": "./server.ts",
"type": "module",
"scripts": {
"start": "node server.js",
"dev": "nodemon server.js"
"start": "bun run server.ts",
"dev": "bun run --watch server.ts"
},
"dependencies": {
"express": "^4.18.1"
"express": "^5.1.0"
},
"devDependencies": {
"nodemon": "^2.0.16"
"@types/express": "^5.0.3",
"typescript": "^5.9.2"
}
}
4 changes: 2 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

set -e

yarn --frozen-lockfile
yarn start
bun install --frozen-lockfile
bun start
6 changes: 5 additions & 1 deletion schemas/actions/function.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
"type": "string",
"description": "The name of the function that is exported in the wit file"
},
"wit": {
"type": "string",
"description": "The wit file of the wasm component"
},
"interface": {
"type": "object",
"additionalProperties": false,
Expand All @@ -95,7 +99,7 @@
"required": ["name", "package"]
}
},
"required": ["functionName", "interface"]
"required": ["functionName", "interface", "wit"]
}
},
"anyOf": [
Expand Down
2 changes: 1 addition & 1 deletion schemas/actions/function/option.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"name": {
"description": "The name of the option. Can be used to reference this option. Should be unique within scope of function.",
"type": "string",
"pattern": "^(?![0-9])[a-zA-Z0-9_]+$"
"pattern": "^(?![0-9])[a-zA-Z0-9_-]+$"
},
"label": {
"description": "The label for option, as shown in the IDE.",
Expand Down
12 changes: 6 additions & 6 deletions server.js → server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const express = require("express");
const fs = require("fs");
const path = require("path");
import express, { type Request, type Response } from "express";
Copy link
Copy Markdown
Contributor

@thomas9911 thomas9911 Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if we use Bun.serve instead of express? (zero deps!)

import fs from "node:fs";
import path from "node:path";

const SCHEMA = "http://json-schema.org/draft-07/schema";
const HOST = "https://raw.githubusercontent.com";
Expand All @@ -9,7 +9,7 @@ const PORT = 9797;

const app = express();

const serve = (request, response, file) => {
const serve = (request: Request, response: Response, file: string) => {
console.log("Request for: ", request.url);
console.log("Serving: ", file);

Expand All @@ -21,7 +21,7 @@ const serve = (request, response, file) => {
response.status(500).send("Internal Error: " + error.code + " ..\n");
}
} else {
const protocol = request.headers.host.includes("localhost")
const protocol = request.headers.host?.includes("localhost")
? request.protocol
: "https";

Expand All @@ -41,7 +41,7 @@ app.get("/schema", (request, response) =>
serve(request, response, path.join(process.cwd(), "schema.json"))
);

app.get("*", (request, response) => {
app.get("/*splat", (request, response) => {
serve(request, response, path.join(process.cwd(), request.url));
});

Expand Down
19 changes: 19 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"allowImportingTsExtensions": true,
"allowJs": true,
"baseUrl": ".",
"lib": ["ESNext"],
"module": "ESNext",
"moduleDetection": "force",
"moduleResolution": "bundler",
"noEmit": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true,
"skipLibCheck": true,
"strict": true,
"target": "ESNext",
"verbatimModuleSyntax": true
},
"exclude": ["node_modules"]
}
Loading