Registry / database / http-api-orm

http-api-orm

JSON →
library1.3.0jsnpmunverified

http-api-orm is an API ORM library for TypeScript, inspired by database ORMs. Version 1.3.0. It treats each API endpoint as a model, with Axios under the hood for HTTP requests. Key differentiators: it provides an ApiModel base class to configure request parameters, manage response data, and chain interceptors in order. Includes a Params class with proxyData() for reactive Vue 3 integration. Requires axios > 0.22.0 and lodash-es > 4.0.0 as peer dependencies.

npm install http-api-orm
INSTALL
IMPORT
SIG · HTTP-API-ORM
H
http-api-orm
databasejavascriptv1.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ApiModel
import ApiModel from 'http-api-orm'
const ApiModel = require('http-api-orm')
This is the default export. Use ESM import.
Params
import { Params } from 'http-api-orm'
import Params from 'http-api-orm'
Params is a named export, not default.
ApiResponseMid
import type { ApiResponseMid } from 'http-api-orm/types/lib/ApiModel'
import { ApiResponseMid } from 'http-api-orm'
ApiResponseMid is a type, use import type.

Shows how to define an API model with URL, params, and data, then make a request.

import ApiModel, { Params } from 'http-api-orm'; class MyApi extends ApiModel { url = '/api/endpoint'; params = new Params(() => ({ id: '', detail: true })); data = { name: '', age: 0 }; } const api = new MyApi(); api.params.data.id = '123'; api.getResData().then(r => { console.log(r.data); });
Debug
Known issues
gotchaParams.data is nested inside params object. To access the actual parameters, use params.data.
fix
Use api.params.data.id instead of api.params.id
affects: >=1.0.0
gotchaproxyData() on Params creates a proxy that accesses the underlying data. Assignments may not trigger Vue reactivity unless used with reactive().
fix
Wrap with reactive() when using in Vue: const api = reactive(new MyApi());
affects: >=1.0.0
deprecatedDirectly exporting type ApiResponseMid from main entry is deprecated; use the type file.
fix
Use import type { ApiResponseMid } from 'http-api-orm/types/lib/ApiModel'
affects: >=1.2.0
gotchaAxios version 0.22.0 or higher is required; using older versions may cause type mismatch.
fix
Install axios@^0.22.0
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'http-api-orm' or its corresponding type declarations.
TypeScript project not configured to resolve ESM packages.
fix
Set moduleResolution to 'node' or 'node16' in tsconfig.json.
TypeError: api.params is not a function
Treating params as a function instead of an instance.
fix
Use api.params.data.id to set parameters.
Property 'proxyData' does not exist on type 'Params'
Calling proxyData without parentheses.
fix
Use new Params(() => ({})).proxyData()
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies
axiosrequiredpeer dependency, used for all HTTP requests
lodash-esrequiredpeer dependency, used internally for utility functions
Agent activity
6 hits · last 30 days
node
6
Resources
http-api-orm — npm install http-api-orm · libregistry