Setup eslint and enforce rules
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {Request} from "../lifecycle/Request";
|
||||
import {uninfer, infer, uuid_v4} from "../../util";
|
||||
import {Request} from '../lifecycle/Request'
|
||||
import {uninfer, infer, uuid4} from '../../util'
|
||||
|
||||
/**
|
||||
* Base type representing a parsed cookie.
|
||||
@@ -61,7 +61,7 @@ export class HTTPCookieJar {
|
||||
* @param value
|
||||
* @param options
|
||||
*/
|
||||
set(name: string, value: any, options?: HTTPCookieOptions) {
|
||||
set(name: string, value: unknown, options?: HTTPCookieOptions): this {
|
||||
this.parsed[name] = {
|
||||
key: name,
|
||||
value,
|
||||
@@ -69,14 +69,16 @@ export class HTTPCookieJar {
|
||||
exists: false,
|
||||
options,
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a cookie exists with the given name.
|
||||
* @param name
|
||||
*/
|
||||
has(name: string) {
|
||||
return !!this.parsed[name]
|
||||
has(name: string): boolean {
|
||||
return Boolean(this.parsed[name])
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,17 +90,21 @@ export class HTTPCookieJar {
|
||||
* @param name
|
||||
* @param options
|
||||
*/
|
||||
clear(name: string, options?: HTTPCookieOptions) {
|
||||
if ( !options ) options = {}
|
||||
clear(name: string, options?: HTTPCookieOptions): this {
|
||||
if ( !options ) {
|
||||
options = {}
|
||||
}
|
||||
options.expires = new Date(0)
|
||||
|
||||
this.parsed[name] = {
|
||||
key: name,
|
||||
value: undefined,
|
||||
originalValue: uuid_v4(),
|
||||
originalValue: uuid4(),
|
||||
exists: false,
|
||||
options,
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,10 +114,14 @@ export class HTTPCookieJar {
|
||||
const headers: string[] = []
|
||||
|
||||
for ( const key in this.parsed ) {
|
||||
if ( !this.parsed.hasOwnProperty(key) ) continue
|
||||
if ( !Object.prototype.hasOwnProperty.call(this.parsed, key) ) {
|
||||
continue
|
||||
}
|
||||
|
||||
const cookie = this.parsed[key]
|
||||
if ( cookie.exists ) continue
|
||||
if ( cookie.exists ) {
|
||||
continue
|
||||
}
|
||||
|
||||
const parts = []
|
||||
parts.push(`${key}=${encodeURIComponent(cookie.originalValue)}`)
|
||||
@@ -144,7 +154,7 @@ export class HTTPCookieJar {
|
||||
const map = {
|
||||
strict: 'Strict',
|
||||
lax: 'Lax',
|
||||
'none-secure': 'None; Secure'
|
||||
'none-secure': 'None; Secure',
|
||||
}
|
||||
|
||||
parts.push(map[cookie.options.sameSite])
|
||||
@@ -163,7 +173,9 @@ export class HTTPCookieJar {
|
||||
const parts = cookie.split('=')
|
||||
|
||||
const key = parts.shift()?.trim()
|
||||
if ( !key ) return;
|
||||
if ( !key ) {
|
||||
return
|
||||
}
|
||||
|
||||
const value = decodeURI(parts.join('='))
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import {Inject, Instantiable, Singleton} from "../../di"
|
||||
import {Collection, HTTPStatus} from "../../util"
|
||||
import {HTTPKernelModule} from "./HTTPKernelModule";
|
||||
import {Logging} from "../../service/Logging";
|
||||
import {AppClass} from "../../lifecycle/AppClass";
|
||||
import {Request} from "../lifecycle/Request";
|
||||
import {error} from "../response/ErrorResponseFactory";
|
||||
import {Inject, Instantiable, Singleton} from '../../di'
|
||||
import {Collection, HTTPStatus} from '../../util'
|
||||
import {HTTPKernelModule} from './HTTPKernelModule'
|
||||
import {Logging} from '../../service/Logging'
|
||||
import {AppClass} from '../../lifecycle/AppClass'
|
||||
import {Request} from '../lifecycle/Request'
|
||||
import {error} from '../response/ErrorResponseFactory'
|
||||
|
||||
/**
|
||||
* Interface for fluently registering kernel modules into the kernel.
|
||||
@@ -105,7 +105,8 @@ export class HTTPKernel extends AppClass {
|
||||
}
|
||||
} catch (e: any) {
|
||||
this.logging.error(e)
|
||||
await error(e).status(HTTPStatus.INTERNAL_SERVER_ERROR).write(request)
|
||||
await error(e).status(HTTPStatus.INTERNAL_SERVER_ERROR)
|
||||
.write(request)
|
||||
}
|
||||
|
||||
this.logging.verbose('Finished kernel lifecycle')
|
||||
@@ -127,16 +128,16 @@ export class HTTPKernel extends AppClass {
|
||||
return this
|
||||
}
|
||||
|
||||
let found_index = this.preflight.find((mod: HTTPKernelModule) => mod instanceof other)
|
||||
if ( typeof found_index !== 'undefined' ) {
|
||||
this.preflight = this.preflight.put(found_index, this.app().make(module))
|
||||
let foundIdx = this.preflight.find((mod: HTTPKernelModule) => mod instanceof other)
|
||||
if ( typeof foundIdx !== 'undefined' ) {
|
||||
this.preflight = this.preflight.put(foundIdx, this.app().make(module))
|
||||
return this
|
||||
} else {
|
||||
found_index = this.postflight.find((mod: HTTPKernelModule) => mod instanceof other)
|
||||
foundIdx = this.postflight.find((mod: HTTPKernelModule) => mod instanceof other)
|
||||
}
|
||||
|
||||
if ( typeof found_index !== 'undefined' ) {
|
||||
this.postflight = this.postflight.put(found_index, this.app().make(module))
|
||||
if ( typeof foundIdx !== 'undefined' ) {
|
||||
this.postflight = this.postflight.put(foundIdx, this.app().make(module))
|
||||
} else {
|
||||
throw new KernelModuleNotFoundError(other.name)
|
||||
}
|
||||
@@ -149,16 +150,16 @@ export class HTTPKernel extends AppClass {
|
||||
return this
|
||||
}
|
||||
|
||||
let found_index = this.preflight.find((mod: HTTPKernelModule) => mod instanceof other)
|
||||
if ( typeof found_index !== 'undefined' ) {
|
||||
this.preflight = this.preflight.put(found_index + 1, this.app().make(module))
|
||||
let foundIdx = this.preflight.find((mod: HTTPKernelModule) => mod instanceof other)
|
||||
if ( typeof foundIdx !== 'undefined' ) {
|
||||
this.preflight = this.preflight.put(foundIdx + 1, this.app().make(module))
|
||||
return this
|
||||
} else {
|
||||
found_index = this.postflight.find((mod: HTTPKernelModule) => mod instanceof other)
|
||||
foundIdx = this.postflight.find((mod: HTTPKernelModule) => mod instanceof other)
|
||||
}
|
||||
|
||||
if ( typeof found_index !== 'undefined' ) {
|
||||
this.postflight = this.postflight.put(found_index + 1, this.app().make(module))
|
||||
if ( typeof foundIdx !== 'undefined' ) {
|
||||
this.postflight = this.postflight.put(foundIdx + 1, this.app().make(module))
|
||||
} else {
|
||||
throw new KernelModuleNotFoundError(other.name)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {Injectable} from "../../di";
|
||||
import {AppClass} from "../../lifecycle/AppClass";
|
||||
import {HTTPKernel} from "./HTTPKernel";
|
||||
import {Request} from "../lifecycle/Request";
|
||||
import {Injectable} from '../../di'
|
||||
import {AppClass} from '../../lifecycle/AppClass'
|
||||
import {HTTPKernel} from './HTTPKernel'
|
||||
import {Request} from '../lifecycle/Request'
|
||||
|
||||
/**
|
||||
* Base class for modules that define logic that is applied to requests
|
||||
@@ -23,7 +23,7 @@ export class HTTPKernelModule extends AppClass {
|
||||
* @param {Request} request
|
||||
* @return Promise<boolean>
|
||||
*/
|
||||
public async match(request: Request): Promise<boolean> {
|
||||
public async match(request: Request): Promise<boolean> { // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ export class HTTPKernelModule extends AppClass {
|
||||
* Register this module with the given HTTP kernel.
|
||||
* @param {HTTPKernel} kernel
|
||||
*/
|
||||
public static register(kernel: HTTPKernel) {
|
||||
public static register(kernel: HTTPKernel): void {
|
||||
kernel.register(this).before()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import {HTTPKernelModule} from "../HTTPKernelModule";
|
||||
import {ResponseObject} from "../../routing/Route";
|
||||
import {Request} from "../../lifecycle/Request";
|
||||
import {plaintext} from "../../response/StringResponseFactory";
|
||||
import {ResponseFactory} from "../../response/ResponseFactory";
|
||||
import {json} from "../../response/JSONResponseFactory";
|
||||
import {HTTPKernelModule} from '../HTTPKernelModule'
|
||||
import {ResponseObject} from '../../routing/Route'
|
||||
import {Request} from '../../lifecycle/Request'
|
||||
import {plaintext} from '../../response/StringResponseFactory'
|
||||
import {ResponseFactory} from '../../response/ResponseFactory'
|
||||
import {json} from '../../response/JSONResponseFactory'
|
||||
|
||||
/**
|
||||
* Base class for HTTP kernel modules that apply some response from a route handler to the request.
|
||||
@@ -15,7 +15,7 @@ export abstract class AbstractResolvedRouteHandlerHTTPModule extends HTTPKernelM
|
||||
* @param request
|
||||
* @protected
|
||||
*/
|
||||
protected async applyResponseObject(object: ResponseObject, request: Request) {
|
||||
protected async applyResponseObject(object: ResponseObject, request: Request): Promise<void> {
|
||||
if ( (typeof object === 'string') || (typeof object === 'number') ) {
|
||||
object = plaintext(String(object))
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import {HTTPKernel} from "../HTTPKernel";
|
||||
import {Request} from "../../lifecycle/Request";
|
||||
import {ActivatedRoute} from "../../routing/ActivatedRoute";
|
||||
import {ResponseObject} from "../../routing/Route";
|
||||
import {http} from "../../response/HTTPErrorResponseFactory";
|
||||
import {HTTPStatus} from "../../../util";
|
||||
import {AbstractResolvedRouteHandlerHTTPModule} from "./AbstractResolvedRouteHandlerHTTPModule";
|
||||
import {HTTPKernel} from '../HTTPKernel'
|
||||
import {Request} from '../../lifecycle/Request'
|
||||
import {ActivatedRoute} from '../../routing/ActivatedRoute'
|
||||
import {ResponseObject} from '../../routing/Route'
|
||||
import {http} from '../../response/HTTPErrorResponseFactory'
|
||||
import {HTTPStatus} from '../../../util'
|
||||
import {AbstractResolvedRouteHandlerHTTPModule} from './AbstractResolvedRouteHandlerHTTPModule'
|
||||
|
||||
/**
|
||||
* HTTP kernel module that runs the handler for the request's route.
|
||||
@@ -12,14 +12,14 @@ import {AbstractResolvedRouteHandlerHTTPModule} from "./AbstractResolvedRouteHan
|
||||
* In most cases, this is the controller method defined by the route.
|
||||
*/
|
||||
export class ExecuteResolvedRouteHandlerHTTPModule extends AbstractResolvedRouteHandlerHTTPModule {
|
||||
public static register(kernel: HTTPKernel) {
|
||||
public static register(kernel: HTTPKernel): void {
|
||||
kernel.register(this).core()
|
||||
}
|
||||
|
||||
public async apply(request: Request) {
|
||||
public async apply(request: Request): Promise<Request> {
|
||||
if ( request.hasInstance(ActivatedRoute) ) {
|
||||
const route = <ActivatedRoute> request.make(ActivatedRoute)
|
||||
let object: ResponseObject = await route.handler(request)
|
||||
const object: ResponseObject = await route.handler(request)
|
||||
|
||||
await this.applyResponseObject(object, request)
|
||||
} else {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import {HTTPKernel} from "../HTTPKernel";
|
||||
import {Request} from "../../lifecycle/Request";
|
||||
import {ActivatedRoute} from "../../routing/ActivatedRoute";
|
||||
import {ResponseObject} from "../../routing/Route";
|
||||
import {AbstractResolvedRouteHandlerHTTPModule} from "./AbstractResolvedRouteHandlerHTTPModule";
|
||||
import {PersistSessionHTTPModule} from "./PersistSessionHTTPModule";
|
||||
import {HTTPKernel} from '../HTTPKernel'
|
||||
import {Request} from '../../lifecycle/Request'
|
||||
import {ActivatedRoute} from '../../routing/ActivatedRoute'
|
||||
import {ResponseObject} from '../../routing/Route'
|
||||
import {AbstractResolvedRouteHandlerHTTPModule} from './AbstractResolvedRouteHandlerHTTPModule'
|
||||
import {PersistSessionHTTPModule} from './PersistSessionHTTPModule'
|
||||
|
||||
/**
|
||||
* HTTP kernel module that executes the postflight handlers for the route.
|
||||
@@ -11,18 +11,18 @@ import {PersistSessionHTTPModule} from "./PersistSessionHTTPModule";
|
||||
* Usually, this is post middleware.
|
||||
*/
|
||||
export class ExecuteResolvedRoutePostflightHTTPModule extends AbstractResolvedRouteHandlerHTTPModule {
|
||||
public static register(kernel: HTTPKernel) {
|
||||
public static register(kernel: HTTPKernel): void {
|
||||
kernel.register(this).before(PersistSessionHTTPModule)
|
||||
}
|
||||
|
||||
public async apply(request: Request) {
|
||||
public async apply(request: Request): Promise<Request> {
|
||||
if ( request.hasInstance(ActivatedRoute) ) {
|
||||
const route = <ActivatedRoute> request.make(ActivatedRoute)
|
||||
const postflight = route.postflight
|
||||
|
||||
for ( const handler of postflight ) {
|
||||
const result: ResponseObject = await handler(request)
|
||||
if ( typeof result !== "undefined" ) {
|
||||
if ( typeof result !== 'undefined' ) {
|
||||
await this.applyResponseObject(result, request)
|
||||
request.response.blockingWriteback(true)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import {HTTPKernel} from "../HTTPKernel";
|
||||
import {MountActivatedRouteHTTPModule} from "./MountActivatedRouteHTTPModule";
|
||||
import {Request} from "../../lifecycle/Request";
|
||||
import {ActivatedRoute} from "../../routing/ActivatedRoute";
|
||||
import {ResponseObject} from "../../routing/Route";
|
||||
import {AbstractResolvedRouteHandlerHTTPModule} from "./AbstractResolvedRouteHandlerHTTPModule";
|
||||
import {HTTPKernel} from '../HTTPKernel'
|
||||
import {MountActivatedRouteHTTPModule} from './MountActivatedRouteHTTPModule'
|
||||
import {Request} from '../../lifecycle/Request'
|
||||
import {ActivatedRoute} from '../../routing/ActivatedRoute'
|
||||
import {ResponseObject} from '../../routing/Route'
|
||||
import {AbstractResolvedRouteHandlerHTTPModule} from './AbstractResolvedRouteHandlerHTTPModule'
|
||||
|
||||
/**
|
||||
* HTTP Kernel module that executes the preflight handlers for the route.
|
||||
@@ -11,18 +11,18 @@ import {AbstractResolvedRouteHandlerHTTPModule} from "./AbstractResolvedRouteHan
|
||||
* Usually, this is the pre middleware.
|
||||
*/
|
||||
export class ExecuteResolvedRoutePreflightHTTPModule extends AbstractResolvedRouteHandlerHTTPModule {
|
||||
public static register(kernel: HTTPKernel) {
|
||||
public static register(kernel: HTTPKernel): void {
|
||||
kernel.register(this).after(MountActivatedRouteHTTPModule)
|
||||
}
|
||||
|
||||
public async apply(request: Request) {
|
||||
public async apply(request: Request): Promise<Request> {
|
||||
if ( request.hasInstance(ActivatedRoute) ) {
|
||||
const route = <ActivatedRoute> request.make(ActivatedRoute)
|
||||
const preflight = route.preflight
|
||||
|
||||
for ( const handler of preflight ) {
|
||||
const result: ResponseObject = await handler(request)
|
||||
if ( typeof result !== "undefined" ) {
|
||||
if ( typeof result !== 'undefined' ) {
|
||||
await this.applyResponseObject(result, request)
|
||||
request.response.blockingWriteback(true)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import {HTTPKernelModule} from "../HTTPKernelModule";
|
||||
import {Injectable} from "../../../di"
|
||||
import {ErrorWithContext} from "../../../util"
|
||||
import {HTTPKernel} from "../HTTPKernel";
|
||||
import {Request} from "../../lifecycle/Request";
|
||||
import {SetSessionCookieHTTPModule} from "./SetSessionCookieHTTPModule";
|
||||
import {SessionFactory} from "../../session/SessionFactory";
|
||||
import {Session} from "../../session/Session";
|
||||
import {HTTPKernelModule} from '../HTTPKernelModule'
|
||||
import {Injectable} from '../../../di'
|
||||
import {ErrorWithContext} from '../../../util'
|
||||
import {HTTPKernel} from '../HTTPKernel'
|
||||
import {Request} from '../../lifecycle/Request'
|
||||
import {SetSessionCookieHTTPModule} from './SetSessionCookieHTTPModule'
|
||||
import {SessionFactory} from '../../session/SessionFactory'
|
||||
import {Session} from '../../session/Session'
|
||||
|
||||
/**
|
||||
* HTTP kernel middleware that creates the session using the configured driver
|
||||
@@ -15,11 +15,11 @@ import {Session} from "../../session/Session";
|
||||
export class InjectSessionHTTPModule extends HTTPKernelModule {
|
||||
public readonly executeWithBlockingWriteback = true
|
||||
|
||||
public static register(kernel: HTTPKernel) {
|
||||
public static register(kernel: HTTPKernel): void {
|
||||
kernel.register(this).after(SetSessionCookieHTTPModule)
|
||||
}
|
||||
|
||||
public async apply(request: Request) {
|
||||
public async apply(request: Request): Promise<Request> {
|
||||
request.registerFactory(new SessionFactory())
|
||||
|
||||
const session = <Session> request.make(Session)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import {Injectable, Inject} from "../../../di"
|
||||
import {HTTPKernelModule} from "../HTTPKernelModule";
|
||||
import {HTTPKernel} from "../HTTPKernel";
|
||||
import {Request} from "../../lifecycle/Request";
|
||||
import {Routing} from "../../../service/Routing";
|
||||
import {ActivatedRoute} from "../../routing/ActivatedRoute";
|
||||
import {Logging} from "../../../service/Logging";
|
||||
import {Injectable, Inject} from '../../../di'
|
||||
import {HTTPKernelModule} from '../HTTPKernelModule'
|
||||
import {HTTPKernel} from '../HTTPKernel'
|
||||
import {Request} from '../../lifecycle/Request'
|
||||
import {Routing} from '../../../service/Routing'
|
||||
import {ActivatedRoute} from '../../routing/ActivatedRoute'
|
||||
import {Logging} from '../../../service/Logging'
|
||||
|
||||
/**
|
||||
* HTTP kernel middleware that tries to find a registered route matching the request's
|
||||
@@ -20,7 +20,7 @@ export class MountActivatedRouteHTTPModule extends HTTPKernelModule {
|
||||
@Inject()
|
||||
protected readonly logging!: Logging
|
||||
|
||||
public static register(kernel: HTTPKernel) {
|
||||
public static register(kernel: HTTPKernel): void {
|
||||
kernel.register(this).before()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import {HTTPKernelModule} from "../HTTPKernelModule"
|
||||
import {HTTPKernel} from "../HTTPKernel"
|
||||
import * as Busboy from "busboy"
|
||||
import {Request} from "../../lifecycle/Request"
|
||||
import {infer, uuid_v4} from "../../../util"
|
||||
import {Files} from "../../../service/Files"
|
||||
import {Config} from "../../../service/Config"
|
||||
import {Logging} from "../../../service/Logging"
|
||||
import {Injectable, Inject, Container} from "../../../di"
|
||||
import {HTTPKernelModule} from '../HTTPKernelModule'
|
||||
import {HTTPKernel} from '../HTTPKernel'
|
||||
import * as Busboy from 'busboy'
|
||||
import {Request} from '../../lifecycle/Request'
|
||||
import {infer, uuid4} from '../../../util'
|
||||
import {Files} from '../../../service/Files'
|
||||
import {Config} from '../../../service/Config'
|
||||
import {Logging} from '../../../service/Logging'
|
||||
import {Injectable, Inject, Container} from '../../../di'
|
||||
|
||||
@Injectable()
|
||||
export class ParseIncomingBodyHTTPModule extends HTTPKernelModule {
|
||||
static register(kernel: HTTPKernel) {
|
||||
static register(kernel: HTTPKernel): void {
|
||||
const files = <Files> Container.getContainer().make(Files)
|
||||
const logging = <Logging> Container.getContainer().make(Logging)
|
||||
if ( !files.hasFilesystem() ) {
|
||||
@@ -32,8 +32,11 @@ export class ParseIncomingBodyHTTPModule extends HTTPKernelModule {
|
||||
public async apply(request: Request): Promise<Request> {
|
||||
const contentType = request.getHeader('content-type')
|
||||
const contentTypes = (Array.isArray(contentType) ? contentType : [contentType])
|
||||
.filter(Boolean).map(x => x!.toLowerCase().split(';')[0])
|
||||
if ( !contentType ) return request
|
||||
.filter(Boolean).map(x => String(x).toLowerCase()
|
||||
.split(';')[0])
|
||||
if ( !contentType ) {
|
||||
return request
|
||||
}
|
||||
|
||||
if (
|
||||
contentTypes.includes('multipart/form-data')
|
||||
@@ -65,7 +68,10 @@ export class ParseIncomingBodyHTTPModule extends HTTPKernelModule {
|
||||
try {
|
||||
const body = JSON.parse(data)
|
||||
for ( const key in body ) {
|
||||
if ( !body.hasOwnProperty(key) ) continue
|
||||
if ( !Object.prototype.hasOwnProperty.call(body, key) ) {
|
||||
continue
|
||||
}
|
||||
|
||||
request.parsedInput[key] = body[key]
|
||||
}
|
||||
res()
|
||||
@@ -94,8 +100,10 @@ export class ParseIncomingBodyHTTPModule extends HTTPKernelModule {
|
||||
request.parsedInput[field] = infer(val)
|
||||
})
|
||||
|
||||
busboy.on('file', async (field, file, filename, encoding, mimetype) => {
|
||||
if ( !this.files.hasFilesystem() ) return
|
||||
busboy.on('file', async (field, file, filename, encoding, mimetype) => { // eslint-disable-line max-params
|
||||
if ( !this.files.hasFilesystem() ) {
|
||||
return
|
||||
}
|
||||
|
||||
if ( !config?.enable ) {
|
||||
this.logging.warn(`Skipping uploaded file '${filename}' because uploading is disabled. Set the server.uploads.enable config to allow uploads.`)
|
||||
@@ -122,7 +130,7 @@ export class ParseIncomingBodyHTTPModule extends HTTPKernelModule {
|
||||
}
|
||||
|
||||
const fs = this.files.getFilesystem()
|
||||
const storePath = `${config.filesystemPrefix ? config.filesystemPrefix : ''}${(config.filesystemPrefix && !config.filesystemPrefix.endsWith('/')) ? '/' : ''}${field}-${uuid_v4()}`
|
||||
const storePath = `${config.filesystemPrefix ? config.filesystemPrefix : ''}${(config.filesystemPrefix && !config.filesystemPrefix.endsWith('/')) ? '/' : ''}${field}-${uuid4()}`
|
||||
this.logging.verbose(`Uploading file in field ${field} to ${fs.getPrefix()}${storePath}`)
|
||||
file.pipe(await fs.putStoreFileAsStream({ storePath })) // FIXME might need to revisit this to ensure we don't res() before pipe finishes
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {HTTPKernelModule} from "../HTTPKernelModule";
|
||||
import {Injectable} from "../../../di"
|
||||
import {HTTPKernel} from "../HTTPKernel";
|
||||
import {Request} from "../../lifecycle/Request";
|
||||
import {Session} from "../../session/Session";
|
||||
import {HTTPKernelModule} from '../HTTPKernelModule'
|
||||
import {Injectable} from '../../../di'
|
||||
import {HTTPKernel} from '../HTTPKernel'
|
||||
import {Request} from '../../lifecycle/Request'
|
||||
import {Session} from '../../session/Session'
|
||||
|
||||
/**
|
||||
* HTTP kernel module that runs after the main logic in the request to persist
|
||||
@@ -12,7 +12,7 @@ import {Session} from "../../session/Session";
|
||||
export class PersistSessionHTTPModule extends HTTPKernelModule {
|
||||
public readonly executeWithBlockingWriteback = true
|
||||
|
||||
public static register(kernel: HTTPKernel) {
|
||||
public static register(kernel: HTTPKernel): void {
|
||||
kernel.register(this).last()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {HTTPKernelModule} from "../HTTPKernelModule";
|
||||
import {Request} from "../../lifecycle/Request";
|
||||
import {Injectable, Inject} from "../../../di"
|
||||
import {HTTPKernel} from "../HTTPKernel";
|
||||
import {Config} from "../../../service/Config";
|
||||
import {HTTPKernelModule} from '../HTTPKernelModule'
|
||||
import {Request} from '../../lifecycle/Request'
|
||||
import {Injectable, Inject} from '../../../di'
|
||||
import {HTTPKernel} from '../HTTPKernel'
|
||||
import {Config} from '../../../service/Config'
|
||||
|
||||
/**
|
||||
* HTTP kernel middleware that sets the `X-Powered-By` header.
|
||||
@@ -14,11 +14,11 @@ export class PoweredByHeaderInjectionHTTPModule extends HTTPKernelModule {
|
||||
@Inject()
|
||||
protected readonly config!: Config;
|
||||
|
||||
public static register(kernel: HTTPKernel) {
|
||||
public static register(kernel: HTTPKernel): void {
|
||||
kernel.register(this).after()
|
||||
}
|
||||
|
||||
public async apply(request: Request) {
|
||||
public async apply(request: Request): Promise<Request> {
|
||||
if ( !this.config.get('server.poweredBy.hide', false) ) {
|
||||
request.response.setHeader('X-Powered-By', this.config.get('server.poweredBy.header', 'Extollo'))
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import {HTTPKernelModule} from "../HTTPKernelModule";
|
||||
import {Injectable, Inject} from "../../../di";
|
||||
import {uuid_v4} from "../../../util";
|
||||
import {HTTPKernel} from "../HTTPKernel";
|
||||
import {Request} from "../../lifecycle/Request";
|
||||
import {Logging} from "../../../service/Logging";
|
||||
import {HTTPKernelModule} from '../HTTPKernelModule'
|
||||
import {Injectable, Inject} from '../../../di'
|
||||
import {uuid4} from '../../../util'
|
||||
import {HTTPKernel} from '../HTTPKernel'
|
||||
import {Request} from '../../lifecycle/Request'
|
||||
import {Logging} from '../../../service/Logging'
|
||||
|
||||
/**
|
||||
* HTTP kernel middleware that tries to look up the session ID from the request.
|
||||
@@ -16,13 +16,13 @@ export class SetSessionCookieHTTPModule extends HTTPKernelModule {
|
||||
@Inject()
|
||||
protected readonly logging!: Logging
|
||||
|
||||
public static register(kernel: HTTPKernel) {
|
||||
public static register(kernel: HTTPKernel): void {
|
||||
kernel.register(this).first()
|
||||
}
|
||||
|
||||
public async apply(request: Request) {
|
||||
public async apply(request: Request): Promise<Request> {
|
||||
if ( !request.cookies.has('extollo.session') ) {
|
||||
const session = `${uuid_v4()}-${uuid_v4()}`
|
||||
const session = `${uuid4()}-${uuid4()}`
|
||||
|
||||
this.logging.verbose(`Starting session: ${session}`)
|
||||
request.cookies.set('extollo.session', session)
|
||||
|
||||
Reference in New Issue
Block a user