GitHub GitHub
docs / Overview

Overview

LiteNode is a zero-dependency Node.js web framework built for developers who want a clean, expressive API without the weight of a larger framework. It ships with everything you need for production — routing, middleware, body parsing, cookies, static file serving, environment variables, an AST-based template engine, and built-in Markdown support — all in a single npm install. No configuration required, no plugin ecosystem to navigate, no surprises.


What's Included

Feature Description
Routing GET, POST, PUT, DELETE, PATCH, named params, optional params, wildcards, catch-all
Response Methods txt(), html(), xml(), json(), sendFile(), redirect(), status()
Middleware Global via use(), per-route inline, scoped to merged/nested routers
Error Handling onError() for runtime errors, notFound() for 404s
Body Parsing JSON, URL-encoded, and multipart/form-data — automatic, no setup
Cookies Parse, set, clear, and sign cookies with HMAC verification
Static Files Auto-served directory with ETag caching and live file watching
Env Variables Native .env loading with type conversion and multi-environment support
Merge & Nest Compose modular routers with merge() and nest()
Templating (STE) AST-based engine for variables, conditionals, loops, includes, and filters
STE Filters 40+ built-in filters for formatting, sorting, grouping, and transforming data
Markdown Parse files, extract frontmatter, paginate, group, and generate TOC

Quick Start

1. Install

npm install litenode

2. Set your package type

{
    "type": "module"
}

3. Create your server

import { LiteNode } from "litenode"

const app = new LiteNode()

app.get("/", (req, res) => {
    res.end("Hello, LiteNode!")
})

app.startServer()

4. Run it

node index.js
# → App @ http://localhost:5000

Visit http://localhost:5000 and you'll see Hello, LiteNode!.


A Slightly More Complete Example

import { LiteNode } from "litenode"

const app = new LiteNode()

// Load environment variables
app.loadEnv()

// Global logger middleware
app.use(async (req, res) => {
    console.log(`[${req.method}] ${req.url}`)
})

// Routes
app.get("/", (req, res) => {
    res.render("layouts/index.html", { title: "Home" })
})

app.get("/api/users/:id", (req, res) => {
    res.json({ id: req.params.id })
})

app.post("/api/users", (req, res) => {
    const data = req.body
    res.status(201).json({ created: data })
})

// Error handlers
app.onError(async (err, req, res) => {
    res.status(500).json({ error: err.message })
})

app.notFound(async (req, res) => {
    res.status(404).render("layouts/404.html", { title: "Not Found" })
})

app.startServer(app.getEnv("PORT", 5000))

Next Steps

The recommended reading order follows the natural flow of building an application:

  1. Starting the Server — ports, options, and the server instance
  2. Routing — defining routes and handling parameters
  3. Response Methods — sending the right response
  4. Middleware — cross-cutting logic
  5. Error Handling — handling failures gracefully
  6. Body Parsing — working with POST data and file uploads
  7. Cookies — session and state management
  8. Static Files — serving assets
  9. Env Variables — configuration management
  10. Merge & Nest — scaling with modular routers
  11. Templating — rendering HTML with STE
  12. STE Filters — the full filter reference
  13. Markdown — building content-driven applications

Or jump straight to the Examples page to see everything in action.