0.2.13 • Published 6 years ago
odata-v4-server v0.2.13
JayStack OData V4 Server
OData V4 server for node.js
Features
- OASIS Standard OData Version 4.0 server
- usable as a standalone server, as an Express router, as a node.js stream or as a library
- expose service document and service metadata - $metadata
- setup metadata using decorators or metadata JSON
- supported data types are Edm primitives, complex types, navigation properties
- support create, read, update, and delete entity sets, action imports, function imports, collection and entity bound actions and functions
- support for full OData query language using odata-v4-parser
- filtering entities - $filter
- sorting - $orderby
- paging - $skip and $top
- projection of entities - $select
- expanding entities - $expand
- $count
- support sync and async controller functions
- support async controller functions using Promise, async/await or ES6 generator functions
- support result streaming
- support media entities
Controller and server functions parameter injection decorators
- @odata.key
- @odata.filter
- @odata.query
- @odata.context
- @odata.body
- @odata.result
- @odata.stream
Example Northwind server
export class ProductsController extends ODataController{
@odata.GET
find(@odata.filter filter:ODataQuery){
if (filter) return products.filter(createFilter(filter));
return products;
}
@odata.GET
findOne(@odata.key key:string){
return products.filter(product => product._id == key)[0];
}
@odata.POST
insert(@odata.body product:any){
product._id = new ObjectID().toString();
products.push(product);
return product;
}
@odata.PATCH
update(@odata.key key:string, @odata.body delta:any){
let product = products.filter(product => product._id == key)[0];
for (let prop in delta){
product[prop] = delta[prop];
}
}
@odata.DELETE
remove(@odata.key key:string){
products.splice(products.indexOf(products.filter(product => product._id == key)[0]), 1);
}
}
export class CategoriesController extends ODataController{
@odata.GET
find(@odata.filter filter:ODataQuery){
if (filter) return categories.filter(createFilter(filter));
return categories;
}
@odata.GET
findOne(@odata.key key:string){
return categories.filter(category => category._id == key)[0];
}
@odata.POST
insert(@odata.body category:any){
category._id = new ObjectID().toString();
categories.push(category);
return category;
}
@odata.PATCH
update(@odata.key key:string, @odata.body delta:any){
let category = categories.filter(category => category._id == key)[0];
for (let prop in delta){
category[prop] = delta[prop];
}
}
@odata.DELETE
remove(@odata.key key:string){
categories.splice(categories.indexOf(categories.filter(category => category._id == key)[0]), 1);
}
}
@odata.cors
@odata.controller(ProductsController, true)
@odata.controller(CategoriesController, true)
export class NorthwindODataServer extends ODataServer{}
NorthwindODataServer.create("/odata", 3000);
0.2.13
6 years ago
0.2.12
6 years ago
0.2.11
6 years ago
0.2.10
6 years ago
0.2.9
6 years ago
0.2.8
6 years ago
0.2.7
6 years ago
0.2.6
6 years ago
0.2.5
6 years ago
0.2.4
6 years ago
0.2.3
6 years ago
0.2.2
6 years ago
0.2.1
6 years ago
0.2.0
7 years ago
0.1.38
7 years ago
0.1.37
7 years ago
0.1.36
7 years ago
0.1.35
7 years ago
0.1.34
7 years ago
0.1.33
7 years ago
0.1.32
7 years ago
0.1.31
7 years ago
0.1.30
7 years ago
0.1.29
7 years ago
0.1.28
7 years ago
0.1.27
7 years ago
0.1.26
7 years ago
0.1.25
7 years ago
0.1.24
7 years ago
0.1.23
7 years ago
0.1.22
7 years ago
0.1.21
7 years ago
0.1.20
7 years ago
0.1.19
7 years ago
0.1.18
7 years ago
0.1.17
7 years ago
0.1.16
7 years ago
0.1.15
7 years ago
0.1.14
7 years ago
0.1.13
7 years ago
0.1.12
7 years ago
0.1.11
7 years ago
0.1.10
7 years ago
0.1.9
7 years ago
0.1.8
7 years ago
0.1.7
7 years ago
0.1.6
7 years ago
0.1.5
7 years ago
0.1.4
7 years ago
0.1.3
7 years ago
0.1.2
7 years ago
0.1.1
7 years ago
0.1.0
7 years ago