diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 09:45:46 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 09:45:46 +0200 |
commit | 74889a71fe687dda74f2a687653122327807af36 (patch) | |
tree | e938e8b6401b74fbec80513a877d9967f2c0dbcd /server/models/request/request-interface.ts | |
parent | 15a302943d84bc0978b84fe33110c4daa451d311 (diff) | |
download | PeerTube-74889a71fe687dda74f2a687653122327807af36.tar.gz PeerTube-74889a71fe687dda74f2a687653122327807af36.tar.zst PeerTube-74889a71fe687dda74f2a687653122327807af36.zip |
Reorganize model files
Diffstat (limited to 'server/models/request/request-interface.ts')
-rw-r--r-- | server/models/request/request-interface.ts | 47 |
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 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | import { PodInstance, PodAttributes } from '../pod' | ||
4 | |||
5 | export type RequestsGrouped = { | ||
6 | [ podId: number ]: { | ||
7 | request: RequestInstance, | ||
8 | pod: PodInstance | ||
9 | }[] | ||
10 | } | ||
11 | |||
12 | export 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 | |||
26 | export interface RequestClass { | ||
27 | countTotalRequests: RequestMethods.CountTotalRequests | ||
28 | listWithLimitAndRandom: RequestMethods.ListWithLimitAndRandom | ||
29 | removeWithEmptyTo: RequestMethods.RemoveWithEmptyTo | ||
30 | removeAll: RequestMethods.RemoveAll | ||
31 | } | ||
32 | |||
33 | export interface RequestAttributes { | ||
34 | request: object | ||
35 | endpoint: string | ||
36 | } | ||
37 | |||
38 | export 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 | |||
47 | export interface RequestModel extends RequestClass, Sequelize.Model<RequestInstance, RequestAttributes> {} | ||