GitHub GitHub
docs / Usage

Usage

LiteNode is a minimal Node.js web framework with zero external dependencies.

Installation

npm install litenode

Basic Usage

import { LiteNode } from "litenode"

const app = new LiteNode()

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

app.startServer()

This starts a server on port 5000 by default. Visiting http://localhost:5000 responds with Hello, LiteNode!.

Information Breaking change in v4.0.0: The integrated Simple Template Engine (STE) was upgraded to a more powerful AST-based engine with a unified tag signature. See the Templating documentation for details.

ES Modules

LiteNode is published as an ES module. Make sure your package.json includes:

{
    "type": "module"
}

Custom Directories

By default, LiteNode serves static files from ./static and renders templates from ./views. You can override both:

// Custom static dir + custom views dir
const app = new LiteNode("public", "templates")

// Disable static file serving entirely
const app = new LiteNode("__NO_STATIC_DIR__")

Console Output

On start, LiteNode prints the server address and reports the status of the static directory:

# If ./static exists:
App @ http://localhost:5000

# If ./static is missing:
Error while reading static directory: "static" directory doesn't exist!
LiteNode will continue running without serving static assets.
App @ http://localhost:5000

The warning is expected when you haven't created a static directory yet. See Serving Static Files to learn more.