Skip to content

Server

Nubo can run .nubo files as HTTP endpoints with the nubo serve command.

Terminal window
nubo serve app

A server can serve either:

TargetBehavior
A single .nubo fileEvery request runs that file.
A directoryNubo builds routes from the files inside the directory.

When a request reaches a Nubo executable file, the server injects these built-in server modules:

ModuleDescription
@server/requestRequest method, headers, path, params, query, cookies, body, JSON, form data, and file uploads.
@server/responseStatus, headers, body writing, JSON, cookies, redirects, and response buffer control.
@server/errorAvailable inside error.nubo for custom error pages.

Create a file named index.nubo:

import request from "@server/request"
import response from "@server/response"
response.write(<h1>Hello from Nubo</h1>)

Start the server:

Terminal window
nubo serve .

Open:

http://localhost:3000
PageDescription
Getting StartedStart a Nubo HTTP server.
RoutingFile-based routes, index routes, dynamic params, and static files.
RequestRead request data from @server/request.
ResponseSend responses with @server/response.
ErrorsDefault errors, custom error.nubo, and JSON error output.
Static FilesServe non-executable files.
CacheParsed AST cache behavior.
LoggingDevelopment request logs.
ConfigurationServer config values.
ExamplesComplete examples.