Registry / testing / agreed-server

agreed-server

JSON →
library3.0.1jsnpmunverified

Agreed Server is a mock server for the Agreed API specification format, providing CLI and programmable interfaces for creating mock APIs from agreed files. Version 3.0.1 is the latest stable release. It supports custom middlewares, default headers, static file serving, and a notifier for real-time event handling. Unlike generic mock servers, it is tightly integrated with the Agreed ecosystem and offers an Express-based pure server mode for advanced customization.

npm install agreed-server
INSTALL
IMPORT
SIG · AGREED-SERVER
A
agreed-server
testingjavascriptv3.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.

default import
const agreedServer = require('agreed-server');
import agreedServer from 'agreed-server';
This package uses CommonJS require. ESM import may not work unless using bundler that handles CJS interop.
agreedServer function
const server = agreedServer({ path: './agreed.json' }).createServer();
const server = new agreedServer();
agreedServer is a factory function, not a constructor. Returns an object with createServer method.
notifier
const { notifier } = agreedServer(options);
const notifier = require('agreed-server').notifier;
notifier is only available on the object returned by agreedServer(), not on the module itself.

Starts a basic mock server from an agreed file on port 3001 using the CLI-compatible API.

const agreedServer = require('agreed-server'); const server = agreedServer({ path: './test/agreed.json', port: 3001 }).createServer(); server.listen(3001, () => { console.log('Mock server running on port 3001'); });
Debug
Known issues
breakingagreed-server v3 uses ES modules internally; commonJS require still works but named exports may not be available.
fix
Continue using require('agreed-server') for default import. For ESM, use dynamic import or bundler.
affects: >=3.0.0
deprecatedThe 'static' option for serving static files is deprecated in favor of using Express middleware directly.
fix
Use middlewares array with express.static() instead of static option.
affects: >=3.0.0
gotchaNotifier events are only emitted when the agreed file has a 'notify' property; listen before making requests.
fix
Attach notifier.on('message', ...) before starting the server to avoid missing events.
affects: >=0.0.0
gotchaThe 'path' option must point to a valid agreed file; relative paths are resolved from process.cwd().
fix
Provide an absolute path or ensure relative path is correct from working directory.
affects: >=0.0.0
breakingagreed-server v2 to v3: The API changed from returning a server directly to returning an object with createServer method.
fix
Call .createServer() on the returned object, or use the CLI directly.
affects: 3.0.0
Errors
Common errors & fixes
TypeError: agreedServer is not a function
Using ES import 'import agreedServer from ...' which doesn't work due to CJS module.
fix
Use const agreedServer = require('agreed-server');
Error: Cannot find module './test/agreed.json'
Incorrect relative path or file doesn't exist.
fix
Ensure the agreed file exists and use correct path (absolute or relative to process.cwd()).
TypeError: agreedServer(...).createServer is not a function
Using an older version (v2) where createServer was not available.
fix
Upgrade to v3 or use the older API: const server = agreedServer(options); server.listen();
Upgrade
Version history
3.0.1latest on npm
Audit
Dependencies
agreed-corerequiredCore dependency for parsing and matching agreed file definitions.
expressrequiredUnderlying HTTP server framework.
Agent activity
45 hits · last 30 days
node
36
OpenAI (training)
1
Resources
agreed-server — npm install agreed-server · libregistry