@tussle/core
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -6,4 +6,12 @@ # Change Log | ||
## [0.0.2](https://github.com/Klowner/tussle/compare/v0.0.1...v0.0.2) (2020-11-19) | ||
**Note:** Version bump only for package @tussle/core | ||
## [0.0.1](https://github.com/Klowner/tussle/compare/v0.0.0...v0.0.1) (2020-10-03) | ||
**Note:** Version bump only for package @tussle/core |
import type { Observable } from 'rxjs'; | ||
import type { TusProtocolExtension } from './tus-protocol.interface'; | ||
import type { TussleIncomingRequest } from './request.interface'; | ||
import type { TussleStorage, TussleStorageCreateFileResponse, TussleStorageCreateFileParams } from './storage.interface'; | ||
import type { TusProtocolExtension } from '@tussle/spec/interface/tus'; | ||
import type { TussleIncomingRequest } from '@tussle/spec/interface/request'; | ||
import type { TussleStorageService, TussleStorageCreateFileResponse, TussleStorageCreateFileParams } from '@tussle/spec/interface/storage'; | ||
export interface TussleConfig { | ||
maxSizeBytes?: number; | ||
storage: TussleStorage | Record<'default' | string, TussleStorage>; | ||
storage: TussleStorageService | Record<'default' | string, TussleStorageService>; | ||
hooks?: Partial<Record<TussleEventHook, TussleHookFunc>>; | ||
@@ -18,3 +18,3 @@ } | ||
readonly extensions: Partial<Record<TusProtocolExtension, boolean>>; | ||
readonly storage: Partial<Record<'default' | string, TussleStorage>>; | ||
readonly storage: Partial<Record<'default' | string, TussleStorageService>>; | ||
readonly hooks: Partial<Record<TussleEventHook, TussleHookFunc>>; | ||
@@ -28,3 +28,3 @@ constructor(cfg: TussleConfig); | ||
setHandler(method: IncomingRequestMethod, handler: IncomingRequestHandler): void; | ||
getStorage(name?: string): TussleStorage; | ||
getStorage(name?: string): TussleStorageService; | ||
hook<T>(name: TussleEventHook, ctx: TussleIncomingRequest<unknown>, params: T): Observable<T>; | ||
@@ -31,0 +31,0 @@ hasHook(name: TussleEventHook): boolean; |
@@ -13,3 +13,2 @@ "use strict"; | ||
const options_1 = __importDefault(require("./handlers/options")); | ||
const commaJoin = (...items) => items.join(','); | ||
const supportedVersions = [ | ||
@@ -16,0 +15,0 @@ '1.0.0', |
import type { Observable } from 'rxjs'; | ||
import type { TussleIncomingRequest } from '../request.interface'; | ||
import type { TussleIncomingRequest } from '@tussle/spec/interface/request'; | ||
import type { Tussle } from '../core'; | ||
export default function handleCreate<T>(core: Tussle, ctx: TussleIncomingRequest<T>): Observable<TussleIncomingRequest<T>>; |
@@ -59,9 +59,7 @@ "use strict"; | ||
const toResponse = (ctx, createdFile) => { | ||
var _a; | ||
if (createdFile.location) { | ||
ctx.response = { | ||
status: 201, | ||
headers: { | ||
'Location': createdFile.location, | ||
'Tussle-Storage': 'b2', | ||
}, | ||
headers: Object.assign({ 'Location': createdFile.location, 'Tussle-Storage': 'b2' }, (_a = ctx.response) === null || _a === void 0 ? void 0 : _a.headers), | ||
}; | ||
@@ -68,0 +66,0 @@ } |
import type { Observable } from "rxjs"; | ||
import type { TussleIncomingRequest } from "../request.interface"; | ||
import type { TussleIncomingRequest } from '@tussle/spec/interface/request'; | ||
import type { Tussle } from '../core'; | ||
export default function handleHead<T>(core: Tussle, ctx: TussleIncomingRequest<T>): Observable<TussleIncomingRequest<T>>; |
import type { Observable } from 'rxjs'; | ||
import type { TussleIncomingRequest } from '../request.interface'; | ||
import type { TussleIncomingRequest } from '@tussle/spec/interface/request'; | ||
import type { Tussle } from '../core'; | ||
export default function handleOptions<T>(core: Tussle, ctx: TussleIncomingRequest<T>): Observable<TussleIncomingRequest<T>>; |
import type { Observable } from 'rxjs'; | ||
import type { Tussle } from '../core'; | ||
import type { TussleIncomingRequest } from '../request.interface'; | ||
import type { TussleIncomingRequest } from '@tussle/spec/interface/request'; | ||
export default function handlePatch<T>(core: Tussle, ctx: TussleIncomingRequest<T>): Observable<TussleIncomingRequest<T>>; |
@@ -20,5 +20,8 @@ "use strict"; | ||
exports.default = handlePatch; | ||
function isComplete(response) { | ||
return response.complete; | ||
} | ||
const callOptionalHooks = (core, ctx, patchedFile) => { | ||
ctx.meta.storage = patchedFile.details; | ||
if (patchedFile.complete) { | ||
if (isComplete(patchedFile)) { | ||
return core.hook('after-complete', ctx, patchedFile); | ||
@@ -47,8 +50,7 @@ } | ||
const toResponse = (ctx, patchedFile) => { | ||
var _a; | ||
if (patchedFile.success && patchedFile.offset !== undefined) { | ||
ctx.response = { | ||
status: 204, | ||
headers: { | ||
'Upload-Offset': patchedFile.offset.toString(10), | ||
} | ||
headers: Object.assign({ 'Upload-Offset': patchedFile.offset.toString(10) }, (_a = ctx.response) === null || _a === void 0 ? void 0 : _a.headers) | ||
}; | ||
@@ -55,0 +57,0 @@ } |
import { Tussle, TussleConfig } from './core'; | ||
import type { TusProtocolExtension } from './tus-protocol.interface'; | ||
import type { TussleStorage } from './storage.interface'; | ||
import type { TussleIncomingRequest, TussleOutgoingResponse, TussleOutgoingRequest, TussleRequestService } from './request.interface'; | ||
import type { TusProtocolExtension } from '@tussle/spec/interface/tus'; | ||
import type { TussleStorageService } from '@tussle/spec/interface/storage'; | ||
import type { TussleIncomingRequest, TussleOutgoingResponse, TussleOutgoingRequest, TussleRequestService } from '@tussle/spec/interface/request'; | ||
import { TussleStateNamespace } from './state'; | ||
import { TTLCache } from './util/ttlcache'; | ||
export { Tussle, TusProtocolExtension, TussleConfig, TussleIncomingRequest, TussleOutgoingRequest, TussleOutgoingResponse, TussleRequestService, TussleStateNamespace, TussleStorage, TTLCache, }; | ||
export { Tussle, TusProtocolExtension, TussleConfig, TussleIncomingRequest, TussleOutgoingRequest, TussleOutgoingResponse, TussleRequestService, TussleStateNamespace, TussleStorageService, TTLCache, }; |
@@ -1,2 +0,2 @@ | ||
import type { TussleStateService } from './state.interface'; | ||
import type { TussleStateService } from '@tussle/spec/interface/state'; | ||
declare type SuperReturnType<T, U extends keyof TussleStateService<T>> = ReturnType<TussleStateService<T>[U]>; | ||
@@ -3,0 +3,0 @@ declare class TussleStateNamespace<T> implements TussleStateService<T> { |
{ | ||
"name": "@tussle/core", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Tussle tus daemon core module", | ||
@@ -23,2 +23,3 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"jest": "^26.4.2", | ||
"npm-run-all": "^4.1.5", | ||
@@ -30,3 +31,7 @@ "rimraf": "^3.0.2" | ||
}, | ||
"gitHead": "3ff35583004c2c4f0b1dab331dc2a1972b6559dd" | ||
"jest": { | ||
"preset": "ts-jest", | ||
"testEnvironment": "node" | ||
}, | ||
"gitHead": "6fdcd06e76ae86fd9f140b36d0d5baab43f78323" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24026
3
19
525