133 lines
3.1 KiB
TypeScript
133 lines
3.1 KiB
TypeScript
import { AbstractUser } from "../src/server/interfaces/index.js";
|
|
import { ObjectId } from 'mongodb';
|
|
import { LoggerClientOptions } from '@navy.gif/logger';
|
|
import { MariaOptions, MongoOptions } from '@navy.gif/wrappers';
|
|
import { Request as ExpressRequest, Response as ExpressResponse, NextFunction } from "express";
|
|
import http from 'http';
|
|
import { UploadedFile } from "express-fileupload";
|
|
import { Session } from "express-session";
|
|
|
|
export type RateLimit = {
|
|
limit: number,
|
|
time: number,
|
|
disabled?: boolean
|
|
}
|
|
|
|
export type RateLimits = {
|
|
[key: string]: RateLimit
|
|
}
|
|
|
|
export type RegistryOptions = {
|
|
path: string
|
|
}
|
|
|
|
export type EndpointOptions = {
|
|
path: string,
|
|
name: string,
|
|
loadOrder?: number
|
|
}
|
|
|
|
type HttpOptions = {
|
|
port: number
|
|
} & http.ServerOptions
|
|
|
|
export type OAuthProvider = {
|
|
name: string,
|
|
iconURL: string,
|
|
authoriseURL: string,
|
|
tokenURL: string,
|
|
profileURL: string
|
|
}
|
|
|
|
export type ServerOptions = {
|
|
dir: string,
|
|
name: string,
|
|
http: HttpOptions,
|
|
databases: {
|
|
mariadb?: MariaOptions,
|
|
mongodb?: MongoOptions
|
|
},
|
|
logger?: LoggerClientOptions,
|
|
domain: string,
|
|
serveFiles: string,
|
|
registrationEnabled: boolean,
|
|
requireCodeForRegister: boolean,
|
|
OAuthProviders: OAuthProvider[],
|
|
callbackPath: string,
|
|
discord: {
|
|
scope?: string[],
|
|
version?: number
|
|
}
|
|
}
|
|
|
|
export type Permissions = {
|
|
[key: string]: number | Permissions
|
|
}
|
|
|
|
export type ExternalProfile = {
|
|
provider: string,
|
|
username: string,
|
|
id: string,
|
|
accessToken?: string
|
|
}
|
|
|
|
export type EntityData = {
|
|
[key:string]: unknown
|
|
id?: string | ObjectId,
|
|
name?: string,
|
|
disabled?: boolean,
|
|
permissions?: Permissions,
|
|
createdTimestamp?: number
|
|
}
|
|
|
|
export type AbstractUserData = {
|
|
icon?: string | null,
|
|
roles?: string[],
|
|
temporary?: boolean
|
|
} & EntityData
|
|
|
|
export type UserData = {
|
|
applications?: string[],
|
|
externalProfiles?: { [key: string]: ExternalProfile },
|
|
password?: string | null,
|
|
otpSecret?: string | null,
|
|
twoFactor?: boolean,
|
|
displayName?: string | null
|
|
} & AbstractUserData
|
|
|
|
export type ApplicationData = {
|
|
token: string,
|
|
ownerId: string | ObjectId,
|
|
description: string | null
|
|
} & AbstractUserData
|
|
|
|
export type RoleData = {
|
|
position: number,
|
|
rateLimits?: RateLimits
|
|
} & EntityData
|
|
|
|
export type EntityJson = { [key: string]: string | string[] | number | boolean | null | ObjectId | Permissions | unknown }
|
|
// export type UserJson = { externalProfiles: {[key: string]: ExternalProfile} } & EntityJson;
|
|
|
|
export type Request = {
|
|
user: AbstractUser,
|
|
session: {
|
|
verified: boolean,
|
|
loginMethod: string
|
|
} & Session,
|
|
files: {[key: string]: UploadedFile}
|
|
} & ExpressRequest
|
|
|
|
export type Response = {
|
|
//
|
|
} & ExpressResponse
|
|
|
|
export type MiddlewareFunction = (req: Request, res: Response, next: NextFunction) => void
|
|
export type HandlerFunction = (req: Request, res: Response) => void
|
|
|
|
export type SessionLimit = {
|
|
budget: number,
|
|
reset: number
|
|
}
|
|
|
|
export type AuthFunction = (req: Request, res: Response, next: NextFunction) => void |