npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-odata

v0.7.16

Published

A module for easily create a REST API based on oData protocol

Downloads

129

Readme

node-odata

Create awesome REST APIs abide by OData Protocol v4. Its purpose is to easier to creating APIs, make you more focus on business logic.

NPM Version npm Build Status Coverage Status Dependency Status License

var odata = require('node-odata');

var server = odata('mongodb://localhost/my-app');

server.resource('books', {
  title: String,
  price: Number
});

server.listen(3000);

Registers the following routes:

GET    /books
GET    /books(:id)
POST   /books
PUT    /books(:id)
DELETE /books(:id)

Use the following OData query:

Example
GET /books?$select=id, title
GET /books?$top=3&$skip=2
GET /books?$orderby=price desc
GET /books?$filter=price gt 10
GET ...

Further options

The odata constructor takes 3 arguments: odata(<mongoURL>, <dbPrefix>, <options>);

The options object currently only supports one parameter: expressRequestLimit, this will be parsed to the express middelware as the "limit" option, which allows for configuring express to support larger requests. It can be either a number or a string like "50kb", 20mb", etc.

Current State

node-odata is currently at an beta stage, it is stable but not 100% feature complete. node-odata is written by ECMAScript 6 then compiled by babel. It currently have to dependent on MongoDB yet. The current target is to add more features (eg. $metadata) and make to support other database. (eg. MySQL, PostgreSQL).

Installation

npm install node-odata

DOCUMENTATION

Demo

Live demo and try it:

  • GET [/book?$select=id, title](http://books.zackyang.com/book?$select=id, title)
  • GET /book?$top=3&$skip=2
  • GET [/book?$orderby=price desc](http://books.zackyang.com/book?$orderby=price desc)
  • GET [/book?$filter=price gt 10](http://books.zackyang.com/book?$filter=price gt 10)

Support Feature

  • [x] Full CRUD Support
  • [x] $count
  • [x] $filter
    • [x] Comparison Operators
      • [x] eq
      • [x] ne
      • [x] lt
      • [x] le
      • [x] gt
      • [x] ge
    • [ ] Logical Operators
      • [x] and
      • [x] or
      • [ ] not
    • [ ] Comparison Operators
      • [ ] has
    • [ ] String Functions
      • [x] indexof
      • [x] contains
      • [ ] endswith
      • [ ] startswith
      • [ ] length
      • [ ] substring
      • [ ] tolower
      • [ ] toupper
      • [ ] trim
      • [ ] concat
    • [ ] Arithmetic Operators
      • [ ] add
      • [ ] sub
      • [ ] mul
      • [ ] div
      • [ ] mod
    • [ ] Date Functions
      • [x] year
      • [ ] month
      • [ ] day
      • [ ] hour
      • [ ] minute
      • [ ] second
      • [ ] fractionalseconds
      • [ ] date
      • [ ] time
      • [ ] totaloffsetminutes
      • [ ] now
      • [ ] mindatetime
      • [ ] maxdatetime
    • [ ] Math Functions
      • [ ] round
      • [ ] floor
      • [ ] ceiling
  • [x] $select
  • [x] $top
  • [x] $skip
  • [x] $orderby
  • [ ] $expand
  • [x] $metadata generation (Nonstandard)

CONTRIBUTING

We always welcome contributions to help make node-odata better. Please feel free to contribute to this project.

LICENSE

node-odata is licensed under the MIT license. See LICENSE for more information.