0.0.71 • Published 3 years ago

@tjc-group/odata-v2-server v0.0.71

Weekly downloads
41
License
MIT
Repository
github
Last release
3 years ago

This is a downgrade from odata-v4-server.

We need to provide OData V2 metadata and response payload Please be advised that this is in alfa status.

  • Added method parameter decorators:

    • @odata.path: OData resource path parsing tree
    • @odata.navstep: Current navigation step
  • Now controller methods are called with controller instance (not controller class descriptor)

  • $batch requests implemented, though no callbacks yet for start and end of changsets

  • OData V2 payload can be switched off via ODataProcessorOptions class

Please see below the original README of JayStack odata-v4-server

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.0.70

3 years ago

0.0.71

3 years ago

0.0.66

3 years ago

0.0.67

3 years ago

0.0.68

3 years ago

0.0.69

3 years ago

0.0.65

4 years ago

0.0.64

4 years ago

0.0.63

4 years ago

0.0.62

4 years ago

0.0.60

4 years ago

0.0.61

4 years ago

0.0.59

4 years ago

0.0.58

4 years ago

0.0.56

4 years ago

0.0.57

4 years ago

0.0.55

4 years ago

0.0.54

4 years ago

0.0.53

4 years ago

0.0.52

4 years ago

0.0.51

4 years ago

0.0.50

4 years ago

0.0.49

4 years ago

0.0.45

4 years ago

0.0.46

4 years ago

0.0.47

4 years ago

0.0.48

4 years ago

0.0.44

4 years ago

0.0.42

4 years ago

0.0.43

4 years ago

0.0.40

4 years ago

0.0.41

4 years ago

0.0.38

4 years ago

0.0.39

4 years ago

0.0.37

4 years ago

0.0.36

4 years ago

0.0.35

4 years ago

0.0.34

4 years ago

0.0.32

4 years ago

0.0.33

4 years ago

0.0.30

4 years ago

0.0.31

4 years ago

0.0.26

4 years ago

0.0.27

4 years ago

0.0.28

4 years ago

0.0.29

4 years ago

0.0.25

4 years ago

0.0.21

4 years ago

0.0.22

4 years ago

0.0.24

4 years ago

0.0.20

4 years ago

0.0.19

4 years ago

0.0.18

4 years ago

0.0.14

4 years ago

0.0.15

4 years ago

0.0.17

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.2

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.1

4 years ago