Registry / devops / hmpo-model

hmpo-model

JSON →
library7.0.1jsnpmunverified

HMPO Model is a Node.js library for creating simple data models with local and remote (HTTP/REST) backends. Version 7.0.1 uses the `got` HTTP library, replacing the deprecated `request`. It provides a LocalModel for in-memory data persistence with change events and a RemoteModel subclass for REST API interactions supporting GET (fetch), POST (save), and DELETE (destroy) methods. Key differentiators include its event-driven model, proxy support via request config, and explicit URL and auth methods for API requests. It is maintained by UK Home Office HMPO and targets Node.js 24.x.

npm install hmpo-model
INSTALL
IMPORT
SIG · HMPO-MODEL
H
hmpo-model
devopsjavascriptv7.0.1
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.

HmpoModel
import HmpoModel from 'hmpo-model'
const HmpoModel = require('hmpo-model')
ESM-only since v7.0.0 (package.json type: module). Default export is the combined class (LocalModel and RemoteModel).
localModel
import { localModel } from 'hmpo-model'
Named export for the local-only model class.
remoteModel
import { remoteModel } from 'hmpo-model'
const remoteModel = require('hmpo-model').remoteModel
Named export for the remote model class. ESM-only since v7.

Shows extending HmpoModel with a url, setting attributes, and performing save (POST) and fetch (GET) operations.

import HmpoModel from 'hmpo-model'; class MyModel extends HmpoModel { url() { return super.url('https://jsonplaceholder.typicode.com/posts'); } } const model = new MyModel(); model.set('name', 'Test'); // Save (POST) model.save((err, data, responseTime) => { if (err) console.error('Save failed:', err); else console.log('Saved:', data); }); // Fetch (GET) model.fetch((err, data, responseTime) => { if (err) console.error('Fetch failed:', err); else console.log('Fetched:', data); });
Debug
Known issues
breakingThe deprecated 'request' library has been replaced with 'got' in v7.0.0. The API is similar but auth and proxy arguments are translated. The 'request' method no longer accepts a body; use 'json', 'body', or 'form' in requestConfig.
fix
Update HTTP calls to use 'got' config style. Put request body in requestConfig as 'json', 'body', or 'form'.
affects: >=7.0.0
breakingVersion 7.0.0 dropped support for CommonJS (require). Package type is 'module' and requires ESM imports.
fix
Use 'import' syntax or switch to dynamic import(). Do not use require().
affects: >=7.0.0
gotchaThe 'got' library does not automatically use proxy environment variables (HTTP_PROXY, HTTPS_PROXY). You must configure proxy explicitly in requestConfig or use a global agent like 'global-agent'.
fix
In requestConfig, set 'proxy' option or add 'global-agent' to your app and set environment variables.
affects: >=7.0.0
deprecatedThe 'requestConfig' method's 'proxy' option is deprecated in favor of 'got's built-in proxy handling. Future versions may remove it.
fix
Use 'got' native proxy option or upgrade to newer version when available.
affects: >=7.0.0
Errors
Common errors & fixes
TypeError: HmpoModel is not a constructor
Using CommonJS require() on an ESM-only package.
fix
Use import HmpoModel from 'hmpo-model'; or use dynamic import().
Error: request is not a function
The deprecated 'request' method was removed in v7. Instead, use got via the internal HTTP client.
fix
Place request body in requestConfig under 'json', 'body', or 'form'.
Error: connect ECONNREFUSED when behind proxy
Proxy environment variables are not automatically used by 'got' in v7.
fix
Configure proxy in requestConfig or use global-agent to handle proxy settings.
Upgrade
Version history
7.0.1latest on npm
Audit
Dependencies
gotrequiredHTTP client for remote API calls, replaces deprecated 'request'
Agent activity
6 hits · last 30 days
node
6
Resources
hmpo-model — npm install hmpo-model · libregistry