Socket
Socket
Sign inDemoInstall

express-router-api

Package Overview
Dependencies
65
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.5 to 1.3.6

1

.vscode/launch.json

@@ -7,2 +7,3 @@ {

"configurations": [
{

@@ -9,0 +10,0 @@ "type": "node",

@@ -10,2 +10,3 @@ import { Request, Response, Router, RouterOptions } from 'express';

}
export declare const ApiNext: {};
declare type SimpleApiResult = string | boolean | number | object | {

@@ -12,0 +13,0 @@ [key: string]: string;

5

dist/index.js

@@ -26,2 +26,3 @@ "use strict";

exports.ApiError = ApiError;
exports.ApiNext = {};
class ApiResponse {

@@ -58,3 +59,3 @@ constructor(apiResult, code = 200) {

}
if (typeof apiResponse.apiResult === 'undefined') {
if (typeof apiResponse.apiResult === 'undefined' || apiResponse.apiResult === exports.ApiNext) {
return false;

@@ -134,3 +135,3 @@ }

if (!sendApiResponse(res, apiResponse)) {
if (callNext) {
if (callNext || (apiResponse && apiResponse.apiResult === exports.ApiNext)) {
next();

@@ -137,0 +138,0 @@ }

{
"name": "express-router-api",
"version": "1.3.5",
"version": "1.3.6",
"description": "Express router that lets you construct your API entirely on promises",

@@ -25,2 +25,3 @@ "main": "dist/index.js",

"request-promise": "^4.2.2",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",

@@ -27,0 +28,0 @@ "typescript": "^3.1.3"

@@ -34,2 +34,4 @@ import {

export const ApiNext = {};
type SimpleApiResult = string | boolean | number | object | { [key: string]: string; } | undefined;

@@ -83,3 +85,3 @@

if (typeof apiResponse.apiResult === 'undefined') {
if (typeof apiResponse.apiResult === 'undefined' || apiResponse.apiResult === ApiNext) {
return false;

@@ -173,3 +175,3 @@ }

if (!sendApiResponse(res, apiResponse)) {
if (callNext) {
if (callNext || (apiResponse && apiResponse.apiResult === ApiNext)) {
next();

@@ -176,0 +178,0 @@ }

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

const { Router } = require('express');
const { ExpressApiRouter, ApiError, ApiResponse, ApiErrors } = require('./dist');
require('ts-node/register');
const { ExpressApiRouter, ApiError, ApiResponse, ApiNext } = require('./src');
const {expect, assert} = require('chai');

@@ -229,2 +230,15 @@ const Promise = require('bluebird');

it('should support handling promise-based middleware', () => {
routeTest((req) => {
req.data = 'def';
return ApiNext;
}, (req, res) => {
return {foo: req.data}
});
return requestTest({
foo: 'def'
})
});
it('should support param handler', () => {

@@ -231,0 +245,0 @@ paramTest((req, res) => {

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