aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/request/request-interface.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/request/request-interface.ts')
-rw-r--r--server/models/request/request-interface.ts47
1 files changed, 47 insertions, 0 deletions
diff --git a/server/models/request/request-interface.ts b/server/models/request/request-interface.ts
new file mode 100644
index 000000000..70fd734e1
--- /dev/null
+++ b/server/models/request/request-interface.ts
@@ -0,0 +1,47 @@
1import * as Sequelize from 'sequelize'
2
3import { PodInstance, PodAttributes } from '../pod'
4
5export type RequestsGrouped = {
6 [ podId: number ]: {
7 request: RequestInstance,
8 pod: PodInstance
9 }[]
10}
11
12export namespace RequestMethods {
13 export type CountTotalRequestsCallback = (err: Error, total: number) => void
14 export type CountTotalRequests = (callback: CountTotalRequestsCallback) => void
15
16 export type ListWithLimitAndRandomCallback = (err: Error, requestsGrouped?: RequestsGrouped) => void
17 export type ListWithLimitAndRandom = (limitPods, limitRequestsPerPod, callback: ListWithLimitAndRandomCallback) => void
18
19 export type RemoveWithEmptyToCallback = (err: Error) => void
20 export type RemoveWithEmptyTo = (callback: RemoveWithEmptyToCallback) => void
21
22 export type RemoveAllCallback = (err: Error) => void
23 export type RemoveAll = (callback: RemoveAllCallback) => void
24}
25
26export interface RequestClass {
27 countTotalRequests: RequestMethods.CountTotalRequests
28 listWithLimitAndRandom: RequestMethods.ListWithLimitAndRandom
29 removeWithEmptyTo: RequestMethods.RemoveWithEmptyTo
30 removeAll: RequestMethods.RemoveAll
31}
32
33export interface RequestAttributes {
34 request: object
35 endpoint: string
36}
37
38export interface RequestInstance extends RequestClass, RequestAttributes, Sequelize.Instance<RequestAttributes> {
39 id: number
40 createdAt: Date
41 updatedAt: Date
42
43 setPods: Sequelize.HasManySetAssociationsMixin<PodAttributes, number>
44 Pods: PodInstance[]
45}
46
47export interface RequestModel extends RequestClass, Sequelize.Model<RequestInstance, RequestAttributes> {}