This lesson will be brief, yet it is crucial for understanding the logic of pathing in Vixeny. We’ll explore the granular power you have to manipulate your code.
We fully support wildcards static and dynamic pathing using the following order:
/api/first
)/api/:second
)/static/html/*
-> /static/*
-> /*
)import { wrap } from "vixeny";
const app = await wrap()()
.get({
path: "/api/first",
f: () => "one",
})
.get({
path: "/api/:second",
f: () => "two",
})
.get({
// Becomes default case
path: "/*",
f: () => "default",
})
.testPetitions();
// Logs `one two default`
console.log(
await app('/api/first').then(async res => await res.text()),
await app('/api/anyValues').then(async res => await res.text()),
await app('/randomValue').then(async res => await res.text()),
)
We fully support wildcards /path/*
using the following order:
/
, /user
, /user/:id
)/static/html/*
-> /static/*
-> /*
)This means that real paths
are prioritized over wildcards, which reflect other nested wildcards.
import { wrap } from "vixeny";
const app = await wrap()()
.get({
path: "/api/first",
f: () => "one",
})
.get({
path: "/api/*",
f: () => "two",
})
.get({
// Becomes default case
path: "/*",
f: () => "default",
})
.testPetitions();
// Logs `one two default`
console.log(
await app('/api/first').then(async res => await res.text()),
await app('/api/anyValues').then(async res => await res.text()),
await app('/randomValue').then(async res => await res.text()),
)