Giter Club home page Giter Club logo

odata-v4-server-pgsql-example's Introduction

odata-v4-server-pgsql-example

PostgreSQL Server example for JayStack OData V4 Server

About JayStack OData V4 Server (odata-v4-server)

With JayStack OData v4 Server you can build your own data endpoints without the hassle of implementing any protocol-level code. This framework binds OData v4 requests to your annotated controller functions, and compiles OData v4 compatible response. Clients can access services through OData-compliant HTTP requests. We recommend the JayData library for consuming OData v4 APIs.

This example uses JayStack OData V4 Server (odata-v4-server) and odata-v4-pgsql repositories.

You can read more about JayStack OData V4 Server in our tutorial at ...

Also there are sevaral other examples on JayStack OData V4 Server (odata-v4-server):

Technical details of this example

Setting up the database

You have to create the database manually using this command after connecting to the default database:

CREATE DATABASE northwind;

Setting up the connection

You may customize the db connection options by editing connect.ts. By default, these are the options:

const pool = new pg.Pool({
  user: 'postgres',
  password: 'postgres',
  database: 'northwind'
});

By default, the database will listen on port 5432 therefore it is not set above.

Building the application

npm run build

Testing the application

npm test

Starting the application

npm start

Creating sample data

After starting the application (it will listen on localhost:3000 by default) you can generate / recreate the sample dataset by submitting localhost:3000/initDb. Alternatively if you start unit tests (npm test) then the database will be initialized automatically.

odata-v4-server-pgsql-example's People

Contributors

hasyee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

odata-v4-server-pgsql-example's Issues

`npm run build` fails

node_modules/odata-v4-server/build/lib/processor.d.ts:20:22 - error TS2415: Class 'ODataProcessor' incorrectly extends base class 'Transform'.
  Property '_flush' is protected in type 'ODataProcessor' but public in type 'Transform'.

20 export declare class ODataProcessor extends Transform {
                        ~~~~~~~~~~~~~~


npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] tsc: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] tsc script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Baybulatov.Artur\AppData\Roaming\npm-cache\_logs\2018-10-01T13_40_56_422Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `npm run tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Baybulatov.Artur\AppData\Roaming\npm-cache\_logs\2018-10-01T13_40_56_459Z-debug.log

C:\Users\Baybulatov.Artur\AppData\Roaming\npm-cache\_logs\2018-10-01T13_40_56_459Z-debug.log:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\prog\\nodejs\\node.exe',
1 verbose cli   'C:\\prog\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle [email protected]~prebuild: [email protected]
6 info lifecycle [email protected]~build: [email protected]
7 verbose lifecycle [email protected]~build: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~build: PATH: C:\prog\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Baybulatov.Artur\AppData\Local\Temp\ggg\odata-v4-server-pgsql-example\node_modules\.bin;C:\Program Files\ImageMagick-7.0.6-Q16;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Heroku\bin;C:\Program Files (x86)\git\cmd;C:\Users\Baybulatov.Artur\AppData\Roaming\npm;C:\prog\WinMerge;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\dotnet\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Yarn\bin;C:\prog\nodejs\;C:\Go\bin;C:\Program Files\Git\cmd;C:\Users\Baybulatov.Artur\AppData\Local\Programs\Python\Python36-32\Scripts\;C:\Users\Baybulatov.Artur\AppData\Local\Programs\Python\Python36-32\;C:\Program Files\Sublime Text 3;C:\Users\Baybulatov.Artur\Documents\projects\windows-shortcuts;C:\Users\Baybulatov.Artur\AppData\Local\Programs\Fiddler;C:\Users\Baybulatov.Artur\AppData\Local\Yarn\bin;C:\Program Files\PostgreSQL\10\bin;C:\Users\Baybulatov.Artur\AppData\Roaming\npm;%GOPATH%\bin
9 verbose lifecycle [email protected]~build: CWD: C:\Users\Baybulatov.Artur\AppData\Local\Temp\ggg\odata-v4-server-pgsql-example
10 silly lifecycle [email protected]~build: Args: [ '/d /s /c', 'npm run tsc' ]
11 silly lifecycle [email protected]~build: Returned: code: 2  signal: null
12 info lifecycle [email protected]~build: Failed to exec build script
13 verbose stack Error: [email protected] build: `npm run tsc`
13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> (C:\prog\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (C:\prog\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid [email protected]
15 verbose cwd C:\Users\Baybulatov.Artur\AppData\Local\Temp\ggg\odata-v4-server-pgsql-example
16 verbose Windows_NT 10.0.10586
17 verbose argv "C:\\prog\\nodejs\\node.exe" "C:\\prog\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v8.11.2
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 2
22 error [email protected] build: `npm run tsc`
22 error Exit status 2
23 error Failed at the [email protected] build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

$extend not working.

Following example.. i can do queries for

http://localhost:3000/Products
http://localhost:3000/Categories

But when i try to expand catatory using..
http://localhost:3000/Products?$expand=Category

then i get error...

{
"error": {
"code": 500,
"message": "Cannot read property 'length' of undefined",
"stack": "TypeError: Cannot read property 'length' of undefined\n at Function. (\expand_test\build\controllers\ProductController.js:69:46)\n at Generator.next ()\n at fulfilled (\expand_test\build\controllers\ProductController.js:13:58)\n at \n at process._tickCallback (internal/process/next_tick.js:188:7)"
}
}

Is this a know issue....or we are doing something wrong ? .. i did see the issue regarding export posted with this lib...

Metadata for the odata server is also attached..

metadata.TXT

npm test and npm start fails

on fresh install of node v8.11.3:

OData V4 example server
Products
1) "before each" hook for "should get all products (GET /Products)"

0 passing (29ms)
1 failing

  1. OData V4 example server "before each" hook for "should get all products (GE
    T /Products)":
    TypeError: Cannot read property 'highWaterMark' of undefined
    at ODataServer.get (_stream_duplex.js:73:32)
    at propNames.forEach (node_modules\odata-v4-server\build\lib\metadata.js:2
    95:49)
    at Array.forEach ()
    at Object.createMetadataJSON (node_modules\odata-v4-server\build\lib\metad
    ata.js:294:15)
    at Function.$metadata (node_modules\odata-v4-server\build\lib\server.js:18
    7:137)
    at new ODataProcessor (node_modules\odata-v4-server\build\lib\processor.js
    :416:81)
    at Function.createProcessor (node_modules\odata-v4-server\build\lib\server
    .js:176:16)
    at Function.execute (node_modules\odata-v4-server\build\lib\server.js:145:
  2. at Context.beforeEach (test\pgsql.spec.js:34:32)

[mochawesome] Report saved to report\odata-v4-server.html

npm ERR! Test failed. See above for more details.

npm start also fails with same error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.