@innet/server 1.0.0

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.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +788 -0
  3. package/action/Action/Action.d.ts +41 -0
  4. package/action/Action/Action.es6.js +97 -0
  5. package/action/Action/Action.js +137 -0
  6. package/action/Action/index.d.ts +2 -0
  7. package/action/Action/index.es6.js +1 -0
  8. package/action/Action/index.js +11 -0
  9. package/action/index.d.ts +4 -0
  10. package/action/index.es6.js +2 -0
  11. package/action/index.js +13 -0
  12. package/action/withAction/index.d.ts +2 -0
  13. package/action/withAction/index.es6.js +1 -0
  14. package/action/withAction/index.js +7 -0
  15. package/action/withAction/withAction.d.ts +11 -0
  16. package/action/withAction/withAction.es6.js +12 -0
  17. package/action/withAction/withAction.js +18 -0
  18. package/constants.d.ts +1 -0
  19. package/constants.es6.js +3 -0
  20. package/constants.js +7 -0
  21. package/handler/handler.d.ts +38 -0
  22. package/handler/handler.es6.js +45 -0
  23. package/handler/handler.js +56 -0
  24. package/handler/index.d.ts +2 -0
  25. package/handler/index.es6.js +1 -0
  26. package/handler/index.js +12 -0
  27. package/index.d.ts +6 -0
  28. package/index.es6.js +12 -0
  29. package/index.js +41 -0
  30. package/package.json +37 -0
  31. package/plugins/cms/cms.d.ts +9 -0
  32. package/plugins/cms/cms.es6.js +25 -0
  33. package/plugins/cms/cms.js +34 -0
  34. package/plugins/cms/index.d.ts +1 -0
  35. package/plugins/cms/index.es6.js +1 -0
  36. package/plugins/cms/index.js +9 -0
  37. package/plugins/cookie/cookie.d.ts +14 -0
  38. package/plugins/cookie/cookie.es6.js +17 -0
  39. package/plugins/cookie/cookie.js +25 -0
  40. package/plugins/cookie/index.d.ts +1 -0
  41. package/plugins/cookie/index.es6.js +1 -0
  42. package/plugins/cookie/index.js +9 -0
  43. package/plugins/error/error.d.ts +61 -0
  44. package/plugins/error/error.es6.js +68 -0
  45. package/plugins/error/error.js +78 -0
  46. package/plugins/error/index.d.ts +1 -0
  47. package/plugins/error/index.es6.js +1 -0
  48. package/plugins/error/index.js +10 -0
  49. package/plugins/file/file.d.ts +7 -0
  50. package/plugins/file/file.es6.js +24 -0
  51. package/plugins/file/file.js +34 -0
  52. package/plugins/file/index.d.ts +1 -0
  53. package/plugins/file/index.es6.js +1 -0
  54. package/plugins/file/index.js +9 -0
  55. package/plugins/header/header.d.ts +12 -0
  56. package/plugins/header/header.es6.js +10 -0
  57. package/plugins/header/header.js +19 -0
  58. package/plugins/header/index.d.ts +1 -0
  59. package/plugins/header/index.es6.js +1 -0
  60. package/plugins/header/index.js +9 -0
  61. package/plugins/index.d.ts +8 -0
  62. package/plugins/index.es6.js +8 -0
  63. package/plugins/index.js +28 -0
  64. package/plugins/proxy/index.d.ts +1 -0
  65. package/plugins/proxy/index.es6.js +1 -0
  66. package/plugins/proxy/index.js +9 -0
  67. package/plugins/proxy/proxy.d.ts +10 -0
  68. package/plugins/proxy/proxy.es6.js +13 -0
  69. package/plugins/proxy/proxy.js +22 -0
  70. package/plugins/router/index.d.ts +1 -0
  71. package/plugins/router/index.es6.js +1 -0
  72. package/plugins/router/index.js +12 -0
  73. package/plugins/router/router.d.ts +29 -0
  74. package/plugins/router/router.es6.js +54 -0
  75. package/plugins/router/router.js +70 -0
  76. package/plugins/success/index.d.ts +1 -0
  77. package/plugins/success/index.es6.js +1 -0
  78. package/plugins/success/index.js +10 -0
  79. package/plugins/success/success.d.ts +19 -0
  80. package/plugins/success/success.es6.js +30 -0
  81. package/plugins/success/success.js +40 -0
  82. package/server/index.d.ts +2 -0
  83. package/server/index.es6.js +1 -0
  84. package/server/index.js +10 -0
  85. package/server/server.d.ts +19 -0
  86. package/server/server.es6.js +63 -0
  87. package/server/server.js +92 -0
@@ -0,0 +1,25 @@
1
+ import path from 'path';
2
+ import { ACTION } from '../../action/Action/Action.es6.js';
3
+ import { file } from '../file/file.es6.js';
4
+
5
+ function cms({ props }, handler) {
6
+ const action = handler[ACTION];
7
+ const { req } = action;
8
+ if (!req) {
9
+ throw Error('`cms` should be used inside `server`');
10
+ }
11
+ const { prefix, dir } = props;
12
+ let url = action.path;
13
+ if (prefix) {
14
+ if (url.startsWith(prefix)) {
15
+ url = url.slice(prefix.length);
16
+ }
17
+ else {
18
+ return;
19
+ }
20
+ }
21
+ const filePath = path.join(dir, url);
22
+ return file({ props: { path: filePath } }, handler);
23
+ }
24
+
25
+ export { cms };
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var path = require('path');
6
+ var Action = require('../../action/Action/Action.js');
7
+ var file = require('../file/file.js');
8
+
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
+
11
+ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
12
+
13
+ function cms(_a, handler) {
14
+ var props = _a.props;
15
+ var action = handler[Action.ACTION];
16
+ var req = action.req;
17
+ if (!req) {
18
+ throw Error('`cms` should be used inside `server`');
19
+ }
20
+ var prefix = props.prefix, dir = props.dir;
21
+ var url = action.path;
22
+ if (prefix) {
23
+ if (url.startsWith(prefix)) {
24
+ url = url.slice(prefix.length);
25
+ }
26
+ else {
27
+ return;
28
+ }
29
+ }
30
+ var filePath = path__default["default"].join(dir, url);
31
+ return file.file({ props: { path: filePath } }, handler);
32
+ }
33
+
34
+ exports.cms = cms;
@@ -0,0 +1 @@
1
+ export * from './cms';
@@ -0,0 +1 @@
1
+ export { cms } from './cms.es6.js';
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var cms = require('./cms.js');
6
+
7
+
8
+
9
+ exports.cms = cms.cms;
@@ -0,0 +1,14 @@
1
+ import { CookieSerializeOptions } from 'cookie';
2
+ import { Handler } from 'innet';
3
+ export interface CookieProps extends CookieSerializeOptions {
4
+ key: string;
5
+ value?: string;
6
+ }
7
+ export declare function cookie({ props: { key, value, ...opt }, children }: {
8
+ props: {
9
+ [x: string]: any;
10
+ key: any;
11
+ value: any;
12
+ };
13
+ children: any;
14
+ }, handler: Handler): any;
@@ -0,0 +1,17 @@
1
+ import { __rest } from 'tslib';
2
+ import innet from 'innet';
3
+ import { ACTION } from '../../action/Action/Action.es6.js';
4
+
5
+ function cookie(_a, handler) {
6
+ var _b = _a.props, { key, value } = _b, opt = __rest(_b, ["key", "value"]), { children } = _a;
7
+ const action = handler[ACTION];
8
+ if (value === undefined) {
9
+ action.setCookie(key, '', Object.assign({ path: '/', expires: new Date(0) }, opt));
10
+ }
11
+ else {
12
+ action.setCookie(key, value, opt);
13
+ }
14
+ return innet(children, handler);
15
+ }
16
+
17
+ export { cookie };
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var innet = require('innet');
7
+ var Action = require('../../action/Action/Action.js');
8
+
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
+
11
+ var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
12
+
13
+ function cookie(_a, handler) {
14
+ var _b = _a.props, key = _b.key, value = _b.value, opt = tslib.__rest(_b, ["key", "value"]), children = _a.children;
15
+ var action = handler[Action.ACTION];
16
+ if (value === undefined) {
17
+ action.setCookie(key, '', tslib.__assign({ path: '/', expires: new Date(0) }, opt));
18
+ }
19
+ else {
20
+ action.setCookie(key, value, opt);
21
+ }
22
+ return innet__default["default"](children, handler);
23
+ }
24
+
25
+ exports.cookie = cookie;
@@ -0,0 +1 @@
1
+ export * from './cookie';
@@ -0,0 +1 @@
1
+ export { cookie } from './cookie.es6.js';
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var cookie = require('./cookie.js');
6
+
7
+
8
+
9
+ exports.cookie = cookie.cookie;
@@ -0,0 +1,61 @@
1
+ export declare const errorStatuses: {
2
+ readonly badRequest: 400;
3
+ readonly unauthorized: 401;
4
+ readonly paymentRequired: 402;
5
+ readonly forbidden: 403;
6
+ readonly notFound: 404;
7
+ readonly methodNotAllowed: 405;
8
+ readonly notAcceptable: 406;
9
+ readonly proxyAuthenticationRequired: 407;
10
+ readonly requestTimeout: 408;
11
+ readonly conflict: 409;
12
+ readonly gone: 410;
13
+ readonly lengthRequired: 411;
14
+ readonly preconditionFailed: 412;
15
+ readonly payloadTooLarge: 413;
16
+ readonly URITooLong: 414;
17
+ readonly unsupportedMediaType: 415;
18
+ readonly rangeNotSatisfiable: 416;
19
+ readonly expectationFailed: 417;
20
+ readonly imATeapot: 418;
21
+ readonly authenticationTimeout: 419;
22
+ readonly misdirectedRequest: 421;
23
+ readonly unprocessableEntity: 422;
24
+ readonly locked: 423;
25
+ readonly failedDependency: 424;
26
+ readonly tooEarly: 425;
27
+ readonly upgradeRequired: 426;
28
+ readonly preconditionRequired: 428;
29
+ readonly tooManyRequests: 429;
30
+ readonly requestHeaderFieldsTooLarge: 431;
31
+ readonly retryWith: 449;
32
+ readonly unavailableForLegalReasons: 451;
33
+ readonly clientClosedRequest: 499;
34
+ readonly internalServerError: 500;
35
+ readonly notImplemented: 501;
36
+ readonly badGateway: 502;
37
+ readonly serviceUnavailable: 503;
38
+ readonly gatewayTimeout: 504;
39
+ readonly HTTPVersionNotSupported: 505;
40
+ readonly variantAlsoNegotiates: 506;
41
+ readonly insufficientStorage: 507;
42
+ readonly loopDetected: 508;
43
+ readonly bandwidthLimitExceeded: 509;
44
+ readonly notExtended: 510;
45
+ readonly networkAuthenticationRequired: 511;
46
+ readonly unknownError: 520;
47
+ readonly webServerIsDown: 521;
48
+ readonly connectionTimedOut: 522;
49
+ readonly originIsUnreachable: 523;
50
+ readonly aTimeoutOccurred: 524;
51
+ readonly SSLHandshakeFailed: 525;
52
+ readonly invalidSSLCertificate: 526;
53
+ };
54
+ export declare type ErrorStatuses = keyof typeof errorStatuses;
55
+ export interface ErrorProps {
56
+ status?: ErrorStatuses | number;
57
+ }
58
+ export declare function error({ props, children }: {
59
+ props: any;
60
+ children: any;
61
+ }, handler: any): any;
@@ -0,0 +1,68 @@
1
+ import innet from 'innet';
2
+ import { ACTION } from '../../action/Action/Action.es6.js';
3
+
4
+ const errorStatuses = {
5
+ badRequest: 400,
6
+ unauthorized: 401,
7
+ paymentRequired: 402,
8
+ forbidden: 403,
9
+ notFound: 404,
10
+ methodNotAllowed: 405,
11
+ notAcceptable: 406,
12
+ proxyAuthenticationRequired: 407,
13
+ requestTimeout: 408,
14
+ conflict: 409,
15
+ gone: 410,
16
+ lengthRequired: 411,
17
+ preconditionFailed: 412,
18
+ payloadTooLarge: 413,
19
+ URITooLong: 414,
20
+ unsupportedMediaType: 415,
21
+ rangeNotSatisfiable: 416,
22
+ expectationFailed: 417,
23
+ imATeapot: 418,
24
+ authenticationTimeout: 419,
25
+ misdirectedRequest: 421,
26
+ unprocessableEntity: 422,
27
+ locked: 423,
28
+ failedDependency: 424,
29
+ tooEarly: 425,
30
+ upgradeRequired: 426,
31
+ preconditionRequired: 428,
32
+ tooManyRequests: 429,
33
+ requestHeaderFieldsTooLarge: 431,
34
+ retryWith: 449,
35
+ unavailableForLegalReasons: 451,
36
+ clientClosedRequest: 499,
37
+ internalServerError: 500,
38
+ notImplemented: 501,
39
+ badGateway: 502,
40
+ serviceUnavailable: 503,
41
+ gatewayTimeout: 504,
42
+ HTTPVersionNotSupported: 505,
43
+ variantAlsoNegotiates: 506,
44
+ insufficientStorage: 507,
45
+ loopDetected: 508,
46
+ bandwidthLimitExceeded: 509,
47
+ notExtended: 510,
48
+ networkAuthenticationRequired: 511,
49
+ unknownError: 520,
50
+ webServerIsDown: 521,
51
+ connectionTimedOut: 522,
52
+ originIsUnreachable: 523,
53
+ aTimeoutOccurred: 524,
54
+ SSLHandshakeFailed: 525,
55
+ invalidSSLCertificate: 526,
56
+ };
57
+ function error({ props, children }, handler) {
58
+ const { res } = handler[ACTION];
59
+ const status = props === null || props === void 0 ? void 0 : props.status;
60
+ res.statusCode = status ? errorStatuses[status] || status : 520;
61
+ const data = innet(children, handler);
62
+ if (typeof data === 'object') {
63
+ return JSON.stringify(data);
64
+ }
65
+ return data !== null && data !== void 0 ? data : null;
66
+ }
67
+
68
+ export { error, errorStatuses };
@@ -0,0 +1,78 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var innet = require('innet');
6
+ var Action = require('../../action/Action/Action.js');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
11
+
12
+ var errorStatuses = {
13
+ badRequest: 400,
14
+ unauthorized: 401,
15
+ paymentRequired: 402,
16
+ forbidden: 403,
17
+ notFound: 404,
18
+ methodNotAllowed: 405,
19
+ notAcceptable: 406,
20
+ proxyAuthenticationRequired: 407,
21
+ requestTimeout: 408,
22
+ conflict: 409,
23
+ gone: 410,
24
+ lengthRequired: 411,
25
+ preconditionFailed: 412,
26
+ payloadTooLarge: 413,
27
+ URITooLong: 414,
28
+ unsupportedMediaType: 415,
29
+ rangeNotSatisfiable: 416,
30
+ expectationFailed: 417,
31
+ imATeapot: 418,
32
+ authenticationTimeout: 419,
33
+ misdirectedRequest: 421,
34
+ unprocessableEntity: 422,
35
+ locked: 423,
36
+ failedDependency: 424,
37
+ tooEarly: 425,
38
+ upgradeRequired: 426,
39
+ preconditionRequired: 428,
40
+ tooManyRequests: 429,
41
+ requestHeaderFieldsTooLarge: 431,
42
+ retryWith: 449,
43
+ unavailableForLegalReasons: 451,
44
+ clientClosedRequest: 499,
45
+ internalServerError: 500,
46
+ notImplemented: 501,
47
+ badGateway: 502,
48
+ serviceUnavailable: 503,
49
+ gatewayTimeout: 504,
50
+ HTTPVersionNotSupported: 505,
51
+ variantAlsoNegotiates: 506,
52
+ insufficientStorage: 507,
53
+ loopDetected: 508,
54
+ bandwidthLimitExceeded: 509,
55
+ notExtended: 510,
56
+ networkAuthenticationRequired: 511,
57
+ unknownError: 520,
58
+ webServerIsDown: 521,
59
+ connectionTimedOut: 522,
60
+ originIsUnreachable: 523,
61
+ aTimeoutOccurred: 524,
62
+ SSLHandshakeFailed: 525,
63
+ invalidSSLCertificate: 526,
64
+ };
65
+ function error(_a, handler) {
66
+ var props = _a.props, children = _a.children;
67
+ var res = handler[Action.ACTION].res;
68
+ var status = props === null || props === void 0 ? void 0 : props.status;
69
+ res.statusCode = status ? errorStatuses[status] || status : 520;
70
+ var data = innet__default["default"](children, handler);
71
+ if (typeof data === 'object') {
72
+ return JSON.stringify(data);
73
+ }
74
+ return data !== null && data !== void 0 ? data : null;
75
+ }
76
+
77
+ exports.error = error;
78
+ exports.errorStatuses = errorStatuses;
@@ -0,0 +1 @@
1
+ export * from './error';
@@ -0,0 +1 @@
1
+ export { error, errorStatuses } from './error.es6.js';
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var error = require('./error.js');
6
+
7
+
8
+
9
+ exports.error = error.error;
10
+ exports.errorStatuses = error.errorStatuses;
@@ -0,0 +1,7 @@
1
+ export interface FileProps {
2
+ path: string;
3
+ }
4
+ export declare function file({ props, children }: {
5
+ props: any;
6
+ children?: any;
7
+ }, handler: any): Promise<unknown>;
@@ -0,0 +1,24 @@
1
+ import fs from 'fs';
2
+ import mime from 'mime';
3
+ import { ACTION } from '../../action/Action/Action.es6.js';
4
+
5
+ function file({ props, children = null }, handler) {
6
+ const { res } = handler[ACTION];
7
+ const { path } = props;
8
+ if (fs.existsSync(path)) {
9
+ const stat = fs.statSync(path);
10
+ res.writeHead(200, {
11
+ 'Content-Type': mime.getType(path),
12
+ 'Content-Length': stat.size,
13
+ });
14
+ const readStream = fs.createReadStream(path);
15
+ readStream.pipe(res);
16
+ return new Promise((resolve, reject) => {
17
+ readStream.once('end', () => resolve(children));
18
+ readStream.once('error', reject);
19
+ });
20
+ }
21
+ res.statusCode = 404;
22
+ }
23
+
24
+ export { file };
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var fs = require('fs');
6
+ var mime = require('mime');
7
+ var Action = require('../../action/Action/Action.js');
8
+
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
+
11
+ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
12
+ var mime__default = /*#__PURE__*/_interopDefaultLegacy(mime);
13
+
14
+ function file(_a, handler) {
15
+ var props = _a.props, _b = _a.children, children = _b === void 0 ? null : _b;
16
+ var res = handler[Action.ACTION].res;
17
+ var path = props.path;
18
+ if (fs__default["default"].existsSync(path)) {
19
+ var stat = fs__default["default"].statSync(path);
20
+ res.writeHead(200, {
21
+ 'Content-Type': mime__default["default"].getType(path),
22
+ 'Content-Length': stat.size,
23
+ });
24
+ var readStream_1 = fs__default["default"].createReadStream(path);
25
+ readStream_1.pipe(res);
26
+ return new Promise(function (resolve, reject) {
27
+ readStream_1.once('end', function () { return resolve(children); });
28
+ readStream_1.once('error', reject);
29
+ });
30
+ }
31
+ res.statusCode = 404;
32
+ }
33
+
34
+ exports.file = file;
@@ -0,0 +1 @@
1
+ export * from './file';
@@ -0,0 +1 @@
1
+ export { file } from './file.es6.js';
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var file = require('./file.js');
6
+
7
+
8
+
9
+ exports.file = file.file;
@@ -0,0 +1,12 @@
1
+ import { Handler } from 'innet';
2
+ export interface HeaderProps {
3
+ name: string;
4
+ value: string;
5
+ }
6
+ export declare function header({ props: { name, value }, children }: {
7
+ props: {
8
+ name: any;
9
+ value: any;
10
+ };
11
+ children: any;
12
+ }, handler: Handler): any;
@@ -0,0 +1,10 @@
1
+ import innet from 'innet';
2
+ import { ACTION } from '../../action/Action/Action.es6.js';
3
+
4
+ function header({ props: { name, value }, children }, handler) {
5
+ const { res } = handler[ACTION];
6
+ res.setHeader(name, value);
7
+ return innet(children, handler);
8
+ }
9
+
10
+ export { header };
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var innet = require('innet');
6
+ var Action = require('../../action/Action/Action.js');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
11
+
12
+ function header(_a, handler) {
13
+ var _b = _a.props, name = _b.name, value = _b.value, children = _a.children;
14
+ var res = handler[Action.ACTION].res;
15
+ res.setHeader(name, value);
16
+ return innet__default["default"](children, handler);
17
+ }
18
+
19
+ exports.header = header;
@@ -0,0 +1 @@
1
+ export * from './header';
@@ -0,0 +1 @@
1
+ export { header } from './header.es6.js';
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var header = require('./header.js');
6
+
7
+
8
+
9
+ exports.header = header.header;
@@ -0,0 +1,8 @@
1
+ export * from './cookie';
2
+ export * from './header';
3
+ export * from './router';
4
+ export * from './success';
5
+ export * from './error';
6
+ export * from './cms';
7
+ export * from './file';
8
+ export * from './proxy';
@@ -0,0 +1,8 @@
1
+ export { cookie } from './cookie/cookie.es6.js';
2
+ export { header } from './header/header.es6.js';
3
+ export { ROUTER, getMatchReg, router, withRouter } from './router/router.es6.js';
4
+ export { success, successStatuses } from './success/success.es6.js';
5
+ export { error, errorStatuses } from './error/error.es6.js';
6
+ export { cms } from './cms/cms.es6.js';
7
+ export { file } from './file/file.es6.js';
8
+ export { proxy } from './proxy/proxy.es6.js';
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var cookie = require('./cookie/cookie.js');
6
+ var header = require('./header/header.js');
7
+ var router = require('./router/router.js');
8
+ var success = require('./success/success.js');
9
+ var error = require('./error/error.js');
10
+ var cms = require('./cms/cms.js');
11
+ var file = require('./file/file.js');
12
+ var proxy = require('./proxy/proxy.js');
13
+
14
+
15
+
16
+ exports.cookie = cookie.cookie;
17
+ exports.header = header.header;
18
+ exports.ROUTER = router.ROUTER;
19
+ exports.getMatchReg = router.getMatchReg;
20
+ exports.router = router.router;
21
+ exports.withRouter = router.withRouter;
22
+ exports.success = success.success;
23
+ exports.successStatuses = success.successStatuses;
24
+ exports.error = error.error;
25
+ exports.errorStatuses = error.errorStatuses;
26
+ exports.cms = cms.cms;
27
+ exports.file = file.file;
28
+ exports.proxy = proxy.proxy;
@@ -0,0 +1 @@
1
+ export * from './proxy';
@@ -0,0 +1 @@
1
+ export { proxy } from './proxy.es6.js';
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var proxy = require('./proxy.js');
6
+
7
+
8
+
9
+ exports.proxy = proxy.proxy;
@@ -0,0 +1,10 @@
1
+ import { Handler } from 'innet';
2
+ export interface ProxyProps {
3
+ to: string;
4
+ }
5
+ export declare function proxy({ props: { to, secure } }: {
6
+ props: {
7
+ to: any;
8
+ secure?: boolean;
9
+ };
10
+ }, handler: Handler): symbol;
@@ -0,0 +1,13 @@
1
+ import httpProxy from 'http-proxy';
2
+ import { ACTION } from '../../action/Action/Action.es6.js';
3
+ import { CONTINUE } from '../../constants.es6.js';
4
+
5
+ const proxyServer = httpProxy.createProxyServer({});
6
+ function proxy({ props: { to, secure = false } }, handler) {
7
+ const { req, res } = handler[ACTION];
8
+ delete req.headers.host;
9
+ proxyServer.web(req, res, { target: to, secure });
10
+ return CONTINUE;
11
+ }
12
+
13
+ export { proxy };
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var httpProxy = require('http-proxy');
6
+ var Action = require('../../action/Action/Action.js');
7
+ var constants = require('../../constants.js');
8
+
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
+
11
+ var httpProxy__default = /*#__PURE__*/_interopDefaultLegacy(httpProxy);
12
+
13
+ var proxyServer = httpProxy__default["default"].createProxyServer({});
14
+ function proxy(_a, handler) {
15
+ var _b = _a.props, to = _b.to, _c = _b.secure, secure = _c === void 0 ? false : _c;
16
+ var _d = handler[Action.ACTION], req = _d.req, res = _d.res;
17
+ delete req.headers.host;
18
+ proxyServer.web(req, res, { target: to, secure: secure });
19
+ return constants.CONTINUE;
20
+ }
21
+
22
+ exports.proxy = proxy;
@@ -0,0 +1 @@
1
+ export * from './router';
@@ -0,0 +1 @@
1
+ export { ROUTER, getMatchReg, router, withRouter } from './router.es6.js';