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

@tussle/core

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tussle/core - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

2

lib/handlers/create.d.ts
import type { TussleIncomingRequest } from '@tussle/spec/interface/request';
import type { Tussle } from '../core';
import { Observable } from 'rxjs';
export default function handleCreate<R>(core: Tussle, ctx: Readonly<TussleIncomingRequest<R>>): Observable<TussleIncomingRequest<R>>;
export default function handleCreate<R>(_core: Tussle, ctx: Readonly<TussleIncomingRequest<R>>): Observable<TussleIncomingRequest<R>>;
export interface TussleCreationParams {

@@ -6,0 +6,0 @@ id: string;

@@ -6,27 +6,10 @@ "use strict";

const operators_1 = require("rxjs/operators");
function defaultPath(path, filename) {
return [
path,
Math.floor(Math.random() * 1e16).toString(16),
encodeURIComponent(filename),
].join('/');
}
// If the before-create hook didn't set the location, for the file being
// created, then generate a default based on the request path and metadata
// filename.
const ensureFilePath = (originalPath) => (0, operators_1.map)(params => {
if (params.path === originalPath) {
params.path = defaultPath(params.path, params.uploadMetadata.filename);
}
return params;
});
function handleCreate(core, ctx) {
function handleCreate(_core, ctx) {
const params = extractCreationHeaders(ctx);
const originalPath = params.path;
const store = ctx.cfg.storage;
if (!store) {
return (0, rxjs_1.throwError)('no storage service selected');
return (0, rxjs_1.throwError)(() => new Error('no storage service selected'));
}
else {
const params$ = ctx.source.hook('before-create', ctx, params).pipe(ensureFilePath(originalPath));
const params$ = ctx.source.hook('before-create', ctx, params);
return params$.pipe((0, operators_1.switchMap)((params) => store.createFile(params)), (0, operators_1.switchMap)((createdFile) => ctx.source.hook('after-create', ctx, createdFile)), (0, operators_1.map)((createdFile) => toResponse(ctx, createdFile)));

@@ -33,0 +16,0 @@ }

import { Observable } from "rxjs";
import type { TussleIncomingRequest } from '@tussle/spec/interface/request';
import type { Tussle } from '../core';
export default function handleHead<Req>(core: Tussle, ctx: TussleIncomingRequest<Req>): Observable<TussleIncomingRequest<Req>>;
export default function handleHead<Req>(_core: Tussle, ctx: TussleIncomingRequest<Req>): Observable<TussleIncomingRequest<Req>>;
declare const extractParamsFromHeaders: <T>(ctx: TussleIncomingRequest<T>) => {

@@ -6,0 +6,0 @@ location: string;

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

const operators_1 = require("rxjs/operators");
function handleHead(core, ctx) {
function handleHead(_core, ctx) {
const params = extractParamsFromHeaders(ctx);
const store = ctx.cfg.storage;
if (!store) {
return (0, rxjs_1.throwError)('no storage service selected');
return (0, rxjs_1.throwError)(() => new Error('no storage service selected'));
}

@@ -12,0 +12,0 @@ else {

@@ -5,3 +5,3 @@ /// <reference types="node" />

import type { TussleIncomingRequest } from '@tussle/spec/interface/request';
export default function handlePatch<T>(core: Tussle, ctx: TussleIncomingRequest<T>): Observable<TussleIncomingRequest<T>>;
export default function handlePatch<T>(_core: Tussle, ctx: TussleIncomingRequest<T>): Observable<TussleIncomingRequest<T>>;
declare const extractPatchHeaders: <Req>(ctx: TussleIncomingRequest<Req>) => {

@@ -8,0 +8,0 @@ contentType: string;

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

const operators_1 = require("rxjs/operators");
function handlePatch(core, ctx) {
function handlePatch(_core, ctx) {
const params = extractPatchHeaders(ctx);
const store = ctx.cfg.storage;
if (!store) {
return (0, rxjs_1.throwError)('no storage service selected');
return (0, rxjs_1.throwError)(() => new Error('no storage service selected'));
}

@@ -13,0 +13,0 @@ // PATCH requests MUST use Content-Type: application/offset+octet-stream

{
"name": "@tussle/core",
"version": "0.2.2",
"version": "0.2.3",
"description": "Tussle tus daemon core module",

@@ -35,3 +35,3 @@ "main": "lib/index.js",

},
"gitHead": "2328201ed539a02b092d6743ca90e65354aa913f"
"gitHead": "ec8013768f04e3060ee20df06caf99cfa86f222e"
}
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