Essential helper classes for common tasks like hashing, encryption, collections, and more.
Use Bcrypt for secure password hashing.
1import { Hash } from "canxjs";23// Hash a password4const hashedPassword = await Hash.make("password123");56// Verify a password7if (await Hash.check("password123", hashedPassword)) {8// Passwords match9}
Two-way encryption using AES-256-CBC.
1import { Encrypt } from "canxjs";23// Encrypt data4const encrypted = Encrypt.make("Sensitive Data");56// Decrypt data7const decrypted = Encrypt.audit(encrypted);
Fluent wrapper for working with arrays of data, inspired by Laravel Collections.
1import { collect } from "canxjs";23const users = [4{ id: 1, name: "Alice", role: "admin" },5{ id: 2, name: "Bob", role: "user" },6];78const admins = collect(users)9.where("role", "admin")10.map(user => user.name)11.all(); // ["Alice"]
Send an object through a series of "pipes" (middleware/actions).
1import { Pipeline } from "canxjs";23const result = await Pipeline4.send(request)5.through([6AuthMiddleware,7ValidationMiddleware,8LoggingMiddleware9])10.thenReturn();
Manage multiple versions of your API with ease.
1import { ApiVersioning } from "canxjs";23// In your app setup4ApiVersioning.enable({5type: 'uri', // or 'header', 'media-type'6defaultVersion: 'v1',7prefix: 'v'8});
Convenient global functions available throughout your application.
| Helper | Description |
|---|---|
| view(name, data) | Render a JSX view |
| env(key, default) | Get environment variable |
| abort(code, msg) | Throw an HTTP exception |
| redirect(url) | Create a redirect response |
1import { Str } from "canxjs";23const slug = Str.slug("Hello World"); // "hello-world"4const id = Str.randomUuid(); // "a1b2..."5const random = Str.randomString(16); // "Ab3..."