Skip to content
Merged
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
17 changes: 17 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

131 changes: 65 additions & 66 deletions packages/example-wormhole/src/features/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,80 +5,79 @@ import route, { query } from "@vortexjs/wormhole/route";
import * as v from "valibot";

route("/", {
page() {
useAction({
name: "Show Alert",
shortcut: "shift+b",
run() {
alert("Action triggered!");
}
})
page() {
useAction({
name: "Show Alert",
shortcut: "shift+b",
run() {
alert("Action triggered!");
}
})

const currentTime = time.use({});
const currentTime = time.use({});

return (
<>
<DOMKeyboardActions />
<h1 class="text-4xl font-bold">
Welcome to Wormhole, {Object.entries(globalThis).length}
</h1>
<p>
This is an example app, go to the{" "}
<a href="/docs/tada">docs</a>, current time is {currentTime}
</p>
<button on:click={async () => {
console.log(await add({
a: 1,
b: 2
}))
}}>
add
</button>
</>
);
},
layout({ children }) {
return (
<>
<title>Wormhole Example</title>
{children}
</>
);
},
notFound() {
return (
<>
<h1>404 not found</h1>
</>
)
}
return (
<>
<DOMKeyboardActions />
<h1 class="text-4xl font-bold">
Welcome to Wormhole, {Object.entries(globalThis).length}
</h1>
<p>
This is an example app, go to the{" "}
<a href="/docs/tada">docs</a>, current time is {currentTime}
</p>
<button on:click={async () => {
console.log(await add({
a: 1,
b: 2
}))
}}>
add
</button>
</>
);
},
layout({ children }) {
return (
<>
<title>Wormhole Example</title>
{children}
</>
);
},
notFound() {
return (
<>
<h1>404 not found</h1>
</>
)
}
});

route("/docs", {
page({ }) {
const page = "introduction";
return (
<>
<h1>Documentation for {page}</h1>
<p>This is the documentation page for {page}.</p>
</>
);
},
route("/docs/[page]", {
page({ page }) {
return (
<>
<h1>Documentation for {page}</h1>
<p>This is the documentation page for {page}.</p>
</>
);
},
});

export const add = query("/api/add", {
schema: v.object({
a: v.number(),
b: v.number()
}),
impl({ a, b }) {
return a + b;
}
schema: v.object({
a: v.number(),
b: v.number()
}),
impl({ a, b }) {
return a + b;
}
})

export const time = query("/api/time", {
impl() {
return new Date().toISOString();
},
schema: v.object({})
impl() {
return new Date().toISOString();
},
schema: v.object({})
});
34 changes: 34 additions & 0 deletions packages/vindicator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# dependencies (bun install)
node_modules

# output
out
dist
*.tgz

# code coverage
coverage
*.lcov

# logs
logs
_.log
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# caches
.eslintcache
.cache
*.tsbuildinfo

# IntelliJ based IDEs
.idea

# Finder (MacOS) folder config
.DS_Store
33 changes: 33 additions & 0 deletions packages/vindicator/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# dependencies (bun install)
node_modules

# output
out
*.tgz

# code coverage
coverage
*.lcov

# logs
logs
_.log
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# caches
.eslintcache
.cache
*.tsbuildinfo

# IntelliJ based IDEs
.idea

# Finder (MacOS) folder config
.DS_Store
9 changes: 9 additions & 0 deletions packages/vindicator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Vindicator

Vercel's Build Output API is quite possible the most poorly documented, unintuitive, and downright frustrating protocol I've ever had the displeasure of working with. Vindicator is my attempt to make it a little less painful.

## What does it do?

Vindicator takes nice, clean steps for your routing code, and converts them into the bizarre, convoluted JSON format that Vercel expects.

Polar is to Stripe as Vindicator is to Vercel's Build Output API.
29 changes: 29 additions & 0 deletions packages/vindicator/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@vortexjs/vindicator",
"type": "module",
"license": "MIT-0",
"repository": {
"url": "https://github.com/andylovescode/vortex"
},
"devDependencies": {
"@types/bun": "catalog:",
"tsdown": "catalog:"
},
"dependencies": {
"@vortexjs/common": "workspace:*"
},
"peerDependencies": {
"typescript": "catalog:"
},
"scripts": {
"build": "tsdown ./src/index.ts --format esm --dts --out-dir dist"
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"version": "0.0.1"
}
28 changes: 28 additions & 0 deletions packages/vindicator/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { Config, Route } from "./types-vercel";
import type { MatchStep } from "./types-vindicator";

export * as Vercel from "./types-vercel";
export * from "./types-vindicator";

export function vindicate(props: { steps: MatchStep[] }): Config {
const routes: Route[] = [];

for (const step of props.steps) {
if (step.type === "all-filesystem") {
routes.push({
handle: "filesystem",
});
}
if (step.type === "route") {
routes.push({
src: step.path,
dest: step.func,
});
}
}

return {
routes,
version: 3,
};
}
Loading