UNPKG

8.61 kBJavaScriptView Raw
1"use strict";
2// Copyright IBM Corp. 2017,2020. All Rights Reserved.
3// Node module: @loopback/rest
4// This file is licensed under the MIT License.
5// License text available at https://opensource.org/licenses/MIT
6Object.defineProperty(exports, "__esModule", { value: true });
7exports.RestTags = exports.RestBindings = void 0;
8const core_1 = require("@loopback/core");
9const express_1 = require("@loopback/express");
10/**
11 * RestServer-specific bindings
12 */
13var RestBindings;
14(function (RestBindings) {
15 /**
16 * Binding key for setting and injecting RestComponentConfig
17 */
18 RestBindings.CONFIG = core_1.CoreBindings.APPLICATION_CONFIG.deepProperty('rest');
19 /**
20 * Binding key for setting and injecting the host name of RestServer
21 */
22 RestBindings.HOST = core_1.BindingKey.create('rest.host');
23 /**
24 * Binding key for setting and injecting the port number of RestServer
25 */
26 RestBindings.PORT = core_1.BindingKey.create('rest.port');
27 /**
28 * Binding key for setting and injecting the socket path of the RestServer
29 */
30 RestBindings.PATH = core_1.BindingKey.create('rest.path');
31 /**
32 * Binding key for setting and injecting the URL of RestServer
33 */
34 RestBindings.URL = core_1.BindingKey.create('rest.url');
35 /**
36 * Binding key for setting and injecting the protocol of RestServer
37 */
38 RestBindings.PROTOCOL = core_1.BindingKey.create('rest.protocol');
39 /**
40 * Binding key for HTTPS options
41 */
42 RestBindings.HTTPS_OPTIONS = core_1.BindingKey.create('rest.httpsOptions');
43 /**
44 * Binding key for the server itself
45 */
46 RestBindings.SERVER = core_1.BindingKey.create('servers.RestServer');
47 /**
48 * Internal binding key for basePath
49 */
50 RestBindings.BASE_PATH = core_1.BindingKey.create('rest.basePath');
51 /**
52 * Internal binding key for http-handler
53 */
54 RestBindings.HANDLER = core_1.BindingKey.create('rest.handler');
55 /**
56 * Internal binding key for rest router
57 */
58 RestBindings.ROUTER = core_1.BindingKey.create('rest.router');
59 RestBindings.ROUTER_OPTIONS = core_1.BindingKey.create('rest.router.options');
60 /**
61 * Binding key for setting and injecting Reject action's error handling
62 * options.
63 *
64 * See https://github.com/loopbackio/strong-error-handler#options for
65 * the list of available options. Please note that the flag `log` is not used
66 * by `@loopback/rest`.
67 */
68 RestBindings.ERROR_WRITER_OPTIONS = core_1.BindingKey.create('rest.errorWriterOptions');
69 /**
70 * Binding key for request body parser options
71 */
72 RestBindings.REQUEST_BODY_PARSER_OPTIONS = core_1.BindingKey.create('rest.requestBodyParserOptions');
73 /**
74 * Binding key for request body parser
75 */
76 RestBindings.REQUEST_BODY_PARSER = core_1.BindingKey.create('rest.requestBodyParser');
77 function bodyParserBindingKey(parser) {
78 return `${RestBindings.REQUEST_BODY_PARSER}.${parser}`;
79 }
80 /**
81 * Binding key for request json body parser
82 */
83 RestBindings.REQUEST_BODY_PARSER_JSON = core_1.BindingKey.create(bodyParserBindingKey('JsonBodyParser'));
84 /**
85 * Binding key for request urlencoded body parser
86 */
87 RestBindings.REQUEST_BODY_PARSER_URLENCODED = core_1.BindingKey.create(bodyParserBindingKey('UrlEncodedBodyParser'));
88 /**
89 * Binding key for request text body parser
90 */
91 RestBindings.REQUEST_BODY_PARSER_TEXT = core_1.BindingKey.create(bodyParserBindingKey('TextBodyParser'));
92 /**
93 * Binding key for request raw body parser
94 */
95 RestBindings.REQUEST_BODY_PARSER_RAW = core_1.BindingKey.create(bodyParserBindingKey('RawBodyParser'));
96 /**
97 * Binding key for request raw body parser
98 */
99 RestBindings.REQUEST_BODY_PARSER_STREAM = core_1.BindingKey.create(bodyParserBindingKey('StreamBodyParser'));
100 /**
101 * Binding key for AJV
102 */
103 RestBindings.AJV_FACTORY = core_1.BindingKey.create(bodyParserBindingKey('rest.ajvFactory'));
104 /**
105 * Binding key for setting and injecting an OpenAPI spec
106 */
107 RestBindings.API_SPEC = core_1.BindingKey.create('rest.apiSpec');
108 /**
109 * Binding key for setting and injecting an OpenAPI operation spec
110 */
111 RestBindings.OPERATION_SPEC_CURRENT = core_1.BindingKey.create('rest.operationSpec.current');
112 /**
113 * Binding key for setting and injecting a Sequence
114 */
115 RestBindings.SEQUENCE = core_1.BindingKey.create('rest.sequence');
116 /**
117 * Binding key for setting and injecting a `invokeMiddleware` function for
118 * middleware based sequence
119 */
120 RestBindings.INVOKE_MIDDLEWARE_SERVICE = core_1.BindingKey.create('rest.invokeMiddleware');
121 /**
122 * Bindings for potential actions that could be used in a sequence
123 */
124 let SequenceActions;
125 (function (SequenceActions) {
126 /**
127 * Binding key for setting and injecting `invokeMiddleware` function
128 */
129 SequenceActions.INVOKE_MIDDLEWARE = core_1.BindingKey.create('rest.sequence.actions.invokeMiddleware');
130 /**
131 * Binding key for setting and injecting a route finding function
132 */
133 SequenceActions.FIND_ROUTE = core_1.BindingKey.create('rest.sequence.actions.findRoute');
134 /**
135 * Binding key for setting and injecting a parameter parsing function
136 */
137 SequenceActions.PARSE_PARAMS = core_1.BindingKey.create('rest.sequence.actions.parseParams');
138 /**
139 * Binding key for setting and injecting a controller route invoking function
140 */
141 SequenceActions.INVOKE_METHOD = core_1.BindingKey.create('rest.sequence.actions.invokeMethod');
142 /**
143 * Binding key for setting and injecting an error logging function
144 */
145 SequenceActions.LOG_ERROR = core_1.BindingKey.create('rest.sequence.actions.logError');
146 /**
147 * Binding key for setting and injecting a response writing function
148 */
149 SequenceActions.SEND = core_1.BindingKey.create('rest.sequence.actions.send');
150 /**
151 * Binding key for setting and injecting a bad response writing function
152 */
153 SequenceActions.REJECT = core_1.BindingKey.create('rest.sequence.actions.reject');
154 })(SequenceActions = RestBindings.SequenceActions || (RestBindings.SequenceActions = {}));
155 let Operation;
156 (function (Operation) {
157 Operation.ROUTE = core_1.BindingKey.create('rest.operation.route');
158 Operation.PARAMS = core_1.BindingKey.create('rest.operation.params');
159 Operation.RETURN_VALUE = core_1.BindingKey.create('rest.operation.returnValue');
160 })(Operation = RestBindings.Operation || (RestBindings.Operation = {}));
161 /**
162 * Request-specific bindings
163 */
164 let Http;
165 (function (Http) {
166 /**
167 * Binding key for setting and injecting the http request
168 */
169 Http.REQUEST = core_1.BindingKey.create('rest.http.request');
170 /**
171 * Binding key for setting and injecting the http response
172 */
173 Http.RESPONSE = core_1.BindingKey.create('rest.http.response');
174 /**
175 * Binding key for setting and injecting the http request context
176 */
177 Http.CONTEXT = core_1.BindingKey.create('rest.http.request.context');
178 })(Http = RestBindings.Http || (RestBindings.Http = {}));
179 /**
180 * Namespace for REST routes
181 */
182 RestBindings.ROUTES = 'routes';
183})(RestBindings = exports.RestBindings || (exports.RestBindings = {}));
184/**
185 * Binding tags for RestServer
186 */
187var RestTags;
188(function (RestTags) {
189 /**
190 * Binding tag to identify REST routes
191 */
192 RestTags.REST_ROUTE = 'restRoute';
193 /**
194 * Binding tag for the REST route verb
195 */
196 RestTags.ROUTE_VERB = 'restRouteVerb';
197 /**
198 * Binding tag for the REST route path
199 */
200 RestTags.ROUTE_PATH = 'restRoutePath';
201 /**
202 * Binding tag to identify controller based REST routes
203 */
204 RestTags.CONTROLLER_ROUTE = 'controllerRoute';
205 /**
206 * Binding tag for controller route bindings to represent the controller
207 * binding key
208 */
209 RestTags.CONTROLLER_BINDING = 'controllerBinding';
210 RestTags.AJV_KEYWORD = 'ajvKeyword';
211 RestTags.AJV_FORMAT = 'ajvFormat';
212 RestTags.REST_MIDDLEWARE_CHAIN = express_1.DEFAULT_MIDDLEWARE_CHAIN;
213 /**
214 * Legacy middleware chain for action-based REST sequence
215 */
216 RestTags.ACTION_MIDDLEWARE_CHAIN = 'middlewareChain.rest.actions';
217})(RestTags = exports.RestTags || (exports.RestTags = {}));
218//# sourceMappingURL=keys.js.map
\No newline at end of file