@celljs/express-adapter 3.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Cellbang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # Cell - Express Adapter Component
package/cell.yml ADDED
@@ -0,0 +1,2 @@
1
+ backend:
2
+ entry: lib/node/http-application-entry
@@ -0,0 +1,4 @@
1
+ export declare const DEFAULT_SERVER_OPTIONS: {
2
+ port: number;
3
+ };
4
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/node/context.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB;;CAElC,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_SERVER_OPTIONS = void 0;
4
+ exports.DEFAULT_SERVER_OPTIONS = {
5
+ port: 3000
6
+ };
7
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/node/context.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG;IAClC,IAAI,EAAE,IAAI;CACb,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=http-application-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-application-entry.d.ts","sourceRoot":"","sources":["../../src/node/http-application-entry.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const dynamic_container_1 = require("@celljs/core/lib/common/container/dynamic-container");
4
+ const application_protocol_1 = require("@celljs/core/lib/common/application/application-protocol");
5
+ const container_provider_1 = require("@celljs/core/lib/common/container/container-provider");
6
+ const dispatcher_protocol_1 = require("@celljs/web/lib/node/dispatcher/dispatcher-protocol");
7
+ const context_1 = require("@celljs/web/lib/node/context");
8
+ const http_1 = require("@celljs/web/lib/node/http");
9
+ const config_protocol_1 = require("@celljs/core/lib/common/config/config-protocol");
10
+ const express = require("express");
11
+ const context_2 = require("./context");
12
+ dynamic_container_1.container.then(async (c) => {
13
+ container_provider_1.ContainerProvider.set(c);
14
+ await c.get(application_protocol_1.Application).start();
15
+ const configProvider = c.get(config_protocol_1.ConfigProvider);
16
+ const port = parseInt(process.env.SERVER_PORT || '') || configProvider.get('cell.server', context_2.DEFAULT_SERVER_OPTIONS).port;
17
+ const app = express();
18
+ app.all('*', async (req, res) => {
19
+ const dispatcher = c.get(dispatcher_protocol_1.Dispatcher);
20
+ const httpContext = new context_1.Context(req, res);
21
+ context_1.Context.run(() => dispatcher.dispatch(httpContext));
22
+ });
23
+ const server = app.listen(port);
24
+ const items = c.getAll(http_1.ServerAware);
25
+ for (const serverAware of items) {
26
+ await serverAware.setServer(server);
27
+ }
28
+ console.log(`serve ${port}`);
29
+ });
30
+ //# sourceMappingURL=http-application-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-application-entry.js","sourceRoot":"","sources":["../../src/node/http-application-entry.ts"],"names":[],"mappings":";;AAAA,2FAAgF;AAChF,mGAAuF;AACvF,6FAAyF;AACzF,6FAAiF;AACjF,0DAAuD;AACvD,oDAAwD;AACxD,oFAAgF;AAEhF,mCAAmC;AACnC,uCAAmD;AAEnD,6BAAS,CAAC,IAAI,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;IACrB,sCAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACzB,MAAM,CAAC,CAAC,GAAG,CAAc,kCAAW,CAAC,CAAC,KAAK,EAAE,CAAC;IAC9C,MAAM,cAAc,GAAG,CAAC,CAAC,GAAG,CAAiB,gCAAc,CAAC,CAAC;IAC7D,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,IAAI,cAAc,CAAC,GAAG,CAAM,aAAa,EAAE,gCAAsB,CAAC,CAAC,IAAI,CAAC;IAC5H,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;IACtB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAQ,EAAE,GAAQ,EAAE,EAAE;QACtC,MAAM,UAAU,GAAG,CAAC,CAAC,GAAG,CAAsB,gCAAU,CAAC,CAAC;QAC1D,MAAM,WAAW,GAAG,IAAI,iBAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC1C,iBAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,CAAc,kBAAW,CAAC,CAAC;IACjD,KAAK,MAAM,WAAW,IAAI,KAAK,EAAE;QAC7B,MAAM,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;KACvC;IACD,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;AACjC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './context';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./context"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("inversify/lib/interfaces/interfaces").interfaces.ContainerModule;
2
+ export default _default;
3
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/node/module.ts"],"names":[],"mappings":";AAEA,wBAA0B"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@celljs/core");
4
+ exports.default = (0, core_1.autoBind)();
5
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/node/module.ts"],"names":[],"mappings":";;AAAA,uCAAwC;AAExC,kBAAe,IAAA,eAAQ,GAAE,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=package.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.spec.d.ts","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ describe('express adapter package', () => {
2
+ it('support code coverage statistics', () => { });
3
+ });
4
+ //# sourceMappingURL=package.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.spec.js","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":"AAAA,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IAErC,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@celljs/express-adapter",
3
+ "version": "3.0.0",
4
+ "description": "",
5
+ "main": "lib/node/index.js",
6
+ "typings": "lib/node/index.d.ts",
7
+ "dependencies": {
8
+ "@celljs/core": "3.0.0",
9
+ "@celljs/web": "3.0.0",
10
+ "express": "^4.17.1"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "keywords": [
16
+ "cell-component"
17
+ ],
18
+ "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/cellbang/cell.git"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/cellbang/cell/issues"
25
+ },
26
+ "homepage": "https://github.com/cellbang/cell",
27
+ "files": [
28
+ "lib",
29
+ "src",
30
+ "cell.yml"
31
+ ],
32
+ "scripts": {
33
+ "lint": "cell-component lint",
34
+ "build": "cell-component build",
35
+ "watch": "cell-component watch",
36
+ "clean": "cell-component clean",
37
+ "test": "cell-component test:js"
38
+ },
39
+ "devDependencies": {
40
+ "@celljs/component": "3.0.0"
41
+ },
42
+ "gitHead": "c0ef8d269e33a795406bcbb240cac4b845c6c24c"
43
+ }
@@ -0,0 +1,3 @@
1
+ export const DEFAULT_SERVER_OPTIONS = {
2
+ port: 3000
3
+ };
@@ -0,0 +1,29 @@
1
+ import { container } from '@celljs/core/lib/common/container/dynamic-container';
2
+ import { Application } from '@celljs/core/lib/common/application/application-protocol';
3
+ import { ContainerProvider } from '@celljs/core/lib/common/container/container-provider';
4
+ import { Dispatcher } from '@celljs/web/lib/node/dispatcher/dispatcher-protocol';
5
+ import { Context } from '@celljs/web/lib/node/context';
6
+ import { ServerAware } from '@celljs/web/lib/node/http';
7
+ import { ConfigProvider } from '@celljs/core/lib/common/config/config-protocol';
8
+
9
+ import * as express from 'express';
10
+ import { DEFAULT_SERVER_OPTIONS } from './context';
11
+
12
+ container.then(async c => {
13
+ ContainerProvider.set(c);
14
+ await c.get<Application>(Application).start();
15
+ const configProvider = c.get<ConfigProvider>(ConfigProvider);
16
+ const port = parseInt(process.env.SERVER_PORT || '') || configProvider.get<any>('cell.server', DEFAULT_SERVER_OPTIONS).port;
17
+ const app = express();
18
+ app.all('*', async (req: any, res: any) => {
19
+ const dispatcher = c.get<Dispatcher<Context>>(Dispatcher);
20
+ const httpContext = new Context(req, res);
21
+ Context.run(() => dispatcher.dispatch(httpContext));
22
+ });
23
+ const server = app.listen(port);
24
+ const items = c.getAll<ServerAware>(ServerAware);
25
+ for (const serverAware of items) {
26
+ await serverAware.setServer(server);
27
+ }
28
+ console.log(`serve ${port}`);
29
+ });
@@ -0,0 +1 @@
1
+ export * from './context';
@@ -0,0 +1,3 @@
1
+ import { autoBind } from '@celljs/core';
2
+
3
+ export default autoBind();
@@ -0,0 +1,4 @@
1
+ describe('express adapter package', () => {
2
+
3
+ it('support code coverage statistics', () => {});
4
+ });