1
0
Fork 0
peertube/server/models/request-interface.ts

48 lines
1.6 KiB
TypeScript
Raw Normal View History

2017-05-22 18:58:25 +00:00
import * as Sequelize from 'sequelize'
2017-06-10 20:15:25 +00:00
import { PodInstance, PodAttributes } from './pod-interface'
export type RequestsGrouped = {
[ podId: number ]: {
request: RequestInstance,
pod: PodInstance
}[]
}
2017-05-22 18:58:25 +00:00
export namespace RequestMethods {
2017-06-10 20:15:25 +00:00
export type CountTotalRequestsCallback = (err: Error, total: number) => void
export type CountTotalRequests = (callback: CountTotalRequestsCallback) => void
export type ListWithLimitAndRandomCallback = (err: Error, requestsGrouped?: RequestsGrouped) => void
export type ListWithLimitAndRandom = (limitPods, limitRequestsPerPod, callback: ListWithLimitAndRandomCallback) => void
export type RemoveWithEmptyToCallback = (err: Error) => void
export type RemoveWithEmptyTo = (callback: RemoveWithEmptyToCallback) => void
export type RemoveAllCallback = (err: Error) => void
export type RemoveAll = (callback: RemoveAllCallback) => void
2017-05-22 18:58:25 +00:00
}
export interface RequestClass {
countTotalRequests: RequestMethods.CountTotalRequests
listWithLimitAndRandom: RequestMethods.ListWithLimitAndRandom
removeWithEmptyTo: RequestMethods.RemoveWithEmptyTo
removeAll: RequestMethods.RemoveAll
}
export interface RequestAttributes {
request: object
endpoint: string
}
2017-06-10 20:15:25 +00:00
export interface RequestInstance extends RequestClass, RequestAttributes, Sequelize.Instance<RequestAttributes> {
2017-05-22 18:58:25 +00:00
id: number
createdAt: Date
updatedAt: Date
setPods: Sequelize.HasManySetAssociationsMixin<PodAttributes, number>
2017-06-10 20:15:25 +00:00
Pods: PodInstance[]
2017-05-22 18:58:25 +00:00
}
export interface RequestModel extends RequestClass, Sequelize.Model<RequestInstance, RequestAttributes> {}