UNPKG

7.21 kBTypeScriptView Raw
1/// <reference types="node" />
2/// <reference types="node" />
3/// <reference types="express" />
4import { BindingKey, Context } from '@loopback/core';
5import { InvokeMiddleware } from '@loopback/express';
6import { HttpProtocol } from '@loopback/http-server';
7import { OpenApiSpec, OperationObject } from '@loopback/openapi-v3';
8import https from 'https';
9import { ErrorWriterOptions } from 'strong-error-handler';
10import { BodyParser, RequestBodyParser } from './body-parsers';
11import { HttpHandler } from './http-handler';
12import { RestServer, RestServerConfig } from './rest.server';
13import { ResolvedRoute, RestRouter, RestRouterOptions } from './router';
14import { SequenceHandler } from './sequence';
15import { AjvFactory, FindRoute, InvokeMethod, LogError, OperationArgs, ParseParams, Reject, Request, RequestBodyParserOptions, Response, Send } from './types';
16/**
17 * RestServer-specific bindings
18 */
19export declare namespace RestBindings {
20 /**
21 * Binding key for setting and injecting RestComponentConfig
22 */
23 const CONFIG: BindingKey<RestServerConfig>;
24 /**
25 * Binding key for setting and injecting the host name of RestServer
26 */
27 const HOST: BindingKey<string | undefined>;
28 /**
29 * Binding key for setting and injecting the port number of RestServer
30 */
31 const PORT: BindingKey<number>;
32 /**
33 * Binding key for setting and injecting the socket path of the RestServer
34 */
35 const PATH: BindingKey<string | undefined>;
36 /**
37 * Binding key for setting and injecting the URL of RestServer
38 */
39 const URL: BindingKey<string>;
40 /**
41 * Binding key for setting and injecting the protocol of RestServer
42 */
43 const PROTOCOL: BindingKey<HttpProtocol>;
44 /**
45 * Binding key for HTTPS options
46 */
47 const HTTPS_OPTIONS: BindingKey<https.ServerOptions<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>>;
48 /**
49 * Binding key for the server itself
50 */
51 const SERVER: BindingKey<RestServer>;
52 /**
53 * Internal binding key for basePath
54 */
55 const BASE_PATH: BindingKey<string>;
56 /**
57 * Internal binding key for http-handler
58 */
59 const HANDLER: BindingKey<HttpHandler>;
60 /**
61 * Internal binding key for rest router
62 */
63 const ROUTER: BindingKey<RestRouter>;
64 const ROUTER_OPTIONS: BindingKey<RestRouterOptions>;
65 /**
66 * Binding key for setting and injecting Reject action's error handling
67 * options.
68 *
69 * See https://github.com/loopbackio/strong-error-handler#options for
70 * the list of available options. Please note that the flag `log` is not used
71 * by `@loopback/rest`.
72 */
73 const ERROR_WRITER_OPTIONS: BindingKey<ErrorWriterOptions>;
74 /**
75 * Binding key for request body parser options
76 */
77 const REQUEST_BODY_PARSER_OPTIONS: BindingKey<RequestBodyParserOptions>;
78 /**
79 * Binding key for request body parser
80 */
81 const REQUEST_BODY_PARSER: BindingKey<RequestBodyParser>;
82 /**
83 * Binding key for request json body parser
84 */
85 const REQUEST_BODY_PARSER_JSON: BindingKey<BodyParser>;
86 /**
87 * Binding key for request urlencoded body parser
88 */
89 const REQUEST_BODY_PARSER_URLENCODED: BindingKey<BodyParser>;
90 /**
91 * Binding key for request text body parser
92 */
93 const REQUEST_BODY_PARSER_TEXT: BindingKey<BodyParser>;
94 /**
95 * Binding key for request raw body parser
96 */
97 const REQUEST_BODY_PARSER_RAW: BindingKey<BodyParser>;
98 /**
99 * Binding key for request raw body parser
100 */
101 const REQUEST_BODY_PARSER_STREAM: BindingKey<BodyParser>;
102 /**
103 * Binding key for AJV
104 */
105 const AJV_FACTORY: BindingKey<AjvFactory>;
106 /**
107 * Binding key for setting and injecting an OpenAPI spec
108 */
109 const API_SPEC: BindingKey<OpenApiSpec>;
110 /**
111 * Binding key for setting and injecting an OpenAPI operation spec
112 */
113 const OPERATION_SPEC_CURRENT: BindingKey<OperationObject>;
114 /**
115 * Binding key for setting and injecting a Sequence
116 */
117 const SEQUENCE: BindingKey<SequenceHandler>;
118 /**
119 * Binding key for setting and injecting a `invokeMiddleware` function for
120 * middleware based sequence
121 */
122 const INVOKE_MIDDLEWARE_SERVICE: BindingKey<InvokeMiddleware>;
123 /**
124 * Bindings for potential actions that could be used in a sequence
125 */
126 namespace SequenceActions {
127 /**
128 * Binding key for setting and injecting `invokeMiddleware` function
129 */
130 const INVOKE_MIDDLEWARE: BindingKey<InvokeMiddleware>;
131 /**
132 * Binding key for setting and injecting a route finding function
133 */
134 const FIND_ROUTE: BindingKey<FindRoute>;
135 /**
136 * Binding key for setting and injecting a parameter parsing function
137 */
138 const PARSE_PARAMS: BindingKey<ParseParams>;
139 /**
140 * Binding key for setting and injecting a controller route invoking function
141 */
142 const INVOKE_METHOD: BindingKey<InvokeMethod>;
143 /**
144 * Binding key for setting and injecting an error logging function
145 */
146 const LOG_ERROR: BindingKey<LogError>;
147 /**
148 * Binding key for setting and injecting a response writing function
149 */
150 const SEND: BindingKey<Send>;
151 /**
152 * Binding key for setting and injecting a bad response writing function
153 */
154 const REJECT: BindingKey<Reject>;
155 }
156 namespace Operation {
157 const ROUTE: BindingKey<ResolvedRoute>;
158 const PARAMS: BindingKey<OperationArgs>;
159 const RETURN_VALUE: BindingKey<any>;
160 }
161 /**
162 * Request-specific bindings
163 */
164 namespace Http {
165 /**
166 * Binding key for setting and injecting the http request
167 */
168 const REQUEST: BindingKey<Request>;
169 /**
170 * Binding key for setting and injecting the http response
171 */
172 const RESPONSE: BindingKey<Response<any, Record<string, any>>>;
173 /**
174 * Binding key for setting and injecting the http request context
175 */
176 const CONTEXT: BindingKey<Context>;
177 }
178 /**
179 * Namespace for REST routes
180 */
181 const ROUTES = "routes";
182}
183/**
184 * Binding tags for RestServer
185 */
186export declare namespace RestTags {
187 /**
188 * Binding tag to identify REST routes
189 */
190 const REST_ROUTE = "restRoute";
191 /**
192 * Binding tag for the REST route verb
193 */
194 const ROUTE_VERB = "restRouteVerb";
195 /**
196 * Binding tag for the REST route path
197 */
198 const ROUTE_PATH = "restRoutePath";
199 /**
200 * Binding tag to identify controller based REST routes
201 */
202 const CONTROLLER_ROUTE = "controllerRoute";
203 /**
204 * Binding tag for controller route bindings to represent the controller
205 * binding key
206 */
207 const CONTROLLER_BINDING = "controllerBinding";
208 const AJV_KEYWORD = "ajvKeyword";
209 const AJV_FORMAT = "ajvFormat";
210 const REST_MIDDLEWARE_CHAIN = "middlewareChain.default";
211 /**
212 * Legacy middleware chain for action-based REST sequence
213 */
214 const ACTION_MIDDLEWARE_CHAIN = "middlewareChain.rest.actions";
215}