New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

server-modules

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

server-modules - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

README.md

16

build/modules/api/apiRoute.d.ts
/// <reference types="express" />
import { Request, Response, Router } from 'express';
import { NextFunction, Request, Response, Router } from 'express';
import { Logger } from '../logger/_interface';

@@ -8,3 +8,3 @@ export declare type ApiCallback<TBodyParams, TRouteParams, TSearchParams> = (req: Request & {

query: TSearchParams;
}, res: Response) => void;
}, res: Response, next: NextFunction) => void;
export declare class ApiRoute<TRouteParams> {

@@ -16,9 +16,9 @@ private _path;

constructor(_path: string);
get<TSearchParams = {}>(fn: ApiCallback<{}, TRouteParams, TSearchParams>): this;
post<TBodyParams = {}, TSearchParams = {}>(fn: ApiCallback<TBodyParams, TRouteParams, TSearchParams>): this;
put<TBodyParams = {}, TSearchParams = {}>(fn: ApiCallback<TBodyParams, TRouteParams, TSearchParams>): this;
delete<TBodyParams = {}, TSearchParams = {}>(fn: ApiCallback<TBodyParams, TRouteParams, TSearchParams>): this;
patch<TBodyParams = {}, TSearchParams = {}>(fn: ApiCallback<TBodyParams, TRouteParams, TSearchParams>): this;
get<TSearchParams = {}>(...fn: ApiCallback<{}, TRouteParams, TSearchParams>[]): this;
post<TBodyParams = {}, TSearchParams = {}>(...fn: ApiCallback<TBodyParams, TRouteParams, TSearchParams>[]): this;
put<TBodyParams = {}, TSearchParams = {}>(...fn: ApiCallback<TBodyParams, TRouteParams, TSearchParams>[]): this;
delete<TBodyParams = {}, TSearchParams = {}>(...fn: ApiCallback<TBodyParams, TRouteParams, TSearchParams>[]): this;
patch<TBodyParams = {}, TSearchParams = {}>(...fn: ApiCallback<TBodyParams, TRouteParams, TSearchParams>[]): this;
registerOn(target: Router, prevPath: string, logger: Logger): void;
private _setMethod(method, fn);
private _setMethod(method, ...fn);
}

@@ -16,20 +16,40 @@ "use strict";

});
ApiRoute.prototype.get = function (fn) {
this._setMethod('get', fn);
ApiRoute.prototype.get = function () {
var fn = [];
for (var _i = 0; _i < arguments.length; _i++) {
fn[_i] = arguments[_i];
}
this._setMethod.apply(this, ['get'].concat(fn));
return this;
};
ApiRoute.prototype.post = function (fn) {
this._setMethod('post', fn);
ApiRoute.prototype.post = function () {
var fn = [];
for (var _i = 0; _i < arguments.length; _i++) {
fn[_i] = arguments[_i];
}
this._setMethod.apply(this, ['post'].concat(fn));
return this;
};
ApiRoute.prototype.put = function (fn) {
this._setMethod('put', fn);
ApiRoute.prototype.put = function () {
var fn = [];
for (var _i = 0; _i < arguments.length; _i++) {
fn[_i] = arguments[_i];
}
this._setMethod.apply(this, ['put'].concat(fn));
return this;
};
ApiRoute.prototype.delete = function (fn) {
this._setMethod('delete', fn);
ApiRoute.prototype.delete = function () {
var fn = [];
for (var _i = 0; _i < arguments.length; _i++) {
fn[_i] = arguments[_i];
}
this._setMethod.apply(this, ['delete'].concat(fn));
return this;
};
ApiRoute.prototype.patch = function (fn) {
this._setMethod('patch', fn);
ApiRoute.prototype.patch = function () {
var fn = [];
for (var _i = 0; _i < arguments.length; _i++) {
fn[_i] = arguments[_i];
}
this._setMethod.apply(this, ['patch'].concat(fn));
return this;

@@ -44,12 +64,14 @@ };

var _loop_1 = function (method) {
var handler = this_1._requestHandler[method];
target[method](this_1._path, function (req, res) {
try {
handler(req, res);
}
catch (e) {
logger.warn("Error on " + method.toUpperCase() + " " + prevPath + _this._path, e);
throw e;
}
});
target[method].apply(target, [this_1._path].concat(this_1._requestHandler[method]
.map(function (handler) {
return function (req, res, next) {
try {
handler(req, res, next);
}
catch (e) {
logger.warn("Error on " + method.toUpperCase() + " " + prevPath + _this._path, e);
throw e;
}
};
})));
};

@@ -62,3 +84,7 @@ var this_1 = this;

};
ApiRoute.prototype._setMethod = function (method, fn) {
ApiRoute.prototype._setMethod = function (method) {
var fn = [];
for (var _i = 1; _i < arguments.length; _i++) {
fn[_i - 1] = arguments[_i];
}
if (this._requestHandler[method]) {

@@ -65,0 +91,0 @@ throw new Error("Method already registered: " + method);

@@ -54,3 +54,3 @@ export declare type LogLevel = 'off' | 'silly' | 'debug' | 'verbose' | 'info' | 'warn' | 'error';

stream: (level: LogLevel) => LoggerStream;
spawn: (name: string, id: number) => Logger;
spawn: (name: string, id?: number) => Logger;
}

@@ -17,3 +17,3 @@ import { Logger, LoggerStream, LogLevel } from './_interface';

stream(level: LogLevel): LoggerStream;
spawn(name: string, id: number): LoggerDefault;
spawn(name: string, id?: number): LoggerDefault;
}

@@ -44,3 +44,3 @@ "use strict";

var nextName = this._name ? this._name + '/' + name : name;
return new LoggerDefault(nextName, id, this._target);
return new LoggerDefault(nextName, id || 0, this._target);
};

@@ -47,0 +47,0 @@ return LoggerDefault;

{
"name": "server-modules",
"version": "0.1.3",
"version": "0.1.4",
"description": "Easy configurable server modules (logging, express, api, websocket, mongodb)",

@@ -20,2 +20,5 @@ "repository": "https://github.com/JohannesLamberts/easy-server-modules",

"license": "MIT",
"files": [
"build/**"
],
"scripts": {

@@ -22,0 +25,0 @@ "start": "node build/index.js",

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