aboutsummaryrefslogtreecommitdiffstats
path: root/cds-ui
diff options
context:
space:
mode:
authorArundathi Patil <arundpil@in.ibm.com>2019-01-17 14:10:08 +0530
committerArundathi Patil <arundpil@in.ibm.com>2019-01-17 08:44:04 +0000
commit85db5b03a1fb5c2544559774b2f37f2ab108e1e4 (patch)
tree75a85e6178aeb4e24092f9102cefcccb61bb736b /cds-ui
parent22ca2adc867594e1c1fe9ff0b5750869e2eda282 (diff)
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 <arundpil@in.ibm.com>
Diffstat (limited to 'cds-ui')
-rw-r--r--cds-ui/server/.npmrc1
-rw-r--r--cds-ui/server/.prettierignore2
-rw-r--r--cds-ui/server/.prettierrc6
-rw-r--r--cds-ui/server/.yo-rc.json1
-rw-r--r--cds-ui/server/README.md24
-rw-r--r--cds-ui/server/index.js42
-rw-r--r--cds-ui/server/index.ts22
-rw-r--r--cds-ui/server/package.json63
-rw-r--r--cds-ui/server/pom.xml106
-rw-r--r--cds-ui/server/public/index.html19
-rw-r--r--cds-ui/server/src/application.ts63
-rw-r--r--cds-ui/server/src/controllers/README.md30
-rw-r--r--cds-ui/server/src/controllers/index.ts22
-rw-r--r--cds-ui/server/src/controllers/ping.controller.ts72
-rw-r--r--cds-ui/server/src/datasources/README.md24
-rw-r--r--cds-ui/server/src/index.ts37
-rw-r--r--cds-ui/server/src/migrate.ts41
-rw-r--r--cds-ui/server/src/models/README.md24
-rw-r--r--cds-ui/server/src/repositories/README.md24
-rw-r--r--cds-ui/server/src/sequence.ts56
-rw-r--r--cds-ui/server/tsconfig.json14
-rw-r--r--cds-ui/server/tslint.build.json4
-rw-r--r--cds-ui/server/tslint.json4
23 files changed, 701 insertions, 0 deletions
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 @@
+<!--
+============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============================================ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.onap.ccsdk.cds.server</groupId>
+ <artifactId>controller-design-studio-server</artifactId>
+ <version>1.0.0</version>
+ <packaging>pom</packaging>
+
+ <name>cds-ui-server</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <npm.executable>npm</npm.executable>
+ <onap.nexus.url>https://nexus.onap.org</onap.nexus.url>
+ </properties>
+
+ <!-- ================================================================================== -->
+ <!-- Distribution Management Sites -->
+ <!-- ================================================================================== -->
+ <distributionManagement>
+ <repository>
+ <id>ecomp-releases</id>
+ <name>openecomp-repository-releases</name>
+ <url>${onap.nexus.url}/content/repositories/releases</url>
+ </repository>
+ <snapshotRepository>
+ <id>ecomp-snapshots</id>
+ <name>openecomp-repository-snapshots</name>
+ <url>${onap.nexus.url}/content/repositories/snapshots</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.github.eirslett</groupId>
+ <artifactId>frontend-maven-plugin</artifactId>
+ <!-- Use the latest released version: https://repo1.maven.org/maven2/com/github/eirslett/frontend-maven-plugin/ -->
+ <version>1.3</version>
+ <configuration>
+ <nodeVersion>v8.12.0</nodeVersion>
+ <nodeDownloadRoot>https://nodejs.org/dist/</nodeDownloadRoot>
+ <npmDownloadRoot>https://nodejs.org/dist/npm/</npmDownloadRoot>
+ <installDirectory>./</installDirectory>
+ </configuration>
+ <executions>
+ <execution>
+ <id>install node and npm</id>
+ <goals>
+ <goal>install-node-and-npm</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ </execution>
+
+ <execution>
+ <id>npm install</id>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+
+ <phase>generate-resources</phase>
+
+ <configuration>
+ <arguments>install</arguments>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>npm build</id>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+
+ <phase>generate-resources</phase>
+
+ <configuration>
+ <arguments>run build</arguments>
+ </configuration>
+ </execution>
+
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
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 @@
+<!--
+============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============================================ -->
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 [<name>]` 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"]
+}