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

express-result-types

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-result-types - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

target/types.d.ts

2

package.json

@@ -5,3 +5,3 @@ {

"typings": "./target/index.d.ts",
"version": "0.0.3",
"version": "0.0.4",
"scripts": {

@@ -8,0 +8,0 @@ "lint": "tslint --project tsconfig.json --type-check",

@@ -31,6 +31,7 @@ export declare class ResponseHeader {

export declare class JsValue {
value: any;
constructor(value: any);
value: {};
constructor(value: {});
}
export declare const jsValueWriteable: Writeable<JsValue>;
export declare const stringWriteable: Writeable<string>;
export declare class Status extends Result {

@@ -37,0 +38,0 @@ constructor(status: number);

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

const map_1 = require("./helpers/map");
const types_1 = require("./types");
// https://github.com/playframework/playframework/blob/49e1bbccdf19501f1c94732ecbef5f4f3ba0ce24/framework/src/play/src/main/scala/play/api/mvc/Results.scala#L32

@@ -60,3 +61,5 @@ class ResponseHeader {

// https://github.com/playframework/playframework/blob/8fc8bbae7fcd2dc63b19667191ce3735c7181d96/framework/src/play/src/main/scala/play/api/http/Writeable.scala#L106
exports.jsValueWriteable = new Writeable(jsValue => JSON.stringify(jsValue.value), 'application/json');
exports.jsValueWriteable = new Writeable(jsValue => JSON.stringify(jsValue.value), types_1.ContentType.ApplicationJson);
// https://github.com/playframework/playframework/blob/8fc8bbae7fcd2dc63b19667191ce3735c7181d96/framework/src/play/src/main/scala/play/api/http/Writeable.scala#L171
exports.stringWriteable = new Writeable(str => str, 'text/string');
// https://github.com/playframework/playframework/blob/49e1bbccdf19501f1c94732ecbef5f4f3ba0ce24/framework/src/play/src/main/scala/play/api/mvc/Results.scala#L389

@@ -72,7 +75,4 @@ class Status extends Result {

exports.Status = Status;
const HeaderNames = {
Location: 'Location',
};
// https://github.com/playframework/playframework/blob/49e1bbccdf19501f1c94732ecbef5f4f3ba0ce24/framework/src/play/src/main/scala/play/api/mvc/Results.scala#L664
exports.Redirect = (url, statusCode) => new Status(statusCode).withHeaders(new Map([[HeaderNames.Location, url]]));
exports.Redirect = (url, statusCode) => new Status(statusCode).withHeaders(new Map([[types_1.Header.Location, url]]));
exports.TemporaryRedirect = (url) => exports.Redirect(url, HttpStatusCodes.TEMPORARY_REDIRECT);

@@ -79,0 +79,0 @@ exports.Ok = new Status(HttpStatusCodes.OK);

/// <reference types="express" />
import * as express from 'express';
import { Result } from './result';
export declare type ExpressRequestSession = {
data: {
[key: string]: string;
};
};
export declare const applyResultToExpress: ({req, res, result}: {

@@ -5,0 +10,0 @@ req: express.Request;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const MapHelpers = require("./helpers/map");
const types_1 = require("./types");
exports.applyResultToExpress = ({ req, res, result, }) => {

@@ -9,5 +10,6 @@ const headersStringDictionary = MapHelpers.toStringDictionary(result.header.headers);

: undefined;
const requestSession = req.session;
if (maybeSessionStringDictionary !== undefined) {
const sessionStringDictionary = maybeSessionStringDictionary;
req.session.data = sessionStringDictionary;
requestSession.data = sessionStringDictionary;
}

@@ -18,3 +20,3 @@ res

.set(result.body.contentType !== undefined
? { 'Content-Type': result.body.contentType }
? { [types_1.Header.ContentType]: result.body.contentType }
: {})

@@ -21,0 +23,0 @@ .send(result.body.data);

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