Utilities
import { ... } from "@95octane/common/utils"
MyError
Structured error class used across the entire codebase.
new MyError({
caller: "UserService.get",
code: "USER_NOT_FOUND",
ctx: { userId },
error: "User not found",
level: "WARN",
stack: new Error("stack").stack ?? "",
status: StatusCodes.NOT_FOUND,
});
Properties: code, message, _tag, status, ctx, level, caller,
stack
MyError.fromError(error, options) — Converts any error to MyError, passing
through unchanged if already a MyError.
Logging
Effect-integrated structured logging with OpenTelemetry trace correlation.
| Function | Level | Signature |
|---|---|---|
logDebug |
DEBUG | (caller, message, context) |
logInfo |
INFO | ({caller, message, state}) |
logWarn |
WARN | (caller, message, state) |
logError |
ERROR | (myError) |
logFatal |
FATAL | (myError) |
All log entries include trace ID and span ID when available.
HTTP Client
Promise-based HTTP client with Effect Schema validation.
| Function | Description |
|---|---|
httpGet |
GET request with response schema validation |
httpPost |
POST request with response schema validation |
httpDelete |
DELETE request with response schema validation |
Other Utilities
| Function | Description |
|---|---|
generateId(length?) |
Nanoid-based URL-safe ID (default 21 chars) |
nullSafe(input, def) |
Type-safe null/undefined coalescing |
readFile(path) |
Read file with existence/emptiness checks |
getAppDetails(folder) |
Extract name/version from nearest package.json |
isRequestSuccessful |
Returns true for 2xx status codes |
StatusCodes |
Comprehensive HTTP status code enum |