@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.
- package/LICENSE +21 -0
- package/README.md +788 -0
- package/action/Action/Action.d.ts +41 -0
- package/action/Action/Action.es6.js +97 -0
- package/action/Action/Action.js +137 -0
- package/action/Action/index.d.ts +2 -0
- package/action/Action/index.es6.js +1 -0
- package/action/Action/index.js +11 -0
- package/action/index.d.ts +4 -0
- package/action/index.es6.js +2 -0
- package/action/index.js +13 -0
- package/action/withAction/index.d.ts +2 -0
- package/action/withAction/index.es6.js +1 -0
- package/action/withAction/index.js +7 -0
- package/action/withAction/withAction.d.ts +11 -0
- package/action/withAction/withAction.es6.js +12 -0
- package/action/withAction/withAction.js +18 -0
- package/constants.d.ts +1 -0
- package/constants.es6.js +3 -0
- package/constants.js +7 -0
- package/handler/handler.d.ts +38 -0
- package/handler/handler.es6.js +45 -0
- package/handler/handler.js +56 -0
- package/handler/index.d.ts +2 -0
- package/handler/index.es6.js +1 -0
- package/handler/index.js +12 -0
- package/index.d.ts +6 -0
- package/index.es6.js +12 -0
- package/index.js +41 -0
- package/package.json +37 -0
- package/plugins/cms/cms.d.ts +9 -0
- package/plugins/cms/cms.es6.js +25 -0
- package/plugins/cms/cms.js +34 -0
- package/plugins/cms/index.d.ts +1 -0
- package/plugins/cms/index.es6.js +1 -0
- package/plugins/cms/index.js +9 -0
- package/plugins/cookie/cookie.d.ts +14 -0
- package/plugins/cookie/cookie.es6.js +17 -0
- package/plugins/cookie/cookie.js +25 -0
- package/plugins/cookie/index.d.ts +1 -0
- package/plugins/cookie/index.es6.js +1 -0
- package/plugins/cookie/index.js +9 -0
- package/plugins/error/error.d.ts +61 -0
- package/plugins/error/error.es6.js +68 -0
- package/plugins/error/error.js +78 -0
- package/plugins/error/index.d.ts +1 -0
- package/plugins/error/index.es6.js +1 -0
- package/plugins/error/index.js +10 -0
- package/plugins/file/file.d.ts +7 -0
- package/plugins/file/file.es6.js +24 -0
- package/plugins/file/file.js +34 -0
- package/plugins/file/index.d.ts +1 -0
- package/plugins/file/index.es6.js +1 -0
- package/plugins/file/index.js +9 -0
- package/plugins/header/header.d.ts +12 -0
- package/plugins/header/header.es6.js +10 -0
- package/plugins/header/header.js +19 -0
- package/plugins/header/index.d.ts +1 -0
- package/plugins/header/index.es6.js +1 -0
- package/plugins/header/index.js +9 -0
- package/plugins/index.d.ts +8 -0
- package/plugins/index.es6.js +8 -0
- package/plugins/index.js +28 -0
- package/plugins/proxy/index.d.ts +1 -0
- package/plugins/proxy/index.es6.js +1 -0
- package/plugins/proxy/index.js +9 -0
- package/plugins/proxy/proxy.d.ts +10 -0
- package/plugins/proxy/proxy.es6.js +13 -0
- package/plugins/proxy/proxy.js +22 -0
- package/plugins/router/index.d.ts +1 -0
- package/plugins/router/index.es6.js +1 -0
- package/plugins/router/index.js +12 -0
- package/plugins/router/router.d.ts +29 -0
- package/plugins/router/router.es6.js +54 -0
- package/plugins/router/router.js +70 -0
- package/plugins/success/index.d.ts +1 -0
- package/plugins/success/index.es6.js +1 -0
- package/plugins/success/index.js +10 -0
- package/plugins/success/success.d.ts +19 -0
- package/plugins/success/success.es6.js +30 -0
- package/plugins/success/success.js +40 -0
- package/server/index.d.ts +2 -0
- package/server/index.es6.js +1 -0
- package/server/index.js +10 -0
- package/server/server.d.ts +19 -0
- package/server/server.es6.js +63 -0
- package/server/server.js +92 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { CookieSerializeOptions } from 'cookie';
|
|
3
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
4
|
+
export declare const ACTION: string;
|
|
5
|
+
export declare type Resources = 'search' | 'body' | 'cookies' | 'files';
|
|
6
|
+
export declare type Body = Record<string, any>;
|
|
7
|
+
export declare type Search = Record<string, any>;
|
|
8
|
+
export declare type Cookies = Record<string, string | string[]>;
|
|
9
|
+
export declare type Files = Record<string, File | File[]>;
|
|
10
|
+
export declare type Request = IncomingMessage;
|
|
11
|
+
export declare type Response = ServerResponse;
|
|
12
|
+
export interface ActionOptions {
|
|
13
|
+
body?: Body;
|
|
14
|
+
search?: Search;
|
|
15
|
+
cookies?: Cookies;
|
|
16
|
+
files?: Files;
|
|
17
|
+
}
|
|
18
|
+
export interface File {
|
|
19
|
+
fieldName: string;
|
|
20
|
+
headers: Record<string, string>;
|
|
21
|
+
originalFilename: string;
|
|
22
|
+
path: string;
|
|
23
|
+
size: number;
|
|
24
|
+
}
|
|
25
|
+
export declare const URL_PARSER: RegExp;
|
|
26
|
+
export default class Action<O extends ActionOptions = ActionOptions> {
|
|
27
|
+
readonly req: Request;
|
|
28
|
+
readonly res: Response;
|
|
29
|
+
constructor(req: Request, res: Response);
|
|
30
|
+
get cookies(): O['cookies'];
|
|
31
|
+
setCookie(key: string, value?: string, opt?: CookieSerializeOptions): void;
|
|
32
|
+
parseBody(): Promise<unknown>;
|
|
33
|
+
body?: O['body'];
|
|
34
|
+
files?: O['files'];
|
|
35
|
+
get search(): O['search'];
|
|
36
|
+
get parsedUrl(): {
|
|
37
|
+
search?: string;
|
|
38
|
+
path?: string;
|
|
39
|
+
};
|
|
40
|
+
get path(): string;
|
|
41
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { __decorate } from 'tslib';
|
|
2
|
+
import { once } from '@cantinc/utils';
|
|
3
|
+
import cookie from 'cookie';
|
|
4
|
+
import multiparty from 'multiparty';
|
|
5
|
+
|
|
6
|
+
const ACTION = Symbol('Action');
|
|
7
|
+
const URL_PARSER = /^(?<path>[^?]+)(\?(?<search>.*))?/;
|
|
8
|
+
class Action {
|
|
9
|
+
constructor(req, res) {
|
|
10
|
+
this.req = req;
|
|
11
|
+
this.res = res;
|
|
12
|
+
}
|
|
13
|
+
get cookies() {
|
|
14
|
+
return cookie.parse(this.req.headers.cookie || '');
|
|
15
|
+
}
|
|
16
|
+
setCookie(key, value, opt) {
|
|
17
|
+
let cookies = this.res.getHeader('Set-Cookie');
|
|
18
|
+
if (typeof cookies === 'string') {
|
|
19
|
+
cookies = [cookies];
|
|
20
|
+
}
|
|
21
|
+
const normValue = typeof value === 'string' ? cookie.serialize(key, value, opt) : `${key}=; max-age=0`;
|
|
22
|
+
if (cookies) {
|
|
23
|
+
cookies.push(normValue);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
cookies = normValue;
|
|
27
|
+
}
|
|
28
|
+
this.res.setHeader('Set-Cookie', cookies);
|
|
29
|
+
}
|
|
30
|
+
parseBody() {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
new multiparty.Form().parse(this.req, (err, fields, files) => {
|
|
33
|
+
if (err) {
|
|
34
|
+
reject(err);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
for (const key in fields) {
|
|
38
|
+
if (fields[key].length === 1) {
|
|
39
|
+
fields[key] = fields[key][0];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
for (const key in files) {
|
|
43
|
+
if (files[key].length === 1) {
|
|
44
|
+
files[key] = files[key][0];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
this.body = fields;
|
|
48
|
+
this.files = files;
|
|
49
|
+
resolve(fields);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
get search() {
|
|
55
|
+
const result = Object.create(null);
|
|
56
|
+
const search = this.parsedUrl.search || '';
|
|
57
|
+
for (const option of search.split('&')) {
|
|
58
|
+
const [key, ...value] = option.split('=');
|
|
59
|
+
if (key) {
|
|
60
|
+
const normValue = value.join('=');
|
|
61
|
+
if (key in result) {
|
|
62
|
+
if (Array.isArray(result[key])) {
|
|
63
|
+
result[key].push(normValue);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
result[key] = [result[key], normValue];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
result[key] = normValue;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
get parsedUrl() {
|
|
77
|
+
const match = this.req.url.match(URL_PARSER);
|
|
78
|
+
return match.groups;
|
|
79
|
+
}
|
|
80
|
+
get path() {
|
|
81
|
+
return this.parsedUrl.path;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
__decorate([
|
|
85
|
+
once
|
|
86
|
+
], Action.prototype, "cookies", null);
|
|
87
|
+
__decorate([
|
|
88
|
+
once
|
|
89
|
+
], Action.prototype, "parseBody", null);
|
|
90
|
+
__decorate([
|
|
91
|
+
once
|
|
92
|
+
], Action.prototype, "search", null);
|
|
93
|
+
__decorate([
|
|
94
|
+
once
|
|
95
|
+
], Action.prototype, "parsedUrl", null);
|
|
96
|
+
|
|
97
|
+
export { ACTION, URL_PARSER, Action as default };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var utils = require('@cantinc/utils');
|
|
7
|
+
var cookie = require('cookie');
|
|
8
|
+
var multiparty = require('multiparty');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var cookie__default = /*#__PURE__*/_interopDefaultLegacy(cookie);
|
|
13
|
+
var multiparty__default = /*#__PURE__*/_interopDefaultLegacy(multiparty);
|
|
14
|
+
|
|
15
|
+
var ACTION = Symbol('Action');
|
|
16
|
+
var URL_PARSER = /^(?<path>[^?]+)(\?(?<search>.*))?/;
|
|
17
|
+
var Action = /** @class */ (function () {
|
|
18
|
+
function Action(req, res) {
|
|
19
|
+
this.req = req;
|
|
20
|
+
this.res = res;
|
|
21
|
+
}
|
|
22
|
+
Object.defineProperty(Action.prototype, "cookies", {
|
|
23
|
+
get: function () {
|
|
24
|
+
return cookie__default["default"].parse(this.req.headers.cookie || '');
|
|
25
|
+
},
|
|
26
|
+
enumerable: false,
|
|
27
|
+
configurable: true
|
|
28
|
+
});
|
|
29
|
+
Action.prototype.setCookie = function (key, value, opt) {
|
|
30
|
+
var cookies = this.res.getHeader('Set-Cookie');
|
|
31
|
+
if (typeof cookies === 'string') {
|
|
32
|
+
cookies = [cookies];
|
|
33
|
+
}
|
|
34
|
+
var normValue = typeof value === 'string' ? cookie__default["default"].serialize(key, value, opt) : "".concat(key, "=; max-age=0");
|
|
35
|
+
if (cookies) {
|
|
36
|
+
cookies.push(normValue);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
cookies = normValue;
|
|
40
|
+
}
|
|
41
|
+
this.res.setHeader('Set-Cookie', cookies);
|
|
42
|
+
};
|
|
43
|
+
Action.prototype.parseBody = function () {
|
|
44
|
+
var _this = this;
|
|
45
|
+
return new Promise(function (resolve, reject) {
|
|
46
|
+
new multiparty__default["default"].Form().parse(_this.req, function (err, fields, files) {
|
|
47
|
+
if (err) {
|
|
48
|
+
reject(err);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
for (var key in fields) {
|
|
52
|
+
if (fields[key].length === 1) {
|
|
53
|
+
fields[key] = fields[key][0];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
for (var key in files) {
|
|
57
|
+
if (files[key].length === 1) {
|
|
58
|
+
files[key] = files[key][0];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
_this.body = fields;
|
|
62
|
+
_this.files = files;
|
|
63
|
+
resolve(fields);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
Object.defineProperty(Action.prototype, "search", {
|
|
69
|
+
get: function () {
|
|
70
|
+
var e_1, _a;
|
|
71
|
+
var result = Object.create(null);
|
|
72
|
+
var search = this.parsedUrl.search || '';
|
|
73
|
+
try {
|
|
74
|
+
for (var _b = tslib.__values(search.split('&')), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
75
|
+
var option = _c.value;
|
|
76
|
+
var _d = tslib.__read(option.split('=')), key = _d[0], value = _d.slice(1);
|
|
77
|
+
if (key) {
|
|
78
|
+
var normValue = value.join('=');
|
|
79
|
+
if (key in result) {
|
|
80
|
+
if (Array.isArray(result[key])) {
|
|
81
|
+
result[key].push(normValue);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
result[key] = [result[key], normValue];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
result[key] = normValue;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
94
|
+
finally {
|
|
95
|
+
try {
|
|
96
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
97
|
+
}
|
|
98
|
+
finally { if (e_1) throw e_1.error; }
|
|
99
|
+
}
|
|
100
|
+
return result;
|
|
101
|
+
},
|
|
102
|
+
enumerable: false,
|
|
103
|
+
configurable: true
|
|
104
|
+
});
|
|
105
|
+
Object.defineProperty(Action.prototype, "parsedUrl", {
|
|
106
|
+
get: function () {
|
|
107
|
+
var match = this.req.url.match(URL_PARSER);
|
|
108
|
+
return match.groups;
|
|
109
|
+
},
|
|
110
|
+
enumerable: false,
|
|
111
|
+
configurable: true
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(Action.prototype, "path", {
|
|
114
|
+
get: function () {
|
|
115
|
+
return this.parsedUrl.path;
|
|
116
|
+
},
|
|
117
|
+
enumerable: false,
|
|
118
|
+
configurable: true
|
|
119
|
+
});
|
|
120
|
+
tslib.__decorate([
|
|
121
|
+
utils.once
|
|
122
|
+
], Action.prototype, "cookies", null);
|
|
123
|
+
tslib.__decorate([
|
|
124
|
+
utils.once
|
|
125
|
+
], Action.prototype, "parseBody", null);
|
|
126
|
+
tslib.__decorate([
|
|
127
|
+
utils.once
|
|
128
|
+
], Action.prototype, "search", null);
|
|
129
|
+
tslib.__decorate([
|
|
130
|
+
utils.once
|
|
131
|
+
], Action.prototype, "parsedUrl", null);
|
|
132
|
+
return Action;
|
|
133
|
+
}());
|
|
134
|
+
|
|
135
|
+
exports.ACTION = ACTION;
|
|
136
|
+
exports.URL_PARSER = URL_PARSER;
|
|
137
|
+
exports["default"] = Action;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ACTION, URL_PARSER, default } from './Action.es6.js';
|
package/action/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var Action = require('./Action/Action.js');
|
|
6
|
+
var withAction = require('./withAction/withAction.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.ACTION = Action.ACTION;
|
|
11
|
+
exports.URL_PARSER = Action.URL_PARSER;
|
|
12
|
+
exports["default"] = Action["default"];
|
|
13
|
+
exports.withAction = withAction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './withAction.es6.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Children, Component, Props } from '@innet/jsx';
|
|
2
|
+
import { Handler } from 'innet';
|
|
3
|
+
import Action, { Body } from '../Action';
|
|
4
|
+
export interface ActionComponent<B extends Body> extends Component {
|
|
5
|
+
action: Action<B>;
|
|
6
|
+
}
|
|
7
|
+
export interface RequestComponentConstructor<B extends Body> {
|
|
8
|
+
new (props?: Props, children?: Children, handler?: Handler): ActionComponent<B>;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
export default function withAction<B extends Body, T extends RequestComponentConstructor<B>>(target: T): T;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ACTION } from '../Action/Action.es6.js';
|
|
2
|
+
|
|
3
|
+
function withAction(target) {
|
|
4
|
+
const originInit = target.prototype.init;
|
|
5
|
+
target.prototype.init = function init(...args) {
|
|
6
|
+
this.action = args[2][ACTION];
|
|
7
|
+
return originInit.apply(this, args);
|
|
8
|
+
};
|
|
9
|
+
return target;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { withAction as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Action = require('../Action/Action.js');
|
|
4
|
+
|
|
5
|
+
function withAction(target) {
|
|
6
|
+
var originInit = target.prototype.init;
|
|
7
|
+
target.prototype.init = function init() {
|
|
8
|
+
var args = [];
|
|
9
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
10
|
+
args[_i] = arguments[_i];
|
|
11
|
+
}
|
|
12
|
+
this.action = args[2][Action.ACTION];
|
|
13
|
+
return originInit.apply(this, args);
|
|
14
|
+
};
|
|
15
|
+
return target;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = withAction;
|
package/constants.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CONTINUE: unique symbol;
|
package/constants.es6.js
ADDED
package/constants.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import html from '@innet/html';
|
|
2
|
+
import { switchAsync, SwitchProps } from '@innet/switch';
|
|
3
|
+
import { arrayAsync } from '@innet/utils';
|
|
4
|
+
import { cms, CmsProps, cookie, CookieProps, error, ErrorProps, file, FileProps, header, HeaderProps, proxy, ProxyProps, router, RouterProps, success, SuccessProps } from '../plugins';
|
|
5
|
+
import { server, ServerProps } from '../server';
|
|
6
|
+
export declare const arrayPlugins: (typeof arrayAsync)[];
|
|
7
|
+
export declare const JSXPlugins: {
|
|
8
|
+
server: typeof server;
|
|
9
|
+
html: typeof html;
|
|
10
|
+
switch: typeof switchAsync;
|
|
11
|
+
router: typeof router;
|
|
12
|
+
cookie: typeof cookie;
|
|
13
|
+
header: typeof header;
|
|
14
|
+
success: typeof success;
|
|
15
|
+
error: typeof error;
|
|
16
|
+
cms: typeof cms;
|
|
17
|
+
file: typeof file;
|
|
18
|
+
proxy: typeof proxy;
|
|
19
|
+
};
|
|
20
|
+
export declare const objectPlugins: ((handler: any) => import("innet").PluginHandler)[];
|
|
21
|
+
declare const _default: import("innet").Handler;
|
|
22
|
+
export default _default;
|
|
23
|
+
declare global {
|
|
24
|
+
namespace JSX {
|
|
25
|
+
interface IntrinsicElements {
|
|
26
|
+
server: ServerProps;
|
|
27
|
+
router: RouterProps;
|
|
28
|
+
cookie: CookieProps;
|
|
29
|
+
success: SuccessProps;
|
|
30
|
+
error: ErrorProps;
|
|
31
|
+
header: HeaderProps;
|
|
32
|
+
cms: CmsProps;
|
|
33
|
+
file: FileProps;
|
|
34
|
+
switch: SwitchProps;
|
|
35
|
+
proxy: ProxyProps;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import html from '@innet/html';
|
|
2
|
+
import { jsxPlugins, jsxComponent, jsxTemplate } from '@innet/jsx';
|
|
3
|
+
import { switchAsync } from '@innet/switch';
|
|
4
|
+
import { async, array, object, arrayAsync, arrayClear, arraySingleLess } from '@innet/utils';
|
|
5
|
+
import { createHandler } from 'innet';
|
|
6
|
+
import { cookie } from '../plugins/cookie/cookie.es6.js';
|
|
7
|
+
import { header } from '../plugins/header/header.es6.js';
|
|
8
|
+
import { router } from '../plugins/router/router.es6.js';
|
|
9
|
+
import { success } from '../plugins/success/success.es6.js';
|
|
10
|
+
import { error } from '../plugins/error/error.es6.js';
|
|
11
|
+
import { cms } from '../plugins/cms/cms.es6.js';
|
|
12
|
+
import { file } from '../plugins/file/file.es6.js';
|
|
13
|
+
import { proxy } from '../plugins/proxy/proxy.es6.js';
|
|
14
|
+
import { server } from '../server/server.es6.js';
|
|
15
|
+
|
|
16
|
+
const arrayPlugins = [
|
|
17
|
+
arrayAsync,
|
|
18
|
+
arrayClear,
|
|
19
|
+
arraySingleLess,
|
|
20
|
+
];
|
|
21
|
+
const JSXPlugins = {
|
|
22
|
+
server,
|
|
23
|
+
html,
|
|
24
|
+
switch: switchAsync,
|
|
25
|
+
router,
|
|
26
|
+
cookie,
|
|
27
|
+
header,
|
|
28
|
+
success,
|
|
29
|
+
error,
|
|
30
|
+
cms,
|
|
31
|
+
file,
|
|
32
|
+
proxy,
|
|
33
|
+
};
|
|
34
|
+
const objectPlugins = [
|
|
35
|
+
jsxPlugins(JSXPlugins),
|
|
36
|
+
jsxComponent,
|
|
37
|
+
jsxTemplate,
|
|
38
|
+
];
|
|
39
|
+
var handler = createHandler([
|
|
40
|
+
async,
|
|
41
|
+
array(arrayPlugins),
|
|
42
|
+
object(objectPlugins),
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
export { JSXPlugins, arrayPlugins, handler as default, objectPlugins };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var html = require('@innet/html');
|
|
6
|
+
var jsx = require('@innet/jsx');
|
|
7
|
+
var _switch = require('@innet/switch');
|
|
8
|
+
var utils = require('@innet/utils');
|
|
9
|
+
var innet = require('innet');
|
|
10
|
+
var cookie = require('../plugins/cookie/cookie.js');
|
|
11
|
+
var header = require('../plugins/header/header.js');
|
|
12
|
+
var router = require('../plugins/router/router.js');
|
|
13
|
+
var success = require('../plugins/success/success.js');
|
|
14
|
+
var error = require('../plugins/error/error.js');
|
|
15
|
+
var cms = require('../plugins/cms/cms.js');
|
|
16
|
+
var file = require('../plugins/file/file.js');
|
|
17
|
+
var proxy = require('../plugins/proxy/proxy.js');
|
|
18
|
+
var server = require('../server/server.js');
|
|
19
|
+
|
|
20
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
|
+
|
|
22
|
+
var html__default = /*#__PURE__*/_interopDefaultLegacy(html);
|
|
23
|
+
|
|
24
|
+
var arrayPlugins = [
|
|
25
|
+
utils.arrayAsync,
|
|
26
|
+
utils.arrayClear,
|
|
27
|
+
utils.arraySingleLess,
|
|
28
|
+
];
|
|
29
|
+
var JSXPlugins = {
|
|
30
|
+
server: server.server,
|
|
31
|
+
html: html__default["default"],
|
|
32
|
+
switch: _switch.switchAsync,
|
|
33
|
+
router: router.router,
|
|
34
|
+
cookie: cookie.cookie,
|
|
35
|
+
header: header.header,
|
|
36
|
+
success: success.success,
|
|
37
|
+
error: error.error,
|
|
38
|
+
cms: cms.cms,
|
|
39
|
+
file: file.file,
|
|
40
|
+
proxy: proxy.proxy,
|
|
41
|
+
};
|
|
42
|
+
var objectPlugins = [
|
|
43
|
+
jsx.jsxPlugins(JSXPlugins),
|
|
44
|
+
jsx.jsxComponent,
|
|
45
|
+
jsx.jsxTemplate,
|
|
46
|
+
];
|
|
47
|
+
var handler = innet.createHandler([
|
|
48
|
+
utils.async,
|
|
49
|
+
utils.array(arrayPlugins),
|
|
50
|
+
utils.object(objectPlugins),
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
exports.JSXPlugins = JSXPlugins;
|
|
54
|
+
exports.arrayPlugins = arrayPlugins;
|
|
55
|
+
exports["default"] = handler;
|
|
56
|
+
exports.objectPlugins = objectPlugins;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { JSXPlugins, arrayPlugins, default, objectPlugins } from './handler.es6.js';
|
package/handler/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var handler = require('./handler.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.JSXPlugins = handler.JSXPlugins;
|
|
10
|
+
exports.arrayPlugins = handler.arrayPlugins;
|
|
11
|
+
exports["default"] = handler["default"];
|
|
12
|
+
exports.objectPlugins = handler.objectPlugins;
|
package/index.d.ts
ADDED
package/index.es6.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { JSXPlugins, arrayPlugins, default, objectPlugins } from './handler/handler.es6.js';
|
|
2
|
+
export { server } from './server/server.es6.js';
|
|
3
|
+
export { cookie } from './plugins/cookie/cookie.es6.js';
|
|
4
|
+
export { header } from './plugins/header/header.es6.js';
|
|
5
|
+
export { ROUTER, getMatchReg, router, withRouter } from './plugins/router/router.es6.js';
|
|
6
|
+
export { success, successStatuses } from './plugins/success/success.es6.js';
|
|
7
|
+
export { error, errorStatuses } from './plugins/error/error.es6.js';
|
|
8
|
+
export { cms } from './plugins/cms/cms.es6.js';
|
|
9
|
+
export { file } from './plugins/file/file.es6.js';
|
|
10
|
+
export { proxy } from './plugins/proxy/proxy.es6.js';
|
|
11
|
+
export { ACTION, default as Action, URL_PARSER } from './action/Action/Action.es6.js';
|
|
12
|
+
export { default as withAction } from './action/withAction/withAction.es6.js';
|
package/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var handler = require('./handler/handler.js');
|
|
6
|
+
var server = require('./server/server.js');
|
|
7
|
+
var cookie = require('./plugins/cookie/cookie.js');
|
|
8
|
+
var header = require('./plugins/header/header.js');
|
|
9
|
+
var router = require('./plugins/router/router.js');
|
|
10
|
+
var success = require('./plugins/success/success.js');
|
|
11
|
+
var error = require('./plugins/error/error.js');
|
|
12
|
+
var cms = require('./plugins/cms/cms.js');
|
|
13
|
+
var file = require('./plugins/file/file.js');
|
|
14
|
+
var proxy = require('./plugins/proxy/proxy.js');
|
|
15
|
+
var Action = require('./action/Action/Action.js');
|
|
16
|
+
var withAction = require('./action/withAction/withAction.js');
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
exports.JSXPlugins = handler.JSXPlugins;
|
|
21
|
+
exports.arrayPlugins = handler.arrayPlugins;
|
|
22
|
+
exports["default"] = handler["default"];
|
|
23
|
+
exports.objectPlugins = handler.objectPlugins;
|
|
24
|
+
exports.server = server.server;
|
|
25
|
+
exports.cookie = cookie.cookie;
|
|
26
|
+
exports.header = header.header;
|
|
27
|
+
exports.ROUTER = router.ROUTER;
|
|
28
|
+
exports.getMatchReg = router.getMatchReg;
|
|
29
|
+
exports.router = router.router;
|
|
30
|
+
exports.withRouter = router.withRouter;
|
|
31
|
+
exports.success = success.success;
|
|
32
|
+
exports.successStatuses = success.successStatuses;
|
|
33
|
+
exports.error = error.error;
|
|
34
|
+
exports.errorStatuses = error.errorStatuses;
|
|
35
|
+
exports.cms = cms.cms;
|
|
36
|
+
exports.file = file.file;
|
|
37
|
+
exports.proxy = proxy.proxy;
|
|
38
|
+
exports.ACTION = Action.ACTION;
|
|
39
|
+
exports.Action = Action["default"];
|
|
40
|
+
exports.URL_PARSER = Action.URL_PARSER;
|
|
41
|
+
exports.withAction = withAction;
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@innet/server",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Create server-side application with innet",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"module": "index.es6.js",
|
|
7
|
+
"jsnext:main": "index.es6.js",
|
|
8
|
+
"types": "index.d.ts",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/d8corp/innet-server.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"innet",
|
|
15
|
+
"server",
|
|
16
|
+
"front-end"
|
|
17
|
+
],
|
|
18
|
+
"author": "Mikhail Lysikov <d8corp@mail.ru>",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/d8corp/innet-server/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/d8corp/innet-server",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@cantinc/utils": "^1.0.0",
|
|
26
|
+
"@innet/html": "^1.0.0",
|
|
27
|
+
"@innet/switch": "^1.0.0",
|
|
28
|
+
"@innet/utils": "^1.0.0",
|
|
29
|
+
"cookie": "^0.4.2",
|
|
30
|
+
"http-proxy": "^1.18.1",
|
|
31
|
+
"innet": "^1.0.0",
|
|
32
|
+
"is-invalid-path": "^1.0.2",
|
|
33
|
+
"mime": "^3.0.0",
|
|
34
|
+
"multiparty": "^4.2.3",
|
|
35
|
+
"tslib": "^2.3.1"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Props } from '@innet/jsx';
|
|
2
|
+
export interface CmsProps extends Props {
|
|
3
|
+
dir?: string;
|
|
4
|
+
prefix?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface CmsJsxElement {
|
|
7
|
+
props: CmsProps;
|
|
8
|
+
}
|
|
9
|
+
export declare function cms({ props }: CmsJsxElement, handler: any): Promise<unknown>;
|