RestInModel is a TypeScript-first model-based REST consumer library that maps API responses directly to class instances via decorators. Version 2.1.1 supports ESM and CJS, with no breaking changes from v2.0. It differentiates by allowing declarative API model definitions with automatic type coercion, relation handling, and base URL configuration. Ideal for structured API clients where type safety and model transformation are priorities.
npm install rest-in-modelNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows model definition with Field and HasMany decorators, and fetching related models via async method.
Add 'experimentalDecorators': true to your tsconfig.json compilerOptions.
Explicitly pass the JSON key as first argument to @Field.
Use new MyModel(data) or MyModel.create(data) instead of MyModel(data).
Replace fetch() with action() or resource() methods.
Use @HasMany('Post') rather than @HasMany(Post).Import 'reflect-metadata' at the top of your entry file.
Add import 'reflect-metadata' at the top of your application entry point.
Set 'experimentalDecorators': true in compilerOptions of tsconfig.json.
Install the package via npm install rest-in-model and use named imports: import { Model } from 'rest-in-model'.Ensure @Model decorator is applied to the parent model and @HasMany uses the correct related model name string.