Routzie - documentation

Modules in Routzie

Introduction

Routzie provides a set of built-in modules that you can use in your machine code via the require function. These modules help you with templating, validation, and more. You do not need to install them manually—they are available in the runtime.

How to use modules

To use a module, simply call:

const module = require('moduleName')

Available Modules

1. EJS (Embedded JavaScript Templates)

EJS is a powerful templating engine for generating HTML with embedded JavaScript. It uses ejs package.

Usage Example:

const EJS = require('ejs') const html = EJS.render('<h1>Hello <%= name %></h1>', { name: 'World' })

2. Ajv (Another JSON Schema Validator)

Ajv is a fast and flexible JSON schema validator. Use it to validate data against schemas. It uses ajv package.

Usage Example:

const Ajv = require('ajv') const ajv = new Ajv() const schema = { type: 'object', properties: { foo: { type: 'integer' } }, required: ['foo'] } const validate = ajv.compile(schema) const valid = validate({ foo: 123 }) if (!valid) console.log(validate.errors)

3. Cookie

Cookie is a minimal library for parsing and serializing HTTP cookies. Use it to read cookies from headers or create Set-Cookie strings. It uses cookie package.

Usage Example:

const cookie = require('cookie') // Parse cookies from a header string const cookies = cookie.parse('foo=bar; baz=qux') // cookies: { foo: 'bar', baz: 'qux' } // Serialize a cookie for Set-Cookie header const setCookie = cookie.serialize('foo', 'bar', { httpOnly: true, maxAge: 3600 }) // setCookie: 'foo=bar; Max-Age=3600; HttpOnly'

4. Text Encoding Polyfill

Text encoding polyfill provides TextEncoder and TextDecoder classes for encoding and decoding strings to and from UTF-8. It uses text-encoding package.

Usage Example:

const { TextEncoder, TextDecoder } = require('text-encoding') const encoder = new TextEncoder() const encoded = encoder.encode('Hello World!') // Uint8Array const decoder = new TextDecoder() const decoded = decoder.decode(encoded) // "Hello World!"

5. URL Polyfill

URL polyfill provides URL and URLSearchParams classes for working with URLs and query parameters. Its using whatwg-url package.

Usage Example:

const { URL, URLSearchParams } = require('whatwg-url') const url = new URL('https://example.com/search?q=hello') const params = new URLSearchParams(url.search) const query = params.get('q') // "hello"

Notes

  • All modules are available globally in the Routzie runtime.
  • Use TypeScript typings for autocompletion and type safety.
  • More modules may be added in the future—check documentation for updates.

© 2025 Routzie Routzie.com