From 85db5b03a1fb5c2544559774b2f37f2ab108e1e4 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Thu, 17 Jan 2019 14:10:08 +0530 Subject: Seed code for loopback server Added seed project structure for loopback server. This will act as intermediate layer between UI and backend. The angular UI app will be serverd through this server. Issue-ID: CCSDK-943 Change-Id: I03259782927eda0d7e5bff989f61a36f09a3afd8 Signed-off-by: Arundathi Patil --- cds-ui/server/.npmrc | 1 + cds-ui/server/.prettierignore | 2 + cds-ui/server/.prettierrc | 6 ++ cds-ui/server/.yo-rc.json | 1 + cds-ui/server/README.md | 24 +++++ cds-ui/server/index.js | 42 +++++++++ cds-ui/server/index.ts | 22 +++++ cds-ui/server/package.json | 63 ++++++++++++++ cds-ui/server/pom.xml | 106 +++++++++++++++++++++++ cds-ui/server/public/index.html | 19 ++++ cds-ui/server/src/application.ts | 63 ++++++++++++++ cds-ui/server/src/controllers/README.md | 30 +++++++ cds-ui/server/src/controllers/index.ts | 22 +++++ cds-ui/server/src/controllers/ping.controller.ts | 72 +++++++++++++++ cds-ui/server/src/datasources/README.md | 24 +++++ cds-ui/server/src/index.ts | 37 ++++++++ cds-ui/server/src/migrate.ts | 41 +++++++++ cds-ui/server/src/models/README.md | 24 +++++ cds-ui/server/src/repositories/README.md | 24 +++++ cds-ui/server/src/sequence.ts | 56 ++++++++++++ cds-ui/server/tsconfig.json | 14 +++ cds-ui/server/tslint.build.json | 4 + cds-ui/server/tslint.json | 4 + pom.xml | 1 + 24 files changed, 702 insertions(+) create mode 100644 cds-ui/server/.npmrc create mode 100644 cds-ui/server/.prettierignore create mode 100644 cds-ui/server/.prettierrc create mode 100644 cds-ui/server/.yo-rc.json create mode 100644 cds-ui/server/README.md create mode 100644 cds-ui/server/index.js create mode 100644 cds-ui/server/index.ts create mode 100644 cds-ui/server/package.json create mode 100644 cds-ui/server/pom.xml create mode 100644 cds-ui/server/public/index.html create mode 100644 cds-ui/server/src/application.ts create mode 100644 cds-ui/server/src/controllers/README.md create mode 100644 cds-ui/server/src/controllers/index.ts create mode 100644 cds-ui/server/src/controllers/ping.controller.ts create mode 100644 cds-ui/server/src/datasources/README.md create mode 100644 cds-ui/server/src/index.ts create mode 100644 cds-ui/server/src/migrate.ts create mode 100644 cds-ui/server/src/models/README.md create mode 100644 cds-ui/server/src/repositories/README.md create mode 100644 cds-ui/server/src/sequence.ts create mode 100644 cds-ui/server/tsconfig.json create mode 100644 cds-ui/server/tslint.build.json create mode 100644 cds-ui/server/tslint.json diff --git a/cds-ui/server/.npmrc b/cds-ui/server/.npmrc new file mode 100644 index 000000000..43c97e719 --- /dev/null +++ b/cds-ui/server/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/cds-ui/server/.prettierignore b/cds-ui/server/.prettierignore new file mode 100644 index 000000000..c6911da9e --- /dev/null +++ b/cds-ui/server/.prettierignore @@ -0,0 +1,2 @@ +dist +*.json diff --git a/cds-ui/server/.prettierrc b/cds-ui/server/.prettierrc new file mode 100644 index 000000000..f58b81dd7 --- /dev/null +++ b/cds-ui/server/.prettierrc @@ -0,0 +1,6 @@ +{ + "bracketSpacing": false, + "singleQuote": true, + "printWidth": 80, + "trailingComma": "all" +} diff --git a/cds-ui/server/.yo-rc.json b/cds-ui/server/.yo-rc.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/cds-ui/server/.yo-rc.json @@ -0,0 +1 @@ +{} diff --git a/cds-ui/server/README.md b/cds-ui/server/README.md new file mode 100644 index 000000000..5591df002 --- /dev/null +++ b/cds-ui/server/README.md @@ -0,0 +1,24 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved. +=================================================================== + +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the License); +you may not use this software except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +============LICENSE_END============================================ +*/ + +# cds-ui-server + +[![LoopBack](https://github.com/strongloop/loopback-next/raw/master/docs/site/imgs/branding/Powered-by-LoopBack-Badge-(blue)-@2x.png)](http://loopback.io/) diff --git a/cds-ui/server/index.js b/cds-ui/server/index.js new file mode 100644 index 000000000..b79f7d6d3 --- /dev/null +++ b/cds-ui/server/index.js @@ -0,0 +1,42 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved. +=================================================================== + +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the License); +you may not use this software except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +============LICENSE_END============================================ +*/ + +const application = require('./dist'); + +module.exports = application; + +if (require.main === module) { + // Run the application + const config = { + rest: { + port: +process.env.PORT || 3000, + host: process.env.HOST || 'localhost', + openApiSpec: { + // useful when used with OASGraph to locate your application + setServersFromRequest: true, + }, + }, + }; + application.main(config).catch(err => { + console.error('Cannot start the application.', err); + process.exit(1); + }); +} diff --git a/cds-ui/server/index.ts b/cds-ui/server/index.ts new file mode 100644 index 000000000..8717b8dcf --- /dev/null +++ b/cds-ui/server/index.ts @@ -0,0 +1,22 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved. +=================================================================== + +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the License); +you may not use this software except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +============LICENSE_END============================================ +*/ + +export * from './src'; diff --git a/cds-ui/server/package.json b/cds-ui/server/package.json new file mode 100644 index 000000000..96639391f --- /dev/null +++ b/cds-ui/server/package.json @@ -0,0 +1,63 @@ +{ + "name": "cds-ui-server", + "version": "1.0.0", + "description": "Intermediate layer between UI and backend. Implemented in loopback 4", + "keywords": [ + "loopback-application", + "loopback" + ], + "main": "index.js", + "engines": { + "node": ">=8.9" + }, + "scripts": { + "build:apidocs": "lb-apidocs", + "build": "lb-tsc es2017 --outDir dist", + "build:watch": "lb-tsc --watch", + "clean": "lb-clean dist", + "lint": "npm run prettier:check && npm run tslint", + "lint:fix": "npm run tslint:fix && npm run prettier:fix", + "prettier:cli": "lb-prettier \"**/*.ts\" \"**/*.js\"", + "prettier:check": "npm run prettier:cli -- -l", + "prettier:fix": "npm run prettier:cli -- --write", + "tslint": "lb-tslint", + "tslint:fix": "npm run tslint -- --fix", + "pretest": "npm run clean && npm run build", + "test": "lb-mocha --allow-console-logs \"dist/test\"", + "posttest": "npm run lint", + "test:dev": "lb-mocha --allow-console-logs dist/test/**/*.js && npm run posttest", + "migrate": "node ./dist/src/migrate", + "prestart": "npm run build", + "start": "node .", + "prepublishOnly": "npm run test" + }, + "repository": { + "type": "git" + }, + "author": "", + "license": "", + "files": [ + "README.md", + "index.js", + "index.d.ts", + "dist/src", + "dist/index*", + "src" + ], + "dependencies": { + "@loopback/boot": "^1.0.8", + "@loopback/context": "^1.4.0", + "@loopback/core": "^1.1.3", + "@loopback/openapi-v3": "^1.1.5", + "@loopback/repository": "^1.1.1", + "@loopback/rest": "^1.5.1", + "@loopback/rest-explorer": "^1.1.4", + "@loopback/service-proxy": "^1.0.5" + }, + "devDependencies": { + "@loopback/build": "^1.1.0", + "@loopback/testlab": "^1.0.3", + "@loopback/tslint-config": "^1.0.0", + "@types/node": "^10.11.2" + } +} diff --git a/cds-ui/server/pom.xml b/cds-ui/server/pom.xml new file mode 100644 index 000000000..8b9c4218b --- /dev/null +++ b/cds-ui/server/pom.xml @@ -0,0 +1,106 @@ + + + + 4.0.0 + org.onap.ccsdk.cds.server + controller-design-studio-server + 1.0.0 + pom + + cds-ui-server + + + UTF-8 + npm + https://nexus.onap.org + + + + + + + + ecomp-releases + openecomp-repository-releases + ${onap.nexus.url}/content/repositories/releases + + + ecomp-snapshots + openecomp-repository-snapshots + ${onap.nexus.url}/content/repositories/snapshots + + + + + + + + com.github.eirslett + frontend-maven-plugin + + 1.3 + + v8.12.0 + https://nodejs.org/dist/ + https://nodejs.org/dist/npm/ + ./ + + + + install node and npm + + install-node-and-npm + + generate-resources + + + + npm install + + npm + + + generate-resources + + + install + + + + + npm build + + npm + + + generate-resources + + + run build + + + + + + + + diff --git a/cds-ui/server/public/index.html b/cds-ui/server/public/index.html new file mode 100644 index 000000000..81e972890 --- /dev/null +++ b/cds-ui/server/public/index.html @@ -0,0 +1,19 @@ + diff --git a/cds-ui/server/src/application.ts b/cds-ui/server/src/application.ts new file mode 100644 index 000000000..463f330b8 --- /dev/null +++ b/cds-ui/server/src/application.ts @@ -0,0 +1,63 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved. +=================================================================== + +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the License); +you may not use this software except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +============LICENSE_END============================================ +*/ + +import { BootMixin } from '@loopback/boot'; +import { ApplicationConfig } from '@loopback/core'; +import { + RestExplorerBindings, + RestExplorerComponent, +} from '@loopback/rest-explorer'; +import { RepositoryMixin } from '@loopback/repository'; +import { RestApplication } from '@loopback/rest'; +import { ServiceMixin } from '@loopback/service-proxy'; +import * as path from 'path'; +import { MySequence } from './sequence'; + +export class CdsUiServerApplication extends BootMixin( + ServiceMixin(RepositoryMixin(RestApplication)), +) { + constructor(options: ApplicationConfig = {}) { + super(options); + + // Set up the custom sequence + this.sequence(MySequence); + + // Set up default home page + this.static('/', path.join(__dirname, '../../public')); + + // Customize @loopback/rest-explorer configuration here + this.bind(RestExplorerBindings.CONFIG).to({ + path: '/explorer', + }); + this.component(RestExplorerComponent); + + this.projectRoot = __dirname; + // Customize @loopback/boot Booter Conventions here + this.bootOptions = { + controllers: { + // Customize ControllerBooter Conventions here + dirs: ['controllers'], + extensions: ['.controller.js'], + nested: true, + }, + }; + } +} diff --git a/cds-ui/server/src/controllers/README.md b/cds-ui/server/src/controllers/README.md new file mode 100644 index 000000000..837a462dc --- /dev/null +++ b/cds-ui/server/src/controllers/README.md @@ -0,0 +1,30 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved. +=================================================================== + +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the License); +you may not use this software except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +============LICENSE_END============================================ +*/ + +# Controllers + +This directory contains source files for the controllers exported by this app. + +To add a new empty controller, type in `lb4 controller []` from the +command-line of your application's root directory. + +For more information, please visit +[Controller generator](http://loopback.io/doc/en/lb4/Controller-generator.html). diff --git a/cds-ui/server/src/controllers/index.ts b/cds-ui/server/src/controllers/index.ts new file mode 100644 index 000000000..bf2bd6fb7 --- /dev/null +++ b/cds-ui/server/src/controllers/index.ts @@ -0,0 +1,22 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved. +=================================================================== + +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the License); +you may not use this software except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +============LICENSE_END============================================ +*/ + +export * from './ping.controller'; diff --git a/cds-ui/server/src/controllers/ping.controller.ts b/cds-ui/server/src/controllers/ping.controller.ts new file mode 100644 index 000000000..d3098bc69 --- /dev/null +++ b/cds-ui/server/src/controllers/ping.controller.ts @@ -0,0 +1,72 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved. +=================================================================== + +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the License); +you may not use this software except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +============LICENSE_END============================================ +*/ + +import { Request, RestBindings, get, ResponseObject } from '@loopback/rest'; +import { inject } from '@loopback/context'; + +/** + * OpenAPI response for ping() + */ +const PING_RESPONSE: ResponseObject = { + description: 'Ping Response', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + greeting: { type: 'string' }, + date: { type: 'string' }, + url: { type: 'string' }, + headers: { + type: 'object', + properties: { + 'Content-Type': { type: 'string' }, + }, + additionalProperties: true, + }, + }, + }, + }, + }, +}; + +/** + * A simple controller to bounce back http requests + */ +export class PingController { + constructor(@inject(RestBindings.Http.REQUEST) private req: Request) { } + + // Map to `GET /ping` + @get('/ping', { + responses: { + '200': PING_RESPONSE, + }, + }) + ping(): object { + // Reply with a greeting, the current time, the url, and request headers + return { + greeting: 'Hello from LoopBack', + date: new Date(), + url: this.req.url, + headers: Object.assign({}, this.req.headers), + }; + } +} diff --git a/cds-ui/server/src/datasources/README.md b/cds-ui/server/src/datasources/README.md new file mode 100644 index 000000000..2d4d4c3be --- /dev/null +++ b/cds-ui/server/src/datasources/README.md @@ -0,0 +1,24 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved. +=================================================================== + +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the License); +you may not use this software except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +============LICENSE_END============================================ +*/ + +# Datasources + +This directory contains config for datasources used by this app. diff --git a/cds-ui/server/src/index.ts b/cds-ui/server/src/index.ts new file mode 100644 index 000000000..04852494f --- /dev/null +++ b/cds-ui/server/src/index.ts @@ -0,0 +1,37 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved. +=================================================================== + +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the License); +you may not use this software except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +============LICENSE_END============================================ +*/ + +import { CdsUiServerApplication } from './application'; +import { ApplicationConfig } from '@loopback/core'; + +export { CdsUiServerApplication }; + +export async function main(options: ApplicationConfig = {}) { + const app = new CdsUiServerApplication(options); + await app.boot(); + await app.start(); + + const url = app.restServer.url; + console.log(`Server is running at ${url}`); + console.log(`Try ${url}/ping`); + + return app; +} diff --git a/cds-ui/server/src/migrate.ts b/cds-ui/server/src/migrate.ts new file mode 100644 index 000000000..0897b980b --- /dev/null +++ b/cds-ui/server/src/migrate.ts @@ -0,0 +1,41 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved. +=================================================================== + +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the License); +you may not use this software except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +============LICENSE_END============================================ +*/ + +import { CdsUiServerApplication } from './application'; + +export async function migrate(args: string[]) { + const existingSchema = args.includes('--rebuild') ? 'drop' : 'alter'; + console.log('Migrating schemas (%s existing schema)', existingSchema); + + const app = new CdsUiServerApplication(); + await app.boot(); + await app.migrateSchema({ existingSchema }); + + // Connectors usually keep a pool of opened connections, + // this keeps the process running even after all work is done. + // We need to exit explicitly. + process.exit(0); +} + +migrate(process.argv).catch(err => { + console.error('Cannot migrate database schema', err); + process.exit(1); +}); diff --git a/cds-ui/server/src/models/README.md b/cds-ui/server/src/models/README.md new file mode 100644 index 000000000..b4bbe4ac0 --- /dev/null +++ b/cds-ui/server/src/models/README.md @@ -0,0 +1,24 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved. +=================================================================== + +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the License); +you may not use this software except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +============LICENSE_END============================================ +*/ + +# Models + +This directory contains code for models provided by this app. diff --git a/cds-ui/server/src/repositories/README.md b/cds-ui/server/src/repositories/README.md new file mode 100644 index 000000000..dc7af9055 --- /dev/null +++ b/cds-ui/server/src/repositories/README.md @@ -0,0 +1,24 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved. +=================================================================== + +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the License); +you may not use this software except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +============LICENSE_END============================================ +*/ + +# Repositories + +This directory contains code for repositories provided by this app. diff --git a/cds-ui/server/src/sequence.ts b/cds-ui/server/src/sequence.ts new file mode 100644 index 000000000..b27093147 --- /dev/null +++ b/cds-ui/server/src/sequence.ts @@ -0,0 +1,56 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved. +=================================================================== + +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the License); +you may not use this software except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +============LICENSE_END============================================ +*/ + +import { inject } from '@loopback/context'; +import { + FindRoute, + InvokeMethod, + ParseParams, + Reject, + RequestContext, + RestBindings, + Send, + SequenceHandler, +} from '@loopback/rest'; + +const SequenceActions = RestBindings.SequenceActions; + +export class MySequence implements SequenceHandler { + constructor( + @inject(SequenceActions.FIND_ROUTE) protected findRoute: FindRoute, + @inject(SequenceActions.PARSE_PARAMS) protected parseParams: ParseParams, + @inject(SequenceActions.INVOKE_METHOD) protected invoke: InvokeMethod, + @inject(SequenceActions.SEND) public send: Send, + @inject(SequenceActions.REJECT) public reject: Reject, + ) { } + + async handle(context: RequestContext) { + try { + const { request, response } = context; + const route = this.findRoute(request); + const args = await this.parseParams(request, route); + const result = await this.invoke(route, args); + this.send(response, result); + } catch (err) { + this.reject(context, err); + } + } +} diff --git a/cds-ui/server/tsconfig.json b/cds-ui/server/tsconfig.json new file mode 100644 index 000000000..eb96bb53c --- /dev/null +++ b/cds-ui/server/tsconfig.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "include": [ + "src", + "test", + "index.ts" + ], + "exclude": [ + "node_modules/**", + "packages/*/node_modules/**", + "**/*.d.ts" + ] +} diff --git a/cds-ui/server/tslint.build.json b/cds-ui/server/tslint.build.json new file mode 100644 index 000000000..121b8adb2 --- /dev/null +++ b/cds-ui/server/tslint.build.json @@ -0,0 +1,4 @@ +{ + "$schema": "http://json.schemastore.org/tslint", + "extends": ["@loopback/tslint-config/tslint.build.json"] +} diff --git a/cds-ui/server/tslint.json b/cds-ui/server/tslint.json new file mode 100644 index 000000000..2bb931e66 --- /dev/null +++ b/cds-ui/server/tslint.json @@ -0,0 +1,4 @@ +{ + "$schema": "http://json.schemastore.org/tslint", + "extends": ["@loopback/tslint-config/tslint.common.json"] +} diff --git a/pom.xml b/pom.xml index 0e386173e..609dbbe15 100644 --- a/pom.xml +++ b/pom.xml @@ -30,6 +30,7 @@ limitations under the License. cds-ui/client + cds-ui/server -- cgit 1.2.3-korg