Utilities

A reference for all built-in utilities Thunder provides out of the box.

Thunder ships with a set of production-ready utilities that address the most common needs of any server application. These utilities are available out of the box — no additional installation required.


createCRUD

Instantly generates a complete CRUD API for any router, schema, and model combination. Supports disabling individual methods and injecting isolation fields for per-user data scoping.

import { createCRUD } from "@/core/crud.ts";

See the full createCRUD documentation for usage details.


denoConfig

Provides access to your project's deno.json configuration at runtime. Useful for reading project metadata, import maps, or custom configuration values stored in your Deno config file.

import { denoConfig } from "@/core/deno-config.ts";

const config = await denoConfig();
console.log(config.name); // your project name

ejsRenderer

Renders EJS templates to HTML strings. Useful for server-side rendering of emails, admin views, or any templated HTML content.

import { ejsRenderer } from "@/core/ejs.ts";

const html = await ejsRenderer("templates/welcome.ejs", {
  name: "Alice",
  appName: "Thunder App",
});

return new Response(html, {
  headers: { "Content-Type": "text/html" },
});

envProvider

Bootstraps and initializes the environment variable system for your Thunder application. This utility is used internally during startup, but you can also call it explicitly to reload environment variables in test contexts.

import { envProvider } from "@/core/env-provider.ts";

await envProvider();

For reading individual environment variables in your application code, use the Env utility class instead.


hashProvider

Provides secure, one-way hashing and hash verification. Built on top of Deno's native cryptographic APIs, hashProvider is the recommended way to hash passwords and other sensitive values in Thunder.

import { hashProvider } from "@/core/hash.ts";

// Hash a password
const hashed = await hashProvider.hash("my_secure_password");

// Verify a password against a hash
const isValid = await hashProvider.verify("my_secure_password", hashed);

Logger

A structured logging utility with colour-coded output for each severity level. Use Logger instead of console.log to maintain consistent, readable log output across your application.

import { Logger } from "@/core/logger.ts";

Logger.success("Server started on port 3742");
Logger.info("Connecting to database...");
Logger.warn("Deprecated configuration option used");
Logger.error("Failed to connect to database");
MethodUse Case
Logger.success(msg)Successful operations (e.g. startup, insert)
Logger.info(msg)General informational messages
Logger.warn(msg)Non-critical warnings
Logger.error(msg)Errors and exceptions

parseQueryParams

Parses URL query string parameters from a Request object and returns them as a typed plain object. This is a lower-level alternative to using queryAsJson with Zod parsing inside a route handler.

import { parseQueryParams } from "@/core/http/utils.ts";

const params = parseQueryParams(req);
// { page: "1", limit: "20", search: "thunder" }

For validated query parsing inside route handlers, prefer queryAsJson combined with a Zod schema via $query.parse(queryAsJson(req)). Use parseQueryParams when you need raw, unvalidated access to query string values.


On this page