Socket
Socket
Sign inDemoInstall

swagger-stats

Package Overview
Dependencies
88
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.95.15 to 0.95.16

examples/restify/restifytest.js

8

CHANGELOG.md
# Changelog
All notable changes to this project will be documented in this file.
## v0.95.16
* [bug] UX paths are not properly resolved [#91](https://github.com/slanatech/swagger-stats/issues/91)
* [feature] Restify support [#86](https://github.com/slanatech/swagger-stats/issues/86)
* [bug] Natives package has been deprecated - removed [#81](https://github.com/slanatech/swagger-stats/issues/81)
* [bug] openapi3 basePath was removed [#81](https://github.com/slanatech/swagger-stats/issues/84)
New option `basePath` allows to specify base path as needed when Openapi 3.0 spec is used.
## v0.95.15

@@ -6,0 +14,0 @@

2

examples/authtest/authtest.js

@@ -67,3 +67,3 @@ 'use strict';

name: 'swagger-stats-authtest',
version: '0.95.15',
version: '0.95.16',
hostname: "hostname",

@@ -70,0 +70,0 @@ ip: "127.0.0.1",

@@ -10,3 +10,3 @@ 'use strict';

const swaggerSpec = require('./petstore.json');
const swaggerSpec = require('../spectest/petstore3.json');

@@ -40,5 +40,13 @@ let server = null;

fastify.route({
method: ['DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT','OPTIONS'],
url: '/pet*',
handler: async function(request, reply){
await mockApiImplementation(request, reply);
}
});
let swsOptions = {
name: 'swagger-stats-fastify',
version: '0.95.15',
version: '0.95.16',
timelineBucketDuration: 1000,

@@ -45,0 +53,0 @@ swaggerSpec:swaggerSpec,

@@ -8,4 +8,3 @@ 'use strict';

const swaggerSpec = require('./petstore.json');
const githubAPISpec = require('./github.json');
const swaggerSpec = require('../spectest/petstore3.json');

@@ -72,3 +71,3 @@ let server = null;

name: 'swagger-stats-hapitest',
version: '0.95.15',
version: '0.95.16',
hostname: "hostname",

@@ -101,3 +100,3 @@ ip: "127.0.0.1",

// respond to any petstore api
if(request.raw.req.url.startsWith('/v2')) {
if(request.raw.req.url.startsWith('/pet') || request.raw.req.url.startsWith('/v2')) {
return await mockApiImplementation(request,h);

@@ -104,0 +103,0 @@ }else{

@@ -60,3 +60,3 @@ 'use strict';

var specLocation = 'petstore.yaml';
var specLocation = 'petstore3.yaml';

@@ -82,3 +82,3 @@ if( process.env.SWS_SPECTEST_URL ){

name: 'swagger-stats-spectest',
version: '0.95.15',
version: '0.95.16',
hostname: "hostname",

@@ -88,2 +88,3 @@ ip: "127.0.0.1",

swaggerSpec:swaggerSpec,
//basePath: '/api',
uriPath: '/swagger-stats',

@@ -96,4 +97,7 @@ durationBuckets: [10, 25, 50, 100, 200],

// Example of extending RRR with custom attributes
// You can remove non-needed or private attributes from Request Response Record
delete rrr.http.request.headers['user-agent'];
// You can also extend Request Response Record with custom attributes
// All custom properties under attrs will be casted to string and indexed in ElasticSearch as keyword

@@ -100,0 +104,0 @@ rrr.attrs = {

@@ -112,3 +112,3 @@ 'use strict';

name: 'swagger-stats-testapp',
version: '0.95.15',
version: '0.95.16',
timelineBucketDuration: tlBucket,

@@ -115,0 +115,0 @@ uriPath: '/swagger-stats',

@@ -67,3 +67,4 @@ var gulp = require('gulp'),

gulp.task('css-build', ['css-base64'], function(){
//gulp.task('css-build', ['css-base64'], function(){
gulp.task('css-build', gulp.series('css-base64', function(){
return gulp.src(cssFiles)

@@ -75,3 +76,3 @@ .pipe(gp_sourcemaps.init())

.pipe(gulp.dest('dist/css/'));
});
}));

@@ -83,2 +84,3 @@ gulp.task('fonts', function() {

gulp.task('default', ['fonts','css-build','js-build'], function(){});
//gulp.task('default', ['fonts','css-build','js-build'], function(){});
gulp.task('default', gulp.series('fonts','css-build','js-build'));

@@ -9,3 +9,3 @@ /**

const util = require('util');
const pathToRegexp = require('path-to-regexp');
const { pathToRegexp } = require('path-to-regexp');
const debug = require('debug')('sws:apistats');

@@ -92,8 +92,14 @@ const promClient = require("prom-client");

swsAPIStats.prototype.initBasePath = function(swaggerSpec) {
this.basePath = swaggerSpec.basePath ? swaggerSpec.basePath : '/';
if (this.basePath.charAt(0) !== '/') {
this.basePath = '/' + this.basePath;
swsAPIStats.prototype.initBasePath = function(swaggerSpec,swsOptions) {
if(('basePath' in swsOptions) && (swsOptions.basePath!=='')){
this.basePath = swsOptions.basePath;
}else{
if( swaggerSpec.openapi && swaggerSpec.openapi.startsWith('3') ){
this.basePath = '/';
}else{
this.basePath = swaggerSpec.basePath ? swaggerSpec.basePath : '/';
if (this.basePath.charAt(0) !== '/') {
this.basePath = '/' + this.basePath;
}
}
}

@@ -140,3 +146,3 @@ if (this.basePath.charAt(this.basePath.length - 1) !== '/') {

this.initBasePath(swaggerSpec);
this.initBasePath(swaggerSpec,swsOptions);

@@ -143,0 +149,0 @@ if(!swaggerSpec.paths) return;

@@ -29,2 +29,7 @@ /* swagger-stats Settings */

// Base path for API described in swagger spec.
// Specify this when using openapi: "3.0.0" specifications
// For example, setting basePath='/api' with petrstore spec would match requests /api/pet/{id}, etc ...
this.basePath = '';
// Base path for swagger-stats internal APIs.

@@ -31,0 +36,0 @@ // If specified, will be used to serve UI, stats and metrics like this:

{
"name": "swagger-stats",
"version": "0.95.15",
"version": "0.95.16",
"description": "API Telemetry and APM. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices, based on express routes and Swagger (Open API) specification",

@@ -13,2 +13,3 @@ "main": "lib/index.js",

"fastifytestapp": "nyc --reporter=lcov --reporter=html --reporter=json --reporter=text --report-dir=coverage/fastifytestapp node examples/fastify/fasifytest.js",
"restifytestapp": "nyc --reporter=lcov --reporter=html --reporter=json --reporter=text --report-dir=coverage/restifytestapp node examples/restify/restifytest.js",
"testappstop": "mocha --delay --exit test/stoptestapp.js",

@@ -43,2 +44,9 @@ "delay1s": "mocha --delay --exit test/delay.js",

"cov500f": "nyc --reporter=lcov --reporter=html --reporter=json --reporter=text --report-dir=coverage/500f mocha --delay --exit test/500_elastic.js",
"testRestify": "concurrently -k --success first \"npm run restifytestapp\" \"npm run covRestify\"",
"covRestify": "npm run delay1s && npm run cov000r && npm run cov100r && npm run cov200r && npm run cov300r && npm run cov400r && npm run testappstop",
"cov000r": "nyc --reporter=lcov --reporter=html --reporter=json --reporter=text --report-dir=coverage/000f mocha --delay --exit test/000_baseline.js",
"cov100r": "nyc --reporter=lcov --reporter=html --reporter=json --reporter=text --report-dir=coverage/100f mocha --delay --exit test/100_method.js",
"cov200r": "nyc --reporter=lcov --reporter=html --reporter=json --reporter=text --report-dir=coverage/200f mocha --delay --exit test/200_apicore.js",
"cov300r": "nyc --reporter=lcov --reporter=html --reporter=json --reporter=text --report-dir=coverage/300f mocha --delay --exit test/300_timeline.js",
"cov400r": "nyc --reporter=lcov --reporter=html --reporter=json --reporter=text --report-dir=coverage/400f mocha --delay --exit test/400_auth.js",
"coverage-report": "node_modules/.bin/istanbul report --root ./coverage --dir ./coverage-report lcov",

@@ -85,16 +93,15 @@ "specstest": "mocha test/specstest/swaggerspecstest.js",

"dependencies": {
"basic-auth": "^2.0.0",
"cookies": "^0.7.1",
"debug": "^3.1.0",
"moment": "^2.19.3",
"natives": "^1.1.6",
"path-to-regexp": "^2.1.0",
"prom-client": "^11.0.0",
"qs": "^6.7.0",
"request": "^2.85.0",
"basic-auth": "^2.0.1",
"cookies": "^0.8.0",
"debug": "^4.1.1",
"moment": "^2.24.0",
"path-to-regexp": "^6.1.0",
"prom-client": "^11.5.3",
"qs": "^6.9.1",
"request": "^2.88.0",
"send": "^0.17.1",
"uuid": "^3.1.0"
"uuid": "^3.4.0"
},
"devDependencies": {
"swagger-stats-ux": "^0.95.20",
"swagger-stats-ux": "^0.95.21",
"artillery": "^1.6.0-26",

@@ -117,11 +124,11 @@ "body-parser": "^1.18.2",

"font-awesome": "^4.7.0",
"gulp": "^3.9.1",
"gulp-clean-css": "^3.9.0",
"gulp": "^4.0.2",
"gulp-clean-css": "^4.2.0",
"gulp-concat": "^2.6.1",
"gulp-concat-css": "^2.3.0",
"gulp-concat-css": "^3.1.0",
"gulp-css-base64": "^1.3.4",
"gulp-minify": "^1.0.0",
"gulp-rename": "^1.2.2",
"gulp-sourcemaps": "^2.6.4",
"gulp-uglify": "^3.0.0",
"gulp-minify": "^3.1.0",
"gulp-rename": "^2.0.0",
"gulp-sourcemaps": "^2.6.5",
"gulp-uglify": "^3.0.2",
"highlightjs": "^9.10.0",

@@ -155,9 +162,10 @@ "istanbul": "^0.4.5",

"supertest": "^3.0.0",
"swagger-jsdoc": "^1.9.1",
"swagger-parser": "^3.4.1",
"swagger-jsdoc": "^3.5.0",
"swagger-parser": "^8.0.4",
"@hapi/hapi": "^18.3.2",
"@hapi/inert": "^5.2.1",
"concurrently": "^4.1.2",
"fastify": "^2.8.0"
"fastify": "^2.8.0",
"restify": "^8.5.1"
}
}

@@ -5,3 +5,3 @@ <p align="center">

# swagger-stats
# swagger-stats | API Observability

@@ -18,9 +18,6 @@

#### Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices
## API Telemetry and APM
### Express, Fastify, Koa, Hapi, Restify
> Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices
### Supports Express, Fastify, Koa and Hapi
**swagger-stats** traces REST API requests and responses in Node.js Microservices, and collects statistics per API Operation.

@@ -157,2 +154,16 @@ **swagger-stats** detects API operations based on express routes. You may also provide [Swagger (Open API) specification](https://swagger.io/specification/),

#### Restify
```javascript
const restify = require('restify');
const swStats = require('swagger-stats');
const apiSpec = require('swagger.json');
const server = restify.createServer();
server.pre(swStats.getMiddleware({
swaggerSpec:apiSpec,
}));
```
See `/examples` for sample apps

@@ -202,3 +213,3 @@

Take a look at [Documentation](http://swaggerstats.io/docs.html#api) for more details on API and returned statistics.
Take a look at [Documentation](https://swaggerstats.io/guide/) for more details on API and returned statistics.

@@ -205,0 +216,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc