Express
Express related exports.
type ExpressApiFunction = (ids: OrArray<string>, accountId?: string, host?: Plugins) => Promise<DataOrError<Api>>
type ExpressApiOptionsFunction = (ids: OrArray<string>, accountId?: string, host?: Plugins) => Promise<DataOrError<ApiOptions>>
type ExpressAuthFunction = (user: string, password: string) => boolean
interface ExpressAuthInfo {
auth: object
}
type ExpressHostFunction = (accountId?: string) => Promise<Plugins>
interface ExpressUnsafeAuth
extends UnknownRecord {
password?: string
type?: string
users?: StringRecord
}
type ExpressWillLaunchFunction = (app: Application) => Promise<(Errored|void)>
interface MMExpress
extends WithId {
api: ExpressApiFunction
apiOptions: ExpressApiOptionsFunction
args: MMExpressArgs
host: ExpressHostFunction
id: string
willLaunch: ExpressWillLaunchFunction
}
interface MMExpressApiArgs
extends MMExpressArgs {
apisDir?: AbsolutePath
authentication?: MMExpressAuthentication
outputRoot?: AbsolutePath
requestRoot?: AbsolutePath
sharedUser?: string
}
interface MMExpressArgs
extends UnknownRecord {
authentication?: MMExpressAuthentication
outputRoot?: AbsolutePath
}
interface MMExpressAuthentication
extends UnknownRecord {
password?: string
type?: string
users?: StringRecord
}
interface MMExpressHostArgs {
api?: MMExpressApiArgs | false
corsOptions?: StringRecord | false
web?: MMExpressWebArgs | false
}
interface MMExpressWebArgs
extends MMExpressArgs {
authentication?: MMExpressAuthentication
jsonDir?: AbsolutePath
outputRoot?: AbsolutePath
publicDirectories?: StringRecord
root?: AbsolutePath
}
type ReceivesParameters<T>[0]
type Returns<T = PluginFunction> = UnwrapPromise<ReturnType<T>>
/** @implements MMExpress */
class MMExpressApi
extends MMExpressClass {
add: ExpressJSHandler<ApiAddFunction>
api: ExpressApiFunction
apiOptions: ExpressApiOptionsFunction
apis: ExpressJSHandler<ApiApisFunction>
args: MMExpressArgs
decode: ExpressJSHandler<ApiDecodeFunction>
delete: ExpressJSHandler<ApiDeleteFunction>
download: ExpressJSHandler<ApiDownloadFunction>
encode: ExpressJSHandler<ApiEncodeFunction>
file: ExpressHandler<DataOrError<MediaUploadResponse>, MediaUploadRequest>
find: ExpressJSHandler<ApiFindFunction>
host: ExpressHostFunction
id: string
insert: ExpressJSHandler<ApiInsertFunction>
mash: ExpressJSHandler<ApiMashFunction>
media: ExpressJSHandler<ApiMediaFunction>
remove: ExpressJSHandler<ApiRemoveFunction>
status: ExpressJSHandler<ApiStatusFunction>
transcode: ExpressJSHandler<ApiTranscodeFunction>
upload: ExpressJSHandler<ApiUploadFunction>
userFromRequest: (req: unknown) => string
willLaunch: ExpressWillLaunchFunction
}
/** @implements MMExpress */
class MMExpressClass {
api: ExpressApiFunction
apiOptions: ExpressApiOptionsFunction
args: MMExpressArgs
host: ExpressHostFunction
id: string
userFromRequest: (req: unknown) => string
willLaunch: ExpressWillLaunchFunction
}
/** @implements MMExpress */
class MMExpressWebClass
extends MMExpressClass {
api: ExpressApiFunction
apiOptions: ExpressApiOptionsFunction
args: MMExpressArgs
host: ExpressHostFunction
id: string
userFromRequest: (req: unknown) => string
willLaunch: ExpressWillLaunchFunction
}
function authedUserFromRequest(
req: unknown
): string
function registerAuthentication(
app: Router,
scope: string,
options?: ExpressUnsafeAuth
): Router