Open sv2 opened 5 years ago
interestingly if run the app locally (not in the docker container) http://localhost:8400/swagger-stats/ui
I get the following
Cannot GET /swagger-stats/ui
The full error when I deploy in the docker container is
TypeError: res.status is not a function at trackingMiddleware (/usr/src/app/node_modules/swagger-stats/lib/swsInterface.js:345:21) at call (/usr/src/app/node_modules/connect/index.js:239:7) at next (/usr/src/app/node_modules/connect/index.js:183:5) at Function.handle (/usr/src/app/node_modules/connect/index.js:186:3) at Server.app (/usr/src/app/node_modules/connect/index.js:51:37) at emitTwo (events.js:126:13) at Server.emit (events.js:214:7) at parserOnIncoming (_http_server.js:619:12) at HTTPParser.parserOnHeadersComplete (_http_common.js:112:17)
attempting to set DEBUG=sws:*
with debug on deployed in the docker container
2018-08-13T10:52:25.024Z sws:interface SWS:processRequest:ERROR: TypeError: req.header is not a function 2018-08-13T10:53:25.021Z sws:interface SWS:processRequest:ERROR: TypeError: req.header is not a function 2018-08-13T10:54:25.020Z sws:interface SWS:processRequest:ERROR: TypeError: req.header is not a function 2018-08-13T10:55:25.020Z sws:interface SWS:processRequest:ERROR: TypeError: req.header is not a function 2018-08-13T10:56:25.020Z sws:interface SWS:processRequest:ERROR: TypeError: req.header is not a function 2018-08-13T10:57:25.020Z sws:interface SWS:processRequest:ERROR: TypeError: req.header is not a function 2018-08-13T10:58:25.020Z sws:interface SWS:processRequest:ERROR: TypeError: req.header is not a function 2018-08-13T10:58:31.577Z sws:interface SWS:processRequest:ERROR: TypeError: req.header is not a function 2018-08-13T10:58:31.713Z sws:interface SWS:processRequest:ERROR: TypeError: req.header is not a function 2018-08-13T10:58:31.798Z sws:interface SWS:processRequest:ERROR: TypeError: req.header is not a function TypeError: res.status is not a function at trackingMiddleware (/usr/src/app/node_modules/swagger-stats/lib/swsInterface.js:345:21) at call (/usr/src/app/node_modules/connect/index.js:239:7) at next (/usr/src/app/node_modules/connect/index.js:183:5) at Function.handle (/usr/src/app/node_modules/connect/index.js:186:3) at Server.app (/usr/src/app/node_modules/connect/index.js:51:37) at emitTwo (events.js:126:13) at Server.emit (events.js:214:7) at parserOnIncoming (_http_server.js:619:12) at HTTPParser.parserOnHeadersComplete (_http_common.js:112:17) 2018-08-13T10:59:25.020Z sws:interface SWS:processRequest:ERROR: TypeError: req.header is not a function
when running local the following debug is output sws:apistats SWS:Initialize API:added get /open-banking/v1.1/banks (/open-banking/v1.1/banks) +0ms sws:apistats SWS:Initialize API:added post /open-banking/v1.1/payments (/open-banking/v1.1/payments) +2ms sws:apistats SWS:Initialize API:added get /open-banking/v1.1/payments/{PaymentId} (/open-banking/v1.1/payments/:PaymentId) +1ms sws:apistats SWS:Initialize API:added post /open-banking/v1.1/payment-submissions (/open-banking/v1.1/payment-submissions) +0ms sws:apistats SWS:Initialize API:added get /open-banking/v1.1/payment-submissions/{PaymentSubmissionId} (/open-banking/v1.1/payment-submissions/:PaymentSubmissionId) +0ms sws:elastic Elasticsearch is disabled +0ms
but I still have the following Cannot GET /swagger-stats/ui
I am using "prom-client": "11.1.1" at the same time could that cause a conflict?
remove prom-client and tested still getting the same results when running locally
Looks like req and res arguments passed to swagger-stats middleware could be wrong. Which version of express are you using ? Could you share your package.json ?
{ "name": "Swagger API", "version": "v0.0.1", "description": "Draft Swagger specification for API", "main": "index.js", "scripts": { "start": "DEBUG=sws:* node index.js", "test": "NODE_ENV=test mocha", "test-integration": "NODE_ENV=integration mocha" }, "keywords": [ "swagger" ], "license": "Unlicense", "private": true, "dependencies": { "amqplib": "0.5.2", "connect": "3.6.5", "express": "4.16.3", "express-mung": "0.5.0", "http-status-codes": "1.3.0", "js-yaml": "3.10.0", "lodash": "4.17.10", "logform": "1.6.0", "lokijs": "1.5.1", "lowdb": "0.16.2", "moment": "2.22.1", "nano": "6.4.4", "nano-seconds": "1.2.2", "nedb": "1.8.0", "node-json-db": "0.7.3", "redis": "2.8.0", "request": "2.83.0", "request-promise": "4.2.2", "shortid": "2.2.8", "swagger-tools": "0.10.3", "uuid": "3.3.2", "winston": "2.4.2", "swagger-stats": "0.95.6" }, "devDependencies": { "async": "2.6.1", "chai": "4.1.2", "eslint": "4.19.1", "eslint-plugin-mocha": "5.0.0", "jasmine": "^2.9.0", "mocha": "5.1.1", "mock-req": "^0.2.0", "mock-res": "^0.5.0", "sinon": "5.0.7", "supertest": "3.1.0" } }
the code I have used in my index.js is as follows let apiSpec = require( './api/swagger.json' ) let swaggerStats = require('swagger-stats') app.use(swaggerStats.getMiddleware({swaggerSpec:apiSpec}))
TypeError: res.status is not a function at trackingMiddleware (/usr/src/app/node_modules/swagger-stats/lib/swsInterface.js:345:21)
when I try to access the ui.
I have deployed my node app in a docker container on kubernetes
http://disq.us/p/1up1rhr