- Overview
- Routing
- Proxy Routes
- React
- Quick Start
- Fetching Data from API
- fetch() API
- Populating Page's Head
- Importing CSS/Sass
- TypeScript
- Excluding Bundle from Client-Side
- Markdown and MDX
- Node.js / JavaScript
- Query Parameters
- POST, PUT, PATCH, DELETE Methods
- Dynamic Routes (Pretty URL Slugs)
- fetch() API
- TypeScript
- Sessions
- CORS and Express Middlewares
- HTML
- Vue
- Svelte
- Static Files
- Python
- Before You Start
- Printing To Console
- JSON Response
- URL Parameters
- Requirements.txt
- Dynamic Routes (Pretty URL Slugs)
- POST Data
- File Upload
- Deployment
- Security
- How Zero Works
How Zero Works
Overview
Zero Server is designed to be modular, so it can support other languages and frameworks in the future. To accomplish this, zero runs each "page" using the handler for that file's extension. Think of it as microservices but locally.
To explain this, let's consider the basic example:
A project directory containing two files index.jsx
and time.js
. When you run zero
in this directory, it does a few things on start:
Loop through all files in the folder and categorize them based on their extension to their respective handler type. Like
index.jsx
will be categorized asreact
type andtime.js
will be handled byjs
.For supported files (
js, jsx, md, mdx
), resolve their dependencies and install allnpm
packages.Generate a map of all possible page routes to their respective entry file.
/
will point to./index.jsx
and/time
to./time.js
.Start the HTTP server.
After this, if you open the http://localhost/time
in the browser, this happens inside zero:
- Check the lookup to find which file corresponds to
/time
path (sotime.js
in this case). - Check if a builder is available to this type of page (in this case
js
pages are bundled using babel). If so, run the builder and wait for it to build. The builder can keep running to facilitate HMR or equivalent. The builder returns with information about the generated build. - After this, load the relevant handler (in this case
handler-js
) and provide all page data and build info for this request.