Isomor Core

raw JSON →
3.0.0 verified Fri May 01 auth: no javascript

Core library for isomor, a tool that abstracts frontend-backend communication in web applications by allowing direct server function calls from UI code without REST or GraphQL. Version 3.0.0 is current; the project uses a rolling release cadence. Key differentiators include automatic layer generation via Babel transpilation, tight code coupling, and TypeScript consistency. Isomor eliminates boilerplate and reduces overhead by keeping all code in a single project. The core package provides essential utilities and types.

error Error [ERR_REQUIRE_ESM]: require() of ES Module
cause Using CommonJS require() with an ESM-only package.
fix
Switch to ES modules: use import statements or rename .js to .mjs.
error TypeError: isomor is not a function
cause Using default import instead of named import, or using wrong import syntax.
fix
Use import { isomor } from 'isomor-core'.
error The requested module 'isomor-core' does not provide an export named 'default'
cause Trying to import default export when only named exports exist.
fix
Use import { isomor } from 'isomor-core' instead of import isomor from 'isomor-core'.
breaking v3.0.0 removes support for Node.js versions < 11. Ensure your environment uses Node.js >= 11.
fix Upgrade to Node.js >= 11.
gotcha All exports are ESM-only; using require() will throw an error.
fix Use import statements instead of require().
deprecated The `isomor` default export is deprecated; use named import instead.
fix Replace `import isomor from 'isomor-core'` with `import { isomor } from 'isomor-core'`.
gotcha TypeScript type imports must use `import type` to avoid runtime side effects.
fix Use `import type { ... } from 'isomor-core'` for type-only imports.
gotcha The `handler` export expects an object with async functions; passing synchronous functions may cause unexpected behavior.
fix Ensure all handler methods return a Promise or use async/await.
npm install isomor-core
yarn add isomor-core
pnpm add isomor-core

Demonstrates calling a server function directly using isomor and defining a handler on the server side.

import { isomor, handler } from 'isomor-core';

const apiKey = process.env.API_KEY ?? 'default-key';

async function main() {
  const result = await isomor({
    url: '/api/greet',
    method: 'POST',
    headers: { 'X-API-Key': apiKey },
    body: { name: 'World' },
  });
  console.log('Result:', result);
}

handler({
  greet: async (name: string) => `Hello, ${name}!`,
});

main();