roim-picx/functions/rest/type.ts

80 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

2023-02-03 15:32:07 +08:00
export interface Result {
code: number
msg: string
data?: any
}
export interface ImgItem {
key : string
url : string
size: number
2024-01-15 16:43:53 +08:00
copyUrl: string
2023-02-03 15:32:07 +08:00
filename ?: string
}
export interface ImgList {
next: boolean
cursor ?: string
list : Array<ImgItem>
prefixes ?: Array<String>
}
export interface ImgReq {
limit: number,
cursor ?: string
delimiter ?: string
}
// 文件夹名称
export interface Folder {
name: string
}
2023-03-24 15:23:15 +08:00
export function NotAuth() : Result {
return <Result> {
code: StatusCode.NotAuth,
msg: "Not Authorization",
data: null
}
}
export function FailCode(msg : string, code: number) : Result {
return <Result> {
code: code,
msg: msg,
data: null
}
}
2023-02-03 15:32:07 +08:00
export function Fail(msg : string) : Result {
return <Result> {
code: StatusCode.ERROR,
msg: msg,
data: null
}
}
export function Ok(data : any) : Result {
return <Result> {
code: StatusCode.OK,
msg: "ok",
data: data
}
}
export function Build(data : any, msg: string) : Result {
return <Result> {
code: StatusCode.OK,
msg: msg,
data: data
}
}
const StatusCode = {
OK: 200,
2023-03-24 15:23:15 +08:00
ERROR: 500,
NotAuth: 401
}
export interface AuthToken {
token: string
2023-02-03 15:32:07 +08:00
}
export default StatusCode