/
controller.ts
32 lines (26 loc) · 1.13 KB
/
controller.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { app } from "@arkecosystem/core-container";
import { PostgresConnection } from "@arkecosystem/core-database-postgres";
import { Blockchain, Logger } from "@arkecosystem/core-interfaces";
import Hapi from "hapi";
import { paginate, respondWith, respondWithCache, toCollection, toResource } from "../utils";
export class Controller {
protected config = app.getConfig();
protected blockchain = app.resolvePlugin<Blockchain.IBlockchain>("blockchain");
protected database = app.resolvePlugin<PostgresConnection>("database");
protected logger = app.resolvePlugin<Logger.ILogger>("logger");
protected paginate(request: Hapi.Request): any {
return paginate(request);
}
protected respondWith(data, error = false): object {
return respondWith(data, error);
}
protected respondWithCache(data, h): any {
return respondWithCache(data, h);
}
protected toResource(request, data, transformer): object {
return toResource(request, data, transformer);
}
protected toCollection(request, data, transformer): object {
return toCollection(request, data, transformer);
}
}