NODERYX
FRAMEWORK v0.7.1

GETTING STARTED

BUILDING

PRODUCTION

DEVICES

REFERENCE

NODERYX / DOCS / REFERENCE
REFERENCE

Framework functions

The public API surface: everything you can import from noderyx-framework, and what each part is for.

01

Creating an application

noderyx(options) builds the application. Options set identity, paths, caching, and security; every one of them has a working default.

server.js
import { noderyx } from "noderyx-framework"; const app = noderyx({ requireAppKey: true, name: config.app.name, environment: config.app.environment, debug: config.app.debug, cache: config.cache, views: "./resources/views", public: "./public", security: config.security });
02

Application methods

The application object is small on purpose.

get / post / put / delete Register a route. Returns the app, so calls chain.
use(middleware) Add middleware, executed in registration order.
provide(name, service) Register a service resolvable from any handler.
service(name) Resolve a service; throws if the name was never registered.
onError(handler) Replace the default error handling.
listen(port, host, callback) Start the HTTP server.
03

The request context

Every handler receives one object carrying input, session state, and response helpers.

request, response The raw Node.js objects, when you need them.
params, query, body, cookies Parsed input.
render, json, text, abort Response helpers.
session Signed, stateless session store.
validate(rules) Validate the body against a rule map.
service(name) Resolve a registered service.
csrfToken, nonce, ip Per-request security values.
setCookie, clearCookie Queue cookies onto the response.
04

Controllers

Controller.handle(action) returns a route handler that constructs the controller per request.

JAVASCRIPT
import { Controller } from "noderyx-framework"; export class PostController extends Controller { async index() { return this.json(await Post.all()); } } app.get("/posts", PostController.handle("index"));
NOTE

Instance API: this.request, this.params, this.query, this.body, this.service, this.json, this.text, this.render, this.abort.

05

Views and compilation

The compiler is exported, so you can render Noderframe outside a request—in a build step, a worker, or a test.

compile(source, data) Compile Noderframe source to HTML.
compileFile(path, data) Compile a file, with production caching.
parse(source) Produce the renderer-agnostic tree.
renderHtml(nodes, data) Render a parsed tree as HTML.
renderNative(nodes, ...) Render a parsed tree as native screens.
interpolate(text, data) Replace {{placeholders}} in a string.
clearCompilerCache() Drop cached parses—useful in tests.
06

Database

One connect() for three engines, plus the Model base class and per-driver adapters when you need them directly.

JAVASCRIPT
import { connect, Model, mysql, postgres, mongo } from "noderyx-framework"; const db = await connect(config.database); Model.use(db);
NOTE

Model statics: table, fillable, use(db), observe(observer), all, find, create, update, delete.

07

Migrations and seeders

The same functions the CLI calls, available for scripts and deployment tooling.

migrate(db, directory) Apply pending migrations.
migrationStatus(db, directory) Report which migrations have run.
rollback(db, directory, steps) Reverse recent migrations.
runSeeders(db, directory, name) Run all seeders, or one by name.
08

Packages

Two functions cover the whole extension system.

JAVASCRIPT
import { definePackage, loadPackages } from "noderyx-framework"; await loadPackages(app, config.packages, { config, discover: true });
09

Security

The primitives behind the defaults, exported so application code can use the same ones.

hashPassword / verifyPassword scrypt hashing and constant-time comparison.
validate(body, rules) Rule-based validation returning valid, values, errors.
generateKey / appKey Create and read the application key.
sign / unsign / safeEqual Signed payloads and constant-time comparison.
csrfToken / verifyCsrf Issue and check CSRF tokens.
securityHeaders / corsHeaders The header sets applied per response.
RateLimiter / clientAddress Limiting, and the address it counts against.
parseCookies / serializeCookie Cookie handling.
securityProfile(name, overrides) Resolve the standard, strict, or banking posture, merged per section.
createApiKey / hashApiKey / verifyApiKey Issue a bearer credential, store only its hash, compare in constant time.
requireApiKey({ lookup, scopes }) Middleware that authenticates a bearer key and sets context.principal.
randomToken(bytes) Cryptographically random token, base64url encoded.
CAPACITOR_ORIGINS The origins a packaged mobile build calls your API from.
10

Configuration helpers

Load the environment and convert its strings into typed values.

JAVASCRIPT
import { loadEnvironment, envBoolean, envNumber, envList } from "noderyx-framework";
11

AI

A provider-independent client, registered as a service and resolved wherever you need it.

JAVASCRIPT
import { ai, AIClient, AIError } from "noderyx-framework"; app.provide("ai", ai(config.ai)); const result = await service("ai").generate(prompt, { reasoningEffort: "low" });
12

Solution and security profiles

Profiles turn the name of a product into tuned cache and security values. Both helpers return a fresh copy, so mutating a result never affects anything else.

solutionProfiles The available names: saas, trading, blog, ecommerce, static, enterprise.
solutionProfile(name) Resolve one to { name, label, description, cache, security }. Accepts aliases and throws on an unknown name.
securityProfile(name, overrides) Resolve standard, strict, or banking, merging overrides per section.
JAVASCRIPT
import { solutionProfile, solutionProfiles } from "noderyx-framework"; solutionProfile("trading").cache; // { ttl: 30, maxItems: 4096, ... }
NOTE

The Solution profiles page covers what each one sets and how the two interact.

13

Mobile and packaged builds

The functions the mobile CLI commands wrap. Call them directly when you need a build step of your own rather than the packaged flow.

mobileOptions(config, overrides) Resolve app id, app name, entry view, views directory, output directory, and API URL.
webDirectory(options) The directory the bundle is written into.
capacitorConfig(options) The generated Capacitor configuration object.
buildMobile(config, overrides, log) Compile views into the mobile bundle. Returns what it wrote; pass a log function to quieten it.
MOBILE_DEFAULTS The defaults every override is applied on top of.
buildNative / themeModule Native screen compilation and theme scaffolding.
compileMNodeFrame / parseMNodeFrame Compile and parse the .mnoderframe payload format.
loadMNodeFrame / runMNodeFrame Load a compiled payload and preview it.
NOTE

.mnoderframe files are generated. Edit the .noderframe view and rebuild rather than changing a payload by hand.

14

Progressive web apps and icons

A packaged build can be installable without a native project at all. These functions produce the manifest, the service worker, and the head tags, and generate icons without an image pipeline.

pwaOptions(overrides) Resolve the PWA settings from PWA_DEFAULTS.
manifest(overrides) The web app manifest object.
serviceWorker(overrides) The service worker source, as a string.
pwaHead(overrides, { skip, nonce }) The head tags to include, honouring the CSP nonce.
injectPwa(html, overrides, nonce) Insert those tags into rendered HTML.
noderyxIcon(size, { maskable }) Generate an icon at a size, optionally maskable.
noderyxSplash(size) Generate a splash image.
encodePng(width, height, paint) Encode a PNG from a paint callback—no image dependency.
ICON_SIZES The sizes a manifest is expected to provide: 192 and 512.
NOTE

pwaHead takes the request nonce because the policy has no unsafe-inline—pass it through or the registration script will not run.

15

Quality checks

The same inspection the qa command runs, exported so a build script, a test, or a CI job can use it without shelling out to the CLI.

inspectProject(config, options) Inspect the project and return a structured report. options.root overrides the working directory.
formatQaReport(report) Render a report as the human-readable text the CLI prints.
JAVASCRIPT
import { inspectProject, formatQaReport } from "noderyx-framework"; const report = await inspectProject(config); console.log(formatQaReport(report)); if (!report.ok) process.exitCode = 1;
NOTE

report.ok is true only when there are no errors—warnings do not clear it. Treat ok as the gate and counts.warnings as advice.

16

What a report contains

The report is plain data, so you can filter it before deciding what should fail a build.

REPORT
{ ok: true, root: "/srv/my-app", checkedFiles: 6, counts: { errors: 0, warnings: 13 }, issues: [ { severity: "warning", code: "view-link", file: "resources/views/home.noderframe", line: 16, message: "Internal link /docs has no matching view.", fix: "Create the view or verify that the server registers this route." } ] }
NOTE

Filtering by code is the practical way to ignore a category: report.issues.filter((issue) => issue.code !== "view-link").

17

Errors and routing internals

The remaining exports are the error type and the router itself.

HttpError The error type abort() throws, with a status and a safe message.
Router The routing table, exported for advanced composition.