Giter Club home page Giter Club logo

Comments (3)

garethcmurphy avatar garethcmurphy commented on June 25, 2024

hi @RKrahl
can you try
npx ts-node ./exampleQuery.ts

from search-api.

RKrahl avatar RKrahl commented on June 25, 2024

You mean in the second terminal in the place of the curl call?

On my desktop, it does not work, because the npm start binds at the external IP address of my box, while npx ts-node ./exampleQuery.ts tries to connect to localhost and gets a connection refused. I have no idea how to control this.

In the meanwhile, I built a dockerized version (rkrahl/nodejs:12.14.1 on Docker Hub). There, the result is curious:

If I run npx ts-node ./exampleQuery.ts once in the second terminal, I get

{
  "where": {
    "and": [
      {
        "variable": "temperature",
        "operator": "gt",
        "value": 0,
        "unit": "degC"
      },
      {
        "variable": "pressure",
        "operator": "gt",
        "value": 7000000,
        "unit": "kg/m*s2"
      }
    ]
  }
}
http://localhost:3000/datasets?filter=%7B%22where%22%3A%7B%22and%22%3A%5B%7B%22variable%22%3A%22temperature%22%2C%22operator%22%3A%22gt%22%2C%22value%22%3A0%2C%22unit%22%3A%22degC%22%7D%2C%7B%22variable%22%3A%22pressure%22%2C%22operator%22%3A%22gt%22%2C%22value%22%3A7000000%2C%22unit%22%3A%22kg%2Fm*s2%22%7D%5D%7D%7D
[]

as output and

Try http://[::1]:3000/ping
{ 'temperature.value': { gt: 0 } }
{ 'pressure.value': { gt: 7000000 } }
[
  { 'temperature.value': { gt: 0 } },
  { 'pressure.value': { gt: 7000000 } }
]

in the log of the npm start process.

If I run the very same call a second time, I get:

{
  "where": {
    "and": [
      {
        "variable": "temperature",
        "operator": "gt",
        "value": 0,
        "unit": "degC"
      },
      {
        "variable": "pressure",
        "operator": "gt",
        "value": 7000000,
        "unit": "kg/m*s2"
      }
    ]
  }
}
http://localhost:3000/datasets?filter=%7B%22where%22%3A%7B%22and%22%3A%5B%7B%22variable%22%3A%22temperature%22%2C%22operator%22%3A%22gt%22%2C%22value%22%3A0%2C%22unit%22%3A%22degC%22%7D%2C%7B%22variable%22%3A%22pressure%22%2C%22operator%22%3A%22gt%22%2C%22value%22%3A7000000%2C%22unit%22%3A%22kg%2Fm*s2%22%7D%5D%7D%7D
StatusCodeError: 500 - "{\"error\":{\"statusCode\":500,\"message\":\"Internal Server Error\"}}"
    at new StatusCodeError (/usr/lib/nodejs/search-api/node_modules/request-promise-core/lib/errors.js:32:15)
    at Request.plumbing.callback (/usr/lib/nodejs/search-api/node_modules/request-promise-core/lib/plumbing.js:104:33)
    at Request.RP$callback [as _callback] (/usr/lib/nodejs/search-api/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at Request.self.callback (/usr/lib/nodejs/search-api/node_modules/request/request.js:185:22)
    at Request.emit (events.js:223:5)
    at Request.EventEmitter.emit (domain.js:475:20)
    at Request.<anonymous> (/usr/lib/nodejs/search-api/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:223:5)
    at Request.EventEmitter.emit (domain.js:475:20)
    at IncomingMessage.<anonymous> (/usr/lib/nodejs/search-api/node_modules/request/request.js:1083:12) {
  name: 'StatusCodeError',
  statusCode: 500,
  message: '500 - "{\\"error\\":{\\"statusCode\\":500,\\"message\\":\\"Internal Server Error\\"}}"',
  error: '{"error":{"statusCode":500,"message":"Internal Server Error"}}',
  options: {
    uri: 'http://localhost:3000/datasets?filter=%7B%22where%22%3A%7B%22and%22%3A%5B%7B%22variable%22%3A%22temperature%22%2C%22operator%22%3A%22gt%22%2C%22value%22%3A0%2C%22unit%22%3A%22degC%22%7D%2C%7B%22variable%22%3A%22pressure%22%2C%22operator%22%3A%22gt%22%2C%22value%22%3A7000000%2C%22unit%22%3A%22kg%2Fm*s2%22%7D%5D%7D%7D',
    method: 'GET',
    callback: [Function: RP$callback],
    transform: undefined,
    simple: true,
    resolveWithFullResponse: false,
    transform2xxOnly: false
  },
  response: IncomingMessage {
    _readableState: ReadableState {
      objectMode: false,
      highWaterMark: 16384,
      buffer: BufferList { head: null, tail: null, length: 0 },
      length: 0,
      pipes: null,
      pipesCount: 0,
      flowing: true,
      ended: true,
      endEmitted: true,
      reading: false,
      sync: true,
      needReadable: false,
      emittedReadable: false,
      readableListening: false,
      resumeScheduled: false,
      paused: false,
      emitClose: true,
      autoDestroy: false,
      destroyed: false,
      defaultEncoding: 'utf8',
      awaitDrain: 0,
      readingMore: true,
      decoder: null,
      encoding: null
    },
    readable: false,
    _events: [Object: null prototype] {
      end: [Array],
      close: [Array],
      data: [Function],
      error: [Function]
    },
    _eventsCount: 4,
    _maxListeners: undefined,
    socket: Socket {
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: 'localhost',
      _readableState: [ReadableState],
      readable: true,
      _events: [Object: null prototype],
      _eventsCount: 6,
      _maxListeners: undefined,
      _writableState: [WritableState],
      writable: false,
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: null,
      _server: null,
      parser: null,
      _httpMessage: [ClientRequest],
      [Symbol(asyncId)]: 13,
      [Symbol(kHandle)]: [TCP],
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0
    },
    connection: Socket {
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: 'localhost',
      _readableState: [ReadableState],
      readable: true,
      _events: [Object: null prototype],
      _eventsCount: 6,
      _maxListeners: undefined,
      _writableState: [WritableState],
      writable: false,
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: null,
      _server: null,
      parser: null,
      _httpMessage: [ClientRequest],
      [Symbol(asyncId)]: 13,
      [Symbol(kHandle)]: [TCP],
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0
    },
    httpVersionMajor: 1,
    httpVersionMinor: 1,
    httpVersion: '1.1',
    complete: true,
    headers: {
      'x-powered-by': 'Express',
      'access-control-allow-origin': '*',
      'access-control-allow-credentials': 'true',
      'x-content-type-options': 'nosniff',
      'content-type': 'application/json; charset=utf-8',
      date: 'Thu, 23 Jan 2020 14:29:58 GMT',
      connection: 'close',
      'content-length': '62'
    },
    rawHeaders: [
      'X-Powered-By',
      'Express',
      'Access-Control-Allow-Origin',
      '*',
      'Access-Control-Allow-Credentials',
      'true',
      'X-Content-Type-Options',
      'nosniff',
      'Content-Type',
      'application/json; charset=utf-8',
      'Date',
      'Thu, 23 Jan 2020 14:29:58 GMT',
      'Connection',
      'close',
      'Content-Length',
      '62'
    ],
    trailers: {},
    rawTrailers: [],
    aborted: false,
    upgrade: false,
    url: '',
    method: null,
    statusCode: 500,
    statusMessage: 'Internal Server Error',
    client: Socket {
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: 'localhost',
      _readableState: [ReadableState],
      readable: true,
      _events: [Object: null prototype],
      _eventsCount: 6,
      _maxListeners: undefined,
      _writableState: [WritableState],
      writable: false,
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: null,
      _server: null,
      parser: null,
      _httpMessage: [ClientRequest],
      [Symbol(asyncId)]: 13,
      [Symbol(kHandle)]: [TCP],
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0
    },
    _consuming: false,
    _dumped: false,
    req: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 5,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: false,
      useChunkedEncodingByDefault: false,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      _contentLength: 0,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      socket: [Socket],
      connection: [Socket],
      _header: 'GET /datasets?filter=%7B%22where%22%3A%7B%22and%22%3A%5B%7B%22variable%22%3A%22temperature%22%2C%22operator%22%3A%22gt%22%2C%22value%22%3A0%2C%22unit%22%3A%22degC%22%7D%2C%7B%22variable%22%3A%22pressure%22%2C%22operator%22%3A%22gt%22%2C%22value%22%3A7000000%2C%22unit%22%3A%22kg%2Fm*s2%22%7D%5D%7D%7D HTTP/1.1\r\n' +
        'host: localhost:3000\r\n' +
        'Connection: close\r\n' +
        '\r\n',
      _onPendingData: [Function: noopPendingOutput],
      agent: [Agent],
      socketPath: undefined,
      method: 'GET',
      path: '/datasets?filter=%7B%22where%22%3A%7B%22and%22%3A%5B%7B%22variable%22%3A%22temperature%22%2C%22operator%22%3A%22gt%22%2C%22value%22%3A0%2C%22unit%22%3A%22degC%22%7D%2C%7B%22variable%22%3A%22pressure%22%2C%22operator%22%3A%22gt%22%2C%22value%22%3A7000000%2C%22unit%22%3A%22kg%2Fm*s2%22%7D%5D%7D%7D',
      _ended: true,
      res: [Circular],
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      [Symbol(kNeedDrain)]: false,
      [Symbol(isCorked)]: false,
      [Symbol(kOutHeaders)]: [Object: null prototype]
    },
    request: Request {
      _events: [Object: null prototype],
      _eventsCount: 5,
      _maxListeners: undefined,
      uri: [Url],
      method: 'GET',
      readable: true,
      writable: true,
      explicitMethod: true,
      _qs: [Querystring],
      _auth: [Auth],
      _oauth: [OAuth],
      _multipart: [Multipart],
      _redirect: [Redirect],
      _tunnel: [Tunnel],
      _rp_resolve: [Function],
      _rp_reject: [Function],
      _rp_promise: [Promise],
      _rp_callbackOrig: undefined,
      callback: [Function],
      _rp_options: [Object],
      headers: {},
      setHeader: [Function],
      hasHeader: [Function],
      getHeader: [Function],
      removeHeader: [Function],
      localAddress: undefined,
      pool: {},
      dests: [],
      __isRequestRequest: true,
      _callback: [Function: RP$callback],
      proxy: null,
      tunnel: false,
      setHost: true,
      originalCookieHeader: undefined,
      _disableCookies: true,
      _jar: undefined,
      port: '3000',
      host: 'localhost',
      path: '/datasets?filter=%7B%22where%22%3A%7B%22and%22%3A%5B%7B%22variable%22%3A%22temperature%22%2C%22operator%22%3A%22gt%22%2C%22value%22%3A0%2C%22unit%22%3A%22degC%22%7D%2C%7B%22variable%22%3A%22pressure%22%2C%22operator%22%3A%22gt%22%2C%22value%22%3A7000000%2C%22unit%22%3A%22kg%2Fm*s2%22%7D%5D%7D%7D',
      httpModule: [Object],
      agentClass: [Function],
      agent: [Agent],
      _started: true,
      href: 'http://localhost:3000/datasets?filter=%7B%22where%22%3A%7B%22and%22%3A%5B%7B%22variable%22%3A%22temperature%22%2C%22operator%22%3A%22gt%22%2C%22value%22%3A0%2C%22unit%22%3A%22degC%22%7D%2C%7B%22variable%22%3A%22pressure%22%2C%22operator%22%3A%22gt%22%2C%22value%22%3A7000000%2C%22unit%22%3A%22kg%2Fm*s2%22%7D%5D%7D%7D',
      req: [ClientRequest],
      ntick: true,
      response: [Circular],
      originalHost: 'localhost:3000',
      originalHostHeaderName: 'host',
      responseContent: [Circular],
      _destdata: true,
      _ended: true,
      _callbackCalled: true
    },
    toJSON: [Function: responseToJSON],
    caseless: Caseless { dict: [Object] },
    body: '{"error":{"statusCode":500,"message":"Internal Server Error"}}'
  }
}

as output and

{ 'temperature.value': { gt: 0 } }
{ 'pressure.value': { gt: 7000000 } }
[
  { 'temperature.value': { gt: 0 } },
  { 'pressure.value': { gt: 7000000 } }
]

Unhandled error in GET /datasets?filter=%7B%22where%22%3A%7B%22and%22%3A%5B%7B%22variable%22%3A%22temperature%22%2C%22operator%22%3A%22gt%22%2C%22value%22%3A0%2C%22unit%22%3A%22degC%22%7D%2C%7B%22variable%22%3A%22pressure%22%2C%22operator%22%3A%22gt%22%2C%22value%22%3A7000000%2C%22unit%22%3A%22kg%2Fm*s2%22%7D%5D%7D%7D: 500 Error: Unit not recognized
    at new QtyError (/usr/lib/nodejs/search-api/node_modules/js-quantities/build/quantities.js:180:17)
    at parseUnits (/usr/lib/nodejs/search-api/node_modules/js-quantities/build/quantities.js:794:13)
    at Qty.parse (/usr/lib/nodejs/search-api/node_modules/js-quantities/build/quantities.js:748:24)
    at new Qty (/usr/lib/nodejs/search-api/node_modules/js-quantities/build/quantities.js:872:13)
    at convertUnits (/usr/lib/nodejs/search-api/src/repositories/dataset.repository.ts:37:15)
    at processQuery (/usr/lib/nodejs/search-api/src/repositories/dataset.repository.ts:67:11)
    at /usr/lib/nodejs/search-api/src/repositories/dataset.repository.ts:26:31
    at notifySingleObserver (/usr/lib/nodejs/search-api/node_modules/loopback-datasource-juggler/lib/observer.js:162:24)
    at /usr/lib/nodejs/search-api/node_modules/async/dist/async.js:3110:16
    at replenish (/usr/lib/nodejs/search-api/node_modules/async/dist/async.js:1011:17)
    at iterateeCallback (/usr/lib/nodejs/search-api/node_modules/async/dist/async.js:995:17)
    at /usr/lib/nodejs/search-api/node_modules/async/dist/async.js:969:16
    at /usr/lib/nodejs/search-api/node_modules/loopback-datasource-juggler/lib/observer.js:165:26
    at processTicksAndRejections (internal/process/task_queues.js:94:5)

in the log of the npm start process.

from search-api.

garethcmurphy avatar garethcmurphy commented on June 25, 2024

This should be working now

from search-api.

Related Issues (20)

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.