Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

appolo-agent

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appolo-agent - npm Package Compare versions

Comparing version 6.0.31 to 6.0.32

19

lib/agent.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const appolo_route_1 = require("appolo-route");
const appolo_utils_1 = require("appolo-utils");
const util_1 = require("./util");

@@ -13,6 +14,4 @@ const types_1 = require("./types");

const http = require("http");
const _ = require("lodash");
const url = require("url");
const qs = require("qs");
const Q = require("bluebird");
const querystring = require("querystring");

@@ -56,3 +55,3 @@ const response_1 = require("./response");

};
this._options = _.defaults(options || {}, defaults_1.Defaults);
this._options = Object.assign({}, defaults_1.Defaults, options);
this._qsParse = this._options.qsParser === "qs" ? qs.parse : querystring.parse;

@@ -68,3 +67,3 @@ this._urlParse = this._options.urlParser === "fast" ? util_1.Util.parseUrlFast : url.parse;

});
_.forEach(types_1.Hooks, hook => this._hooks[hook] = []);
appolo_utils_1.Enums.enumValues(types_1.Hooks).forEach(hook => this._hooks[hook] = []);
this._view = new view_1.View(this._options);

@@ -90,3 +89,3 @@ this._server = server_1.Server.createServer(this);

_initializeHandler(handler) {
_.forEach(this._hooks, (hook, hookName) => handler.hooks[hookName] = [...hook, ...(handler.hooks[hookName] || [])]);
Object.keys(this._hooks).forEach(hookName => handler.hooks[hookName] = [...this._hooks[hookName], ...(handler.hooks[hookName] || [])]);
if (handler.hooks.onSend.length) {

@@ -152,4 +151,4 @@ handler.hooks.onSend.push(function (data, req, res, next) {

add(method, path, handlers, route, hooks) {
handlers = _(handlers).map(handler => _.isArray(handler) ? handler : [handler]).flatten().value();
let result = _.partition(handlers, handler => handler.length <= 3);
handlers = appolo_utils_1.Arrays.flat(handlers.map(handler => Array.isArray(handler) ? handler : [handler]));
let result = appolo_utils_1.Arrays.partition(handlers, handler => handler.length <= 3);
let middlewares = result[0];

@@ -198,3 +197,3 @@ let errors = result[1];

}
let result = _.partition(fn, handler => handler.length <= 3);
let result = appolo_utils_1.Arrays.partition(fn, handler => handler.length <= 3);
if (result[0].length) {

@@ -220,3 +219,3 @@ this._middlewares.push(...result[0]);

try {
await Q.fromCallback(c => this._server.close(c));
await appolo_utils_1.Promises.fromCallback(c => this._server.close(c));
this._requestApp.fireEvent(events_1.Events.ServerClosed);

@@ -232,3 +231,3 @@ }

this._initialize();
await Q.fromCallback(c => this._server.listen(port, c));
await appolo_utils_1.Promises.fromCallback(c => this._server.listen(port, c));
(cb) && cb(this);

@@ -235,0 +234,0 @@ return this;

import {IOptions} from "./IOptions";
import {Methods, Router} from 'appolo-route';
import {IRequest} from "./request";
import {Arrays, Enums, Promises} from "appolo-utils";
import {Util} from "./util";

@@ -29,6 +30,4 @@ import {

import https = require('https');
import _ = require('lodash');
import url = require('url');
import qs = require('qs');
import Q = require('bluebird');
import querystring = require('querystring');

@@ -59,3 +58,3 @@ import {sendMiddleware} from "./response";

this._options = _.defaults(options || {}, Defaults);
this._options = Object.assign({}, Defaults, options);

@@ -75,3 +74,3 @@ this._qsParse = this._options.qsParser === "qs" ? qs.parse : querystring.parse;

_.forEach(Hooks, hook => this._hooks[hook] = []);
Enums.enumValues<Hooks>(Hooks).forEach(hook => this._hooks[hook] = []);

@@ -110,4 +109,4 @@ this._view = new View(this._options);

_.forEach(this._hooks, (hook, hookName) =>
handler.hooks[hookName] = [...hook, ...(handler.hooks[hookName] || [])]);
Object.keys(this._hooks).forEach(hookName =>
handler.hooks[hookName] = [...this._hooks[hookName], ...(handler.hooks[hookName] || [])]);

@@ -228,3 +227,3 @@ if (handler.hooks.onSend.length) {

.add(Methods.DELETE, path, handler)
.add(Methods.HEAD, path, handler)
.add(Methods.HEAD, path, handler);

@@ -236,5 +235,5 @@ return this;

handlers = _(handlers).map(handler => _.isArray(handler) ? handler : [handler]).flatten().value();
handlers = Arrays.flat<MiddlewareHandlerParams>(handlers.map(handler => Array.isArray(handler) ? handler : [handler]));
let result = _.partition(handlers, handler => handler.length <= 3);
let result = Arrays.partition(handlers, handler => handler.length <= 3);

@@ -273,3 +272,3 @@ let middlewares = result[0] as MiddlewareHandlerOrAny[];

if(routeHandler){
if (routeHandler) {
routeHandler.errors.push(...errors);

@@ -283,4 +282,2 @@ routeHandler.middlewares.push(...middlewares);

if (this._isInitialized) {

@@ -301,3 +298,3 @@ this._initializeHandler(dto);

let result = _.partition(fn, handler => handler.length <= 3);
let result = Arrays.partition(fn, handler => handler.length <= 3);

@@ -330,3 +327,3 @@ if (result[0].length) {

try {
await Q.fromCallback(c => this._server.close(c));
await Promises.fromCallback(c => this._server.close(c));
this._requestApp.fireEvent(Events.ServerClosed);

@@ -344,3 +341,3 @@

await Q.fromCallback(c => this._server.listen(port, c));
await Promises.fromCallback(c => this._server.listen(port, c as any));

@@ -347,0 +344,0 @@ (cb) && cb(this);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const httpError_1 = require("./errors/httpError");
const _ = require("lodash");
const appolo_utils_1 = require("appolo-utils");
class ErrorHandler {

@@ -21,4 +21,4 @@ static getStatusCode(err) {

if (e instanceof httpError_1.HttpError) {
if (_.isPlainObject(e.data)) {
_.extend(dto, e.data);
if (appolo_utils_1.Objects.isPlain(e.data)) {
Object.assign(dto, e.data);
}

@@ -25,0 +25,0 @@ dto.message = e.message;

@@ -1,6 +0,3 @@

import {IResponse} from "./response";
import {HttpError} from "./errors/httpError";
import {NextFn} from "./types";
import {IRequest} from "./request";
import _ = require("lodash");
import {Objects} from "appolo-utils";

@@ -31,4 +28,4 @@ export class ErrorHandler {

if (_.isPlainObject(e.data)) {
_.extend(dto, e.data)
if (Objects.isPlain(e.data)) {
Object.assign(dto, e.data)
}

@@ -54,2 +51,2 @@

}
}
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const http = require("http");
const _ = require("lodash");
const typeis = require("type-is");

@@ -10,3 +9,3 @@ const url_1 = require("url");

proto.is = function (types) {
return typeis.apply(typeis, [this].concat(_.toArray(arguments)));
return typeis.apply(typeis, [this].concat(Array.from(arguments)));
};

@@ -67,3 +66,6 @@ proto.get = proto.header = function (name) {

enumerable: true,
get: getter
get: getter,
set: function (value) {
this[name] = value;
}
});

@@ -70,0 +72,0 @@ }

import http = require('http');
import _ = require('lodash');
import typeis = require('type-is');

@@ -46,3 +45,3 @@ import {parse} from "url";

return typeis.apply(typeis, [this].concat(_.toArray(arguments)));
return typeis.apply(typeis, [this].concat(Array.from(arguments)));
};

@@ -128,3 +127,6 @@

enumerable: true,
get: getter
get: getter,
set:function (value) {
this[name] = value
}
});

@@ -131,0 +133,0 @@ }

@@ -6,4 +6,4 @@ "use strict";

const cookie = require("cookie");
const _ = require("lodash");
const mime = require("mime");
const appolo_utils_1 = require("appolo-utils");
const middleware_1 = require("./middleware");

@@ -37,3 +37,3 @@ const statusEmpty = {

}
let paths = _.isArray(path) ? path : [path];
let paths = Array.isArray(path) ? path : [path];
if (!this.hasHeader("Content-Type")) {

@@ -68,3 +68,3 @@ this.setHeader("Content-Type", "text/html;charset=utf-8");

let opts = options || {};
let val = _.isObject(value) ? 'j:' + JSON.stringify(value) : String(value);
let val = appolo_utils_1.Objects.isPlain(value) || Array.isArray(value) ? 'j:' + JSON.stringify(value) : String(value);
if ('maxAge' in opts) {

@@ -102,5 +102,5 @@ opts.expires = new Date(Date.now() + opts.maxAge);

}
let val = _.isArray(current)
let val = Array.isArray(current)
? current.concat(value)
: (_.isArray(value) ? [current].concat(value) : [current, value]);
: (Array.isArray(value) ? [current].concat(value) : [current, value]);
return this.setHeader(field, val);

@@ -107,0 +107,0 @@ };

import http = require('http');
import zlib = require('zlib');
import cookie = require('cookie');
import _ = require('lodash');
import mime = require('mime');
import {IRequest} from "./request";
import {Objects,Arrays} from "appolo-utils";
import {handleMiddleware} from "./middleware";
import {Util} from "./util";

@@ -83,3 +84,3 @@ const statusEmpty = {

let paths = _.isArray(path) ? path : [path];
let paths = Array.isArray(path) ? path : [path];

@@ -124,3 +125,3 @@

let val: string = _.isObject(value) ? 'j:' + JSON.stringify(value) : String(value);
let val: string = Objects.isPlain(value)|| Array.isArray(value) ? 'j:' + JSON.stringify(value) : String(value);

@@ -170,5 +171,5 @@ if ('maxAge' in opts) {

}
let val: string[] = _.isArray(current)
let val: string[] = Array.isArray(current)
? current.concat(value)
: (_.isArray(value) ? [current].concat(value) : [current, value]);
: (Array.isArray(value) ? [current].concat(value) : [current, value]);

@@ -175,0 +176,0 @@ return this.setHeader(field, val);

@@ -5,5 +5,5 @@ "use strict";

const httpError_1 = require("./errors/httpError");
const appolo_utils_1 = require("appolo-utils");
const fs = require("fs");
const path = require("path");
const Q = require("bluebird");
class View {

@@ -69,3 +69,3 @@ constructor(_options) {

try {
let result = await Q.fromCallback(c => fs.stat(path, c));
let result = await appolo_utils_1.Util.promises.fromCallback(c => fs.stat(path, c));
return result.isFile();

@@ -72,0 +72,0 @@ }

@@ -5,5 +5,5 @@ import {Cache} from "appolo-cache";

import {IResponse} from "./response";
import {Util} from "appolo-utils";
import fs = require("fs");
import path = require("path");
import Q = require("bluebird");

@@ -103,3 +103,3 @@ export class View {

try {
let result: fs.Stats = await Q.fromCallback<fs.Stats>(c => fs.stat(path, c));
let result: fs.Stats = await Util.promises.fromCallback<fs.Stats>(c => fs.stat(path, c));
return result.isFile();

@@ -106,0 +106,0 @@ } catch (e) {

@@ -27,3 +27,3 @@ {

"main": "./index.js",
"version": "6.0.31",
"version": "6.0.32",
"license": "MIT",

@@ -38,7 +38,8 @@ "repository": {

"appolo-cache": "^6.0.6",
"appolo-event-dispatcher": "^6.0.8",
"appolo-route": "^6.0.3",
"bluebird": "^3.5.3",
"appolo-event-dispatcher": "^6.0.14",
"appolo-route": "^6.0.4",
"appolo-utils": "^0.0.23",
"bluebird": "^3.7.2",
"cookie": "^0.3.1",
"lodash": "^4.17.11",
"lodash": "^4.17.15",
"mime": "^2.4.3",

@@ -51,33 +52,32 @@ "qs": "^6.6.0",

"@types/benchmark": "^1.0.31",
"@types/bluebird": "^3.5.24",
"@types/chai": "^4.1.7",
"@types/chai-http": "^3.0.5",
"@types/cookie": "^0.3.2",
"@types/express": "^4.16.1",
"@types/lodash": "^4.14.119",
"@types/chai": "^4.2.7",
"@types/chai-http": "^4.2.0",
"@types/cookie": "^0.3.3",
"@types/express": "^4.17.2",
"@types/lodash": "^4.14.149",
"@types/mime": "^2.0.1",
"@types/mocha": "^5.2.5",
"@types/node": "^10.12.14",
"@types/mocha": "^5.2.7",
"@types/node": "^13.1.8",
"@types/qs": "^6.5.1",
"@types/sinon": "^7.0.0",
"@types/sinon-chai": "^3.2.2",
"@types/supertest": "^2.0.7",
"@types/type-is": "^1.6.2",
"autocannon": "^3.2.0",
"@types/sinon": "^7.5.1",
"@types/sinon-chai": "^3.2.3",
"@types/supertest": "^2.0.8",
"@types/type-is": "^1.6.3",
"autocannon": "^4.4.2",
"benchmark": "^2.1.4",
"body-parser": "^1.18.3",
"body-parser": "^1.19.0",
"chai": "^4.2.0",
"chai-http": "^4.2.0",
"chai-http": "^4.3.0",
"cli-table": "^0.3.1",
"consolidate": "^0.15.1",
"express": "^4.16.4",
"fastify": "^1.13.1",
"mocha": "^5.2.0",
"express": "^4.17.1",
"fastify": "^2.11.0",
"mocha": "^7.0.0",
"nunjucks": "^3.2.0",
"nyc": "^14.1.1",
"sinon": "^7.2.4",
"sinon-chai": "^3.3.0",
"supertest": "^3.3.0",
"typescript": "^3.2.2"
"sinon": "^8.1.1",
"sinon-chai": "^3.4.0",
"supertest": "^4.0.2",
"typescript": "^3.7.5"
}
}

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

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc