@opra/http 1.0.0-beta.4 → 1.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/express-adapter.js +3 -10
- package/cjs/http-adapter.js +3 -0
- package/esm/express-adapter.js +3 -10
- package/esm/http-adapter.js +3 -0
- package/package.json +3 -3
- package/types/express-adapter.d.ts +1 -1
- package/types/http-adapter.d.ts +1 -0
package/cjs/express-adapter.js
CHANGED
|
@@ -19,7 +19,7 @@ class ExpressAdapter extends http_adapter_js_1.HttpAdapter {
|
|
|
19
19
|
throw new TypeError('document.api must be instance of HttpApi');
|
|
20
20
|
for (const c of this.api.controllers.values())
|
|
21
21
|
this._createControllers(c);
|
|
22
|
-
this._initRouter(
|
|
22
|
+
this._initRouter();
|
|
23
23
|
}
|
|
24
24
|
get platform() {
|
|
25
25
|
return 'express';
|
|
@@ -54,16 +54,9 @@ class ExpressAdapter extends http_adapter_js_1.HttpAdapter {
|
|
|
54
54
|
const controller = this.api.findController(controllerPath);
|
|
55
55
|
return controller && this._controllerInstances.get(controller);
|
|
56
56
|
}
|
|
57
|
-
_initRouter(
|
|
57
|
+
_initRouter() {
|
|
58
58
|
const router = (0, express_1.Router)();
|
|
59
|
-
|
|
60
|
-
if (!basePath.startsWith('/'))
|
|
61
|
-
basePath = '/' + basePath;
|
|
62
|
-
if (basePath)
|
|
63
|
-
this.app.use(basePath, router);
|
|
64
|
-
}
|
|
65
|
-
else
|
|
66
|
-
this.app.use(router);
|
|
59
|
+
this.app.use(this.basePath, router);
|
|
67
60
|
const createContext = async (_req, _res, args) => {
|
|
68
61
|
const request = http_incoming_interface_js_1.HttpIncoming.from(_req);
|
|
69
62
|
const response = http_outgoing_interface_js_1.HttpOutgoing.from(_res);
|
package/cjs/http-adapter.js
CHANGED
|
@@ -16,6 +16,9 @@ class HttpAdapter extends core_1.PlatformAdapter {
|
|
|
16
16
|
throw new TypeError(`The document does not expose an HTTP Api`);
|
|
17
17
|
this.handler = new http_handler_js_1.HttpHandler(this);
|
|
18
18
|
this.interceptors = [...(options?.interceptors || [])];
|
|
19
|
+
this.basePath = options?.basePath || '/';
|
|
20
|
+
if (!this.basePath.startsWith('/'))
|
|
21
|
+
this.basePath = '/' + this.basePath;
|
|
19
22
|
}
|
|
20
23
|
get api() {
|
|
21
24
|
return this.document.httpApi;
|
package/esm/express-adapter.js
CHANGED
|
@@ -15,7 +15,7 @@ export class ExpressAdapter extends HttpAdapter {
|
|
|
15
15
|
throw new TypeError('document.api must be instance of HttpApi');
|
|
16
16
|
for (const c of this.api.controllers.values())
|
|
17
17
|
this._createControllers(c);
|
|
18
|
-
this._initRouter(
|
|
18
|
+
this._initRouter();
|
|
19
19
|
}
|
|
20
20
|
get platform() {
|
|
21
21
|
return 'express';
|
|
@@ -50,16 +50,9 @@ export class ExpressAdapter extends HttpAdapter {
|
|
|
50
50
|
const controller = this.api.findController(controllerPath);
|
|
51
51
|
return controller && this._controllerInstances.get(controller);
|
|
52
52
|
}
|
|
53
|
-
_initRouter(
|
|
53
|
+
_initRouter() {
|
|
54
54
|
const router = Router();
|
|
55
|
-
|
|
56
|
-
if (!basePath.startsWith('/'))
|
|
57
|
-
basePath = '/' + basePath;
|
|
58
|
-
if (basePath)
|
|
59
|
-
this.app.use(basePath, router);
|
|
60
|
-
}
|
|
61
|
-
else
|
|
62
|
-
this.app.use(router);
|
|
55
|
+
this.app.use(this.basePath, router);
|
|
63
56
|
const createContext = async (_req, _res, args) => {
|
|
64
57
|
const request = HttpIncoming.from(_req);
|
|
65
58
|
const response = HttpOutgoing.from(_res);
|
package/esm/http-adapter.js
CHANGED
|
@@ -13,6 +13,9 @@ export class HttpAdapter extends PlatformAdapter {
|
|
|
13
13
|
throw new TypeError(`The document does not expose an HTTP Api`);
|
|
14
14
|
this.handler = new HttpHandler(this);
|
|
15
15
|
this.interceptors = [...(options?.interceptors || [])];
|
|
16
|
+
this.basePath = options?.basePath || '/';
|
|
17
|
+
if (!this.basePath.startsWith('/'))
|
|
18
|
+
this.basePath = '/' + this.basePath;
|
|
16
19
|
}
|
|
17
20
|
get api() {
|
|
18
21
|
return this.document.httpApi;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/http",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.5",
|
|
4
4
|
"description": "Opra Http Server Adapter",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"@browsery/antlr4": "^4.13.3-r1",
|
|
9
9
|
"@browsery/http-parser": "^0.5.9-r1",
|
|
10
10
|
"@browsery/type-is": "^1.6.18-r5",
|
|
11
|
-
"@opra/common": "^1.0.0-beta.
|
|
12
|
-
"@opra/core": "^1.0.0-beta.
|
|
11
|
+
"@opra/common": "^1.0.0-beta.5",
|
|
12
|
+
"@opra/core": "^1.0.0-beta.5",
|
|
13
13
|
"accepts": "^1.3.8",
|
|
14
14
|
"base64-stream": "^1.0.0",
|
|
15
15
|
"busboy": "^1.6.0",
|
|
@@ -8,6 +8,6 @@ export declare class ExpressAdapter extends HttpAdapter {
|
|
|
8
8
|
get platform(): string;
|
|
9
9
|
close(): Promise<void>;
|
|
10
10
|
getControllerInstance<T>(controllerPath: string): T | undefined;
|
|
11
|
-
protected _initRouter(
|
|
11
|
+
protected _initRouter(): void;
|
|
12
12
|
protected _createControllers(controller: HttpController): void;
|
|
13
13
|
}
|
package/types/http-adapter.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export declare namespace HttpAdapter {
|
|
|
26
26
|
export declare abstract class HttpAdapter extends PlatformAdapter {
|
|
27
27
|
readonly handler: HttpHandler;
|
|
28
28
|
readonly protocol: OpraSchema.Transport;
|
|
29
|
+
readonly basePath: string;
|
|
29
30
|
interceptors: (HttpAdapter.InterceptorFunction | HttpAdapter.IHttpInterceptor)[];
|
|
30
31
|
protected constructor(document: ApiDocument, options?: HttpAdapter.Options);
|
|
31
32
|
get api(): HttpApi;
|