UNPKG

3.38 kBPlain TextView Raw
1"use strict";
2
3/*************************************************************************
4 *
5 * Troven CONFIDENTIAL
6 * __________________
7 *
8 * (c) 2017-2019 Troven Pty Ltd
9 * All Rights Reserved.
10 *
11 * NOTICE: All information contained herein is, and remains
12 * the property of Troven Pty Ltd and its licensors,
13 * if any. The intellectual and technical concepts contained
14 * herein are proprietary to Troven Pty Ltd
15 * and its suppliers and may be covered by International and Regional Patents,
16 * patents in process, and are protected by trade secret or copyright law.
17 * Dissemination of this information or reproduction of this material
18 * is strictly forbidden unless prior written permission is obtained
19 * from Troven Pty Ltd.
20 */
21
22import * as core from "api-service-core";
23
24import { amqp, cors, harden, remote_config, prometheus, ua, render, webhooks } from "./plugins";
25export { amqp, cors, harden, remote_config, prometheus, ua, render, webhooks } from "./plugins";
26import { apidocs, api_config, decrypt, encrypt, local_file, redact, redirect, static_assets } from "./middleware";
27export { apidocs, api_config, decrypt, encrypt, local_file, redact, redirect, static_assets } from "./middleware";
28
29export { Chassis, IChassisPlugin, IOperation, IChassisFeature, IChassisDataStore, IChassisConfig, IChassisContext, IChassisMiddleware, IChassisLogger } from "api-service-core";
30
31/*
32 Register all our default plugins
33 These can are installed before the server starts listening
34 */
35let default_plugins = function() {
36 this.registerPlugin( new amqp );
37 this.registerPlugin( new cors );
38 this.registerPlugin( new harden );
39 this.registerPlugin( new prometheus );
40 this.registerPlugin( new ua );
41 this.registerPlugin( new render );
42 this.registerPlugin( new remote_config );
43 this.registerPlugin( new webhooks );
44
45 this.registerPlugin( new core.PipelinePlugin );
46 this.registerPlugin( new core.after );
47 this.registerPlugin( new core.before );
48 this.registerPlugin( new core.graphql );
49 this.registerPlugin( new core.logging );
50 this.registerPlugin( new core.jwt );
51 this.registerPlugin( new core.payload );
52 this.registerPlugin( new core.OpenAPIPlugin );
53}
54
55/*
56 Register all our middleware plugins
57 These can be attached as chassis:operations to Open API specs
58 */
59let default_middleware = function() {
60 this.registerFn( new core.bower_components );
61 this.registerFn( new core.debug );
62 this.registerFn( new core.DataDict );
63 this.registerFn( new core.echo );
64 this.registerFn( new core.gregarious );
65 this.registerFn( new core.heartbeat );
66 this.registerFn( new core.headers );
67 this.registerFn( new core.mock );
68 this.registerFn( new core.mount );
69 this.registerFn( new core.not_found );
70 this.registerFn( new core.proxy );
71 this.registerFn( new core.request_uuid );
72 this.registerFn( new core.sortby );
73
74 this.registerFn( new apidocs);
75 this.registerFn( new decrypt );
76 this.registerFn( new encrypt );
77 this.registerFn( new local_file );
78 this.registerFn( new api_config );
79 this.registerFn( new redact );
80 this.registerFn( new redirect );
81 this.registerFn( new static_assets );
82}
83
84export function default_features() {
85 console.log("common-defaults");
86 default_plugins.apply(this);
87 default_middleware.apply(this);
88}
89