diff --git a/Dockerfile b/Dockerfile index 5fea512..d9d62e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM registry.access.redhat.com/ubi8/nodejs-16-minimal:1-79 +FROM registry.access.redhat.com/ubi9/nodejs-22:9.5-1740412185 -USER 1001 +USER default WORKDIR /opt/app-root/src -COPY --chown=1001 . . -RUN npm install && \ +COPY --chown=default:root . . +RUN npm ci && \ npm run compile ENV HOST=0.0.0.0 PORT=3001 diff --git a/docker-compose.yaml b/docker-compose.yaml index a52ca9f..05fe57b 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,7 +1,8 @@ version: '3' services: ascent-bff: - image: quay.io/cloudnativetoolkit/ascent-bff:v1.1.0 + image: ascent-bff-next +# image: quay.io/cloudnativetoolkit/ascent-bff:v1.1.0 # build: . environment: - DATABASE_TEST={"connection":{"mongodb":{"composed":["mongodb://mongodb:27017/mongodb"],"authentication":{"username":"mongodb","password":"passw0rd"},"hosts":[{"hostname":"localhost","port":27017}],"database":"mongodb","query_options":{"authSource":"admin","tls":false}}}} @@ -21,4 +22,8 @@ services: - "27017" environment: - MONGO_INITDB_ROOT_USERNAME=mongodb - - MONGO_INITDB_ROOT_PASSWORD=passw0rd \ No newline at end of file + - MONGO_INITDB_ROOT_PASSWORD=passw0rd + volumes: + - type: bind + source: ./data/db + target: /data/db diff --git a/package.json b/package.json index df0275d..235e11c 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "engines": { - "node": "14 || 16 || 17 || 18" + "node": "14 || 16 || 17 || 18 || 20 || 22" }, "scripts": { "compile": "npm run clean && lb-tsc", diff --git a/src/controllers/automation-catalog.controller.ts b/src/controllers/automation-catalog.controller.ts index 60c635d..7e5fea6 100644 --- a/src/controllers/automation-catalog.controller.ts +++ b/src/controllers/automation-catalog.controller.ts @@ -27,7 +27,9 @@ import { ArchitecturesController, DiagramType } from './architectures.controller import { IascableService, Service } from '../services/iascable.service'; import { S3 } from 'ibm-cos-sdk'; +import {Catalog} from "@cloudnativetoolkit/iascable"; +export type CatalogResult = Omit export class AutomationCatalogController { @@ -58,11 +60,13 @@ export class AutomationCatalogController { } @get('/automation/catalog/boms') - async getBomsCatalog(): Promise { - const catalog = JSON.parse(JSON.stringify(await this.iascableService.getCatalog())); + async getBomsCatalog(): Promise { + const catalog: any = Object.assign({}, (await this.iascableService.getCatalog())); + delete catalog.modules; delete catalog.moduleIdAliases; delete catalog.flattenedAliases; + return catalog; } diff --git a/src/controllers/user.controller.ts b/src/controllers/user.controller.ts index afce4ce..0592da4 100644 --- a/src/controllers/user.controller.ts +++ b/src/controllers/user.controller.ts @@ -2,9 +2,9 @@ import { repository, } from '@loopback/repository'; import { - param, get, response, getModelSchemaRef, patch, requestBody + param, get, response, getModelSchemaRef, patch, requestBody, post } from '@loopback/rest'; -import {Architectures, Solution, User} from '../models'; +import {Architectures, Bom, Solution, User} from '../models'; import {UserRepository} from '../repositories'; export class UserController { @@ -93,4 +93,27 @@ export class UserController { return this.userRepository.findById(id); } + @post('/users') + @response(200, { + description: 'User model instance', + content: { + 'application/json': { + schema: getModelSchemaRef(User, {includeRelations: true}), + }, + }, + }) + async addUser( + @requestBody({ + content: { + 'application/json': { + schema: getModelSchemaRef(User, { + title: 'NewUser', + }), + }, + }, + }) + user: User + ): Promise { + return this.userRepository.create(user); + } } diff --git a/src/interceptors/user.interceptor.ts b/src/interceptors/user.interceptor.ts index cb0ac8f..8c12eb0 100644 --- a/src/interceptors/user.interceptor.ts +++ b/src/interceptors/user.interceptor.ts @@ -15,6 +15,7 @@ import { 'UserController.prototype.findUserArchitecturesById', 'UserController.prototype.findUserSolutionsById', 'UserController.prototype.updateById', + 'UserController.prototype.addUser', ] /**