Registry / web-framework / simple-odata-server

simple-odata-server

JSON →
library1.2.2jsnpmunverified

Simple OData Server (simple-odata-server) is a lightweight Node.js library designed to create OData v2 compatible servers with minimal setup. It currently stands at version 1.2.2. While stable and used in projects like jsreport, the repository explicitly states it is no longer actively maintained by its creators, meaning bug fixes and new features are unlikely to be introduced regularly, if at all. Its primary differentiator is its simplicity and direct support for MongoDB and NeDB databases via separate adapter packages (simple-odata-server-mongodb, simple-odata-server-nedb), making it suitable for projects requiring basic OData functionality without the overhead of more comprehensive, feature-rich OData frameworks. It supports core operations like $metadata, filtering, and CRUD operations, but intentionally omits advanced features such as entity links, batch operations, or Atom feeds to maintain its lean footprint.

npm install simple-odata-server
INSTALL
IMPORT
SIG · SIMPLE-ODATA-SERVE
S
simple-odata-server
web-frameworkjavascriptv1.2.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

ODataServer
const ODataServer = require('simple-odata-server');
import ODataServer from 'simple-odata-server';
The library primarily uses CommonJS `require` syntax. Direct ESM `import` is not officially supported and may lead to issues.
NedbAdapter
const Adapter = require('simple-odata-server-nedb');
import Adapter from 'simple-odata-server-nedb';
Adapters for specific databases like NeDB were extracted into separate packages in v1.0.0 and are imported using CommonJS `require`.
MongoDbAdapter
const Adapter = require('simple-odata-server-mongodb');
import Adapter from 'simple-odata-server-mongodb';
Similarly, the MongoDB adapter is a separate package imported via CommonJS `require`.

This quickstart demonstrates setting up a basic OData server using simple-odata-server with an in-memory NeDB database, defining a simple 'UserType' entity and exposing it via an 'users' entity set. It then initializes the server, binds it to an HTTP port, and provides example OData requests.

const http = require('http'); const Datastore = require('nedb'); const db = new Datastore( { inMemoryOnly: true }); const ODataServer = require('simple-odata-server'); const Adapter = require('simple-odata-server-nedb'); const model = { namespace: "jsreport", entityTypes: { "UserType": { "_id": {"type": "Edm.String", key: true}, "name": {"type": "Edm.String"} } }, entitySets: { "users": { entityType: "jsreport.UserType" } } }; const odataServer = ODataServer("http://localhost:1337") .model(model) .adapter(Adapter(function(es, cb) { cb(null, db)})); http.createServer(odataServer.handle.bind(odataServer)).listen(1337, () => { console.log('OData server running on http://localhost:1337'); console.log('Try: GET http://localhost:1337/$metadata'); console.log('Try: POST http://localhost:1337/users with body {"_id":"1", "name":"Test User"}'); console.log('Try: GET http://localhost:1337/users?$filter=name eq \'Test User\'''); });
Debug
Known issues
breakingStarting from v1.0.0, database adapters (MongoDB and NeDB) are no longer bundled with `simple-odata-server`. They must be installed as separate packages (`simple-odata-server-mongodb` or `simple-odata-server-nedb`).
fix
Install the appropriate adapter package: `npm install simple-odata-server-mongodb` or `npm install simple-odata-server-nedb`.
affects: >=1.0.0
breakingThe `update`, `query`, `insert`, and `remove` hooks in v1.0.0 changed their signature. They now accept the original HTTP request object as a parameter before the callback.
fix
Update your hook implementations to include the `req` parameter: `fn(setName, query, req, cb)` for `query` and `remove`, `fn(setName, doc, req, cb)` for `insert`, and `fn(setName, query, update, req, cb)` for `update`.
affects: >=1.0.0
deprecatedThe package explicitly states it is no longer being actively maintained. While it remains stable and used in production, future updates, bug fixes, or security patches are unlikely.
fix
Evaluate forking the repository if active development or specific new features are required, or consider alternative OData implementations for long-term projects requiring active support.
affects: >=1.2.2
gotchaOlder versions (prior to 1.2.2) might emit Node.js deprecation warnings due to their reliance on `odata-parser`. Version 1.2.2 updated to `@jsreport/odata-parser` to address this.
fix
Upgrade to `simple-odata-server@1.2.2` or later to resolve Node.js deprecation warnings related to the OData parser.
affects: <1.2.2
Errors
Common errors & fixes
TypeError: Adapter is not a function
Attempting to use `odataServer.adapter()` without explicitly importing and passing an adapter from `simple-odata-server-nedb` or `simple-odata-server-mongodb`.
fix
Ensure the necessary adapter package is installed (`npm install simple-odata-server-nedb`) and imported: `const Adapter = require('simple-odata-server-nedb');` then passed to the server: `.adapter(Adapter(...))`.
Error: Unhandled promise rejection: TypeError: cb is not a function
This error occurs in custom `query`, `update`, `insert`, or `remove` hooks if the callback function is not correctly passed or invoked, often due to an incorrect signature introduced in v1.0.0.
fix
Review the hook signature to ensure it matches `(setName, query, req, cb)` for `query`/`remove`, `(setName, doc, req, cb)` for `insert`, or `(setName, query, update, req, cb)` for `update`, and call `cb(err, result)` appropriately.
Error: Cannot find module 'odata-parser'
Older versions of `simple-odata-server` (pre-1.2.2) explicitly depended on `odata-parser`, which might not be correctly resolved or installed in some environments, or if it was removed due to deprecation. This was often seen with Node.js deprecation warnings.
fix
Upgrade `simple-odata-server` to version 1.2.2 or later to use the updated `@jsreport/odata-parser` dependency.
Upgrade
Version history
1.2.2latest on npm
Audit
Dependencies
simple-odata-server-nedbrequiredRequired for using NeDB as a data store, extracted into a separate package since v1.0.0.
simple-odata-server-mongodbrequiredRequired for using MongoDB as a data store, extracted into a separate package since v1.0.0.
nedboptionalA minimal database used directly in the quickstart example for in-memory or file-based storage.
Agent activity
2 hits · last 30 days
node
2
Resources
simple-odata-server — npm install simple-odata-server · libregistry