Routing
When serving a directory, Nubo builds routes from files in that directory.
nubo serve appExecutable Routes
Section titled “Executable Routes”A file ending in .nubo is executable.
app/ index.nubo about.nuboRoutes:
| File | Route |
|---|---|
app/index.nubo | / |
app/about.nubo | /about |
The .nubo extension is removed from the URL.
Index Routes
Section titled “Index Routes”Files named index.nubo become the folder route.
app/ index.nubo docs/ index.nuboRoutes:
| File | Route |
|---|---|
app/index.nubo | / |
app/docs/index.nubo | /docs |
Dynamic Routes
Section titled “Dynamic Routes”Use square brackets for route parameters.
app/ users/ [id].nuboRoute:
/users/123Inside users/[id].nubo, read the parameter with request.param.
import request from "@server/request"import response from "@server/response"
let id = request.param("id")
response.write("User ID: ")response.write(id)Exact Routes Before Param Routes
Section titled “Exact Routes Before Param Routes”Nubo prefers exact matches before dynamic parameter matches.
app/ users/ settings.nubo [id].nuboRoutes:
| URL | Matched File |
|---|---|
/users/settings | users/settings.nubo |
/users/123 | users/[id].nubo |
Static Files
Section titled “Static Files”Files that do not end in .nubo are not executed. They are served as static files.
app/ index.nubo style.css logo.pngRoutes:
| File | Behavior |
|---|---|
index.nubo | Executed by Nubo. |
style.css | Served as a static file. |
logo.png | Served as a static file. |
Missing Routes
Section titled “Missing Routes”If no route matches, Nubo tries built-in static files. If that fails, the request becomes a 404 Not Found.
If your app has an error.nubo file, Nubo can use it as a custom error page.