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

@thisisagile/easy

Package Overview
Dependencies
Maintainers
2
Versions
1266
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thisisagile/easy - npm Package Compare versions

Comparing version 1.8.7 to 1.8.8

26

dist/services/RequestOptions.d.ts
import { ContentType } from './ContentType';
export declare class RequestOptions {
headers: {
import { Enum, JsonValue } from '../types';
export declare class RequestOptions extends Enum {
readonly type: ContentType;
readonly headers: {
[key: string]: any;
};
constructor(contentType?: ContentType);
static get json(): RequestOptions;
static get text(): RequestOptions;
static get xml(): RequestOptions;
static get form(): RequestOptions;
get contentType(): ContentType;
set contentType(type: ContentType);
type(type: ContentType): RequestOptions;
authorization(auth: string): RequestOptions;
accept(type: ContentType): RequestOptions;
static Json: RequestOptions;
static Text: RequestOptions;
static Xml: RequestOptions;
static Form: RequestOptions;
constructor(type?: ContentType, headers?: {
[key: string]: any;
});
authorization: (auth: string) => this;
accept: (type: ContentType) => this;
bearer: (jwt: JsonValue) => this;
}

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

const ContentType_1 = require("./ContentType");
class RequestOptions {
constructor(contentType = ContentType_1.ContentType.Json) {
this.headers = {};
this.contentType = contentType;
const types_1 = require("../types");
class RequestOptions extends types_1.Enum {
constructor(type = ContentType_1.ContentType.Json, headers = {}) {
super(type.name);
this.type = type;
this.headers = headers;
this.authorization = (auth) => {
this.headers.Authorization = auth;
return this;
};
this.accept = (type) => {
this.headers.Accept = type.id;
return this;
};
this.bearer = (jwt) => {
if (types_1.isNotEmpty(jwt)) {
this.authorization(`Bearer ${jwt}`);
}
return this;
};
this.headers['Content-Type'] = type.id;
// this.headers['X-Correlation-Id'] = context.request.correlation ?? newId();
}
static get json() {
return new RequestOptions();
}
static get text() {
return new RequestOptions(ContentType_1.ContentType.Text);
}
static get xml() {
return new RequestOptions(ContentType_1.ContentType.Xml);
}
static get form() {
return new RequestOptions(ContentType_1.ContentType.Form);
}
get contentType() {
return ContentType_1.ContentType.byId(this.headers['Content-Type']);
}
set contentType(type) {
this.headers['Content-Type'] = type.id;
}
type(type) {
this.contentType = type;
return this;
}
authorization(auth) {
this.headers.Authorization = auth;
return this;
}
accept(type) {
this.headers['Accept'] = type.id;
return this;
}
}
exports.RequestOptions = RequestOptions;
RequestOptions.Json = new RequestOptions(ContentType_1.ContentType.Json);
RequestOptions.Text = new RequestOptions(ContentType_1.ContentType.Text);
RequestOptions.Xml = new RequestOptions(ContentType_1.ContentType.Xml);
RequestOptions.Form = new RequestOptions(ContentType_1.ContentType.Form);
//# sourceMappingURL=RequestOptions.js.map
{
"name": "@thisisagile/easy",
"version": "1.8.7",
"version": "1.8.8",
"description": "Straightforward library for building domain-driven microservice architectures",

@@ -5,0 +5,0 @@ "author": "Sander Hoogendoorn",

import { ContentType } from './ContentType';
import { Enum, isNotEmpty, JsonValue } from '../types';
export class RequestOptions {
headers: { [key: string]: any } = {};
constructor(contentType: ContentType = ContentType.Json) {
this.contentType = contentType;
// this.headers['X-Correlation-Id'] = context.request.correlation ?? newId();
}
export class RequestOptions extends Enum {
static get json(): RequestOptions {
return new RequestOptions();
}
static Json = new RequestOptions(ContentType.Json);
static Text = new RequestOptions(ContentType.Text);
static Xml = new RequestOptions(ContentType.Xml);
static Form = new RequestOptions(ContentType.Form);
static get text(): RequestOptions {
return new RequestOptions(ContentType.Text);
}
static get xml(): RequestOptions {
return new RequestOptions(ContentType.Xml);
}
static get form(): RequestOptions {
return new RequestOptions(ContentType.Form);
}
get contentType(): ContentType {
return ContentType.byId(this.headers['Content-Type']);
}
set contentType(type: ContentType) {
constructor(readonly type: ContentType = ContentType.Json, readonly headers: { [key: string]: any } = {}) {
super(type.name);
this.headers['Content-Type'] = type.id;
// this.headers['X-Correlation-Id'] = context.request.correlation ?? newId();
}
type(type: ContentType): RequestOptions {
this.contentType = type;
authorization = (auth: string): this => {
this.headers.Authorization = auth;
return this;
}
};
authorization(auth: string): RequestOptions {
this.headers.Authorization = auth;
accept = (type: ContentType): this => {
this.headers.Accept = type.id;
return this;
}
};
accept(type: ContentType): RequestOptions {
this.headers['Accept'] = type.id;
bearer = (jwt: JsonValue): this => {
if (isNotEmpty(jwt)) { this.authorization(`Bearer ${jwt}`); }
return this;
}
//
// bearer(jwt: Jwt): RequestOptions {
// return Try.ofDefined(() => jwt)
// .map(j => this.authorization(`Bearer ${j.value}`))
// .recover(() => this).value;
// }
};
}

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