diff --git a/projects/aas-lib/tsconfig.json b/projects/aas-lib/tsconfig.json index 0c0d5cf8..6c52cc33 100644 --- a/projects/aas-lib/tsconfig.json +++ b/projects/aas-lib/tsconfig.json @@ -6,8 +6,6 @@ "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, "declaration": false, - "module": "ES2022", - "moduleResolution": "node", "importHelpers": true, "lib": [ "ES2022", diff --git a/projects/aas-portal/tsconfig.json b/projects/aas-portal/tsconfig.json index 0d7f46a4..fbf99a72 100644 --- a/projects/aas-portal/tsconfig.json +++ b/projects/aas-portal/tsconfig.json @@ -6,8 +6,6 @@ "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, "declaration": false, - "module": "ES2022", - "moduleResolution": "node", "importHelpers": true, "lib": [ "ES2022", diff --git a/projects/aas-server/src/app/aas-index/aas-index.ts b/projects/aas-server/src/app/aas-index/aas-index.ts index 0f6c787a..6f979132 100644 --- a/projects/aas-server/src/app/aas-index/aas-index.ts +++ b/projects/aas-server/src/app/aas-index/aas-index.ts @@ -9,6 +9,7 @@ import { AASCursor, AASDocument, + AASDocumentId, AASEndpoint, AASPagedResult, aas, @@ -144,6 +145,10 @@ export abstract class AASIndex { return BigInt(referable.value); } + protected toDocumentId(document: AASDocument): AASDocumentId { + return { endpoint: document.endpoint, id: document.id }; + } + private preprocessString(value: string | LangString[] | undefined, max: number = 512): string | undefined { if (value === undefined) { return undefined; diff --git a/projects/aas-server/src/app/aas-index/lowdb/lowdb-index.ts b/projects/aas-server/src/app/aas-index/lowdb/lowdb-index.ts index d93a2285..753642a9 100644 --- a/projects/aas-server/src/app/aas-index/lowdb/lowdb-index.ts +++ b/projects/aas-server/src/app/aas-index/lowdb/lowdb-index.ts @@ -336,7 +336,7 @@ export class LowDbIndex extends AASIndex { return { previous: null, documents: documents.slice(0, limit), - next: documents.length >= 0 ? documents[limit] : null, + next: documents.length >= 0 ? this.toDocumentId(documents[limit]) : null, }; } @@ -348,7 +348,7 @@ export class LowDbIndex extends AASIndex { const n = limit + 1; const items = this.db.data.documents; - let i = items.findIndex(item => this.compare(current, item) < 0); + let i = items.findIndex(item => this.compare(current, item) <= 0); if (i < 0) { return this.getLastPage(limit, filter); } @@ -374,7 +374,7 @@ export class LowDbIndex extends AASIndex { return { previous: current, documents: documents.slice(0, limit), - next: documents.length >= n ? documents[limit] : null, + next: documents.length >= n ? this.toDocumentId(documents[limit]) : null, }; } @@ -410,7 +410,7 @@ export class LowDbIndex extends AASIndex { } return { - previous: documents.length >= n ? documents[0] : null, + previous: documents.length >= n ? this.toDocumentId(documents[0]) : null, documents: documents.slice(0, limit).reverse(), next: current, }; @@ -443,7 +443,7 @@ export class LowDbIndex extends AASIndex { } return { - previous: documents.length >= n ? documents[0] : null, + previous: documents.length >= n ? this.toDocumentId(documents[0]) : null, documents: documents.slice(0, limit).reverse(), next: null, }; diff --git a/projects/aas-server/src/app/aas-index/mysql/mysql-index.ts b/projects/aas-server/src/app/aas-index/mysql/mysql-index.ts index b04dee29..fd22c6cb 100644 --- a/projects/aas-server/src/app/aas-index/mysql/mysql-index.ts +++ b/projects/aas-server/src/app/aas-index/mysql/mysql-index.ts @@ -604,8 +604,4 @@ export class MySqlIndex extends AASIndex { return document; } - - private toDocumentId(document: AASDocument): AASDocumentId { - return { endpoint: document.endpoint, id: document.id }; - } } diff --git a/projects/aas-server/src/app/app.ts b/projects/aas-server/src/app/app.ts index 52b2c3de..574f5a7b 100644 --- a/projects/aas-server/src/app/app.ts +++ b/projects/aas-server/src/app/app.ts @@ -20,6 +20,7 @@ import { RegisterRoutes } from './routes/routes.js'; import { ERRORS } from './errors.js'; import { Variable } from './variable.js'; import { Logger } from './logging/logger.js'; +import multer from 'multer'; @singleton() export class App { @@ -64,7 +65,7 @@ export class App { return res.send(swaggerUi.generateHTML(this.swaggerDoc)); }); - RegisterRoutes(this.app); + RegisterRoutes(this.app, { multer: multer({ dest: './temp' }) }); this.app.get('/', this.getIndex); this.app.use(express.static(this.variable.WEB_ROOT)); diff --git a/projects/aas-server/src/test/aas-index/lowdb/lowdb-index.spec.ts b/projects/aas-server/src/test/aas-index/lowdb/lowdb-index.spec.ts index 465ffa70..8dbdd8aa 100644 --- a/projects/aas-server/src/test/aas-index/lowdb/lowdb-index.spec.ts +++ b/projects/aas-server/src/test/aas-index/lowdb/lowdb-index.spec.ts @@ -63,7 +63,7 @@ describe('LowDbIndex', () => { expect(page.next).toBeDefined(); let n = page.documents.length; while (page.next !== null) { - cursor = { ...cursor, next: getId(page.documents[page.documents.length - 1]) }; + cursor = { ...cursor, next: page.next }; page = await index.getDocuments(cursor); n += page.documents.length; } diff --git a/projects/aas-server/src/test/controller/app-controller.spec.ts b/projects/aas-server/src/test/controller/app-controller.spec.ts index 0e773574..46bb72eb 100644 --- a/projects/aas-server/src/test/controller/app-controller.spec.ts +++ b/projects/aas-server/src/test/controller/app-controller.spec.ts @@ -9,6 +9,7 @@ import 'reflect-metadata'; import { container } from 'tsyringe'; import express, { Express, json, urlencoded } from 'express'; +import multer from 'multer'; import morgan from 'morgan'; import request from 'supertest'; import { Logger } from '../../app/logging/logger.js'; @@ -61,7 +62,7 @@ describe('AppController', function () { app.use(morgan('dev')); app.set('trust proxy', 1); - RegisterRoutes(app); + RegisterRoutes(app, { multer: multer({ dest: './temp' }) }); app.use(errorHandler); }); diff --git a/projects/aas-server/src/test/controller/auth-controller.spec.ts b/projects/aas-server/src/test/controller/auth-controller.spec.ts index 1028253e..74c8f1cb 100644 --- a/projects/aas-server/src/test/controller/auth-controller.spec.ts +++ b/projects/aas-server/src/test/controller/auth-controller.spec.ts @@ -9,6 +9,7 @@ import 'reflect-metadata'; import { container } from 'tsyringe'; import express, { Express, json, urlencoded } from 'express'; +import multer from 'multer'; import morgan from 'morgan'; import request from 'supertest'; import { ApplicationError, AuthResult, Cookie, Credentials } from 'aas-core'; @@ -58,7 +59,7 @@ describe('AuthController', () => { app.use(morgan('dev')); app.set('trust proxy', 1); - RegisterRoutes(app); + RegisterRoutes(app, { multer: multer({ dest: './temp' }) }); app.use(errorHandler); }); diff --git a/projects/aas-server/src/test/controller/containers-controller.spec.ts b/projects/aas-server/src/test/controller/containers-controller.spec.ts index 7dcf8a1f..54d8bd73 100644 --- a/projects/aas-server/src/test/controller/containers-controller.spec.ts +++ b/projects/aas-server/src/test/controller/containers-controller.spec.ts @@ -10,6 +10,7 @@ import 'reflect-metadata'; import { container } from 'tsyringe'; import { describe, beforeEach, it, expect, jest } from '@jest/globals'; import express, { Express, json, urlencoded } from 'express'; +import multer from 'multer'; import morgan from 'morgan'; import request from 'supertest'; import { Readable } from 'stream'; @@ -74,7 +75,7 @@ describe('ContainersController', () => { app.use(morgan('dev')); app.set('trust proxy', 1); - RegisterRoutes(app); + RegisterRoutes(app, { multer: multer({ dest: './temp' }) }); app.use(errorHandler); }); @@ -208,15 +209,15 @@ describe('ContainersController', () => { }); }); - it('updateDocument: /api/v1/containers/:url/documents/:id', async () => { + it('updateDocument: /api/v1/containers/{endpoint}/documents/{id}', async () => { aasProvider.updateDocumentAsync.mockReturnValue(Promise.resolve([])); auth.hasUserAsync.mockReturnValue(new Promise(resolve => resolve(true))); - const url = Buffer.from('http://localhost/container').toString('base64url'); + const endpoint = Buffer.from('Endpoint 1').toString('base64url'); const id = Buffer.from('http://localhost/document').toString('base64url'); const response = await request(app) - .put(`/api/v1/containers/${url}/documents/${id}`) + .put(`/api/v1/containers/${endpoint}/documents/${id}`) .set('Authorization', `Bearer ${getToken('John')}`) .attach('content', resolve('./src/test/assets/aas-example.json')); diff --git a/projects/aas-server/src/test/controller/documents-controller.spec.ts b/projects/aas-server/src/test/controller/documents-controller.spec.ts index d2434742..a887a2a9 100644 --- a/projects/aas-server/src/test/controller/documents-controller.spec.ts +++ b/projects/aas-server/src/test/controller/documents-controller.spec.ts @@ -11,6 +11,7 @@ import { container } from 'tsyringe'; import { describe, beforeEach, it, expect, jest } from '@jest/globals'; import express, { Express, json, urlencoded } from 'express'; import morgan from 'morgan'; +import multer from 'multer'; import request from 'supertest'; import { AASCursor, AASPagedResult } from 'aas-core'; @@ -74,7 +75,7 @@ describe('DocumentsController', function () { app.use(morgan('dev')); app.set('trust proxy', 1); - RegisterRoutes(app); + RegisterRoutes(app, { multer: multer({ dest: './temp' }) }); app.use(errorHandler); }); diff --git a/projects/aas-server/src/test/controller/endpoints-controller.spec.ts b/projects/aas-server/src/test/controller/endpoints-controller.spec.ts index 46cc9849..c8ce6dce 100644 --- a/projects/aas-server/src/test/controller/endpoints-controller.spec.ts +++ b/projects/aas-server/src/test/controller/endpoints-controller.spec.ts @@ -11,6 +11,7 @@ import { container } from 'tsyringe'; import { describe, beforeEach, it, expect, jest } from '@jest/globals'; import express, { Express, json, urlencoded } from 'express'; import morgan from 'morgan'; +import multer from 'multer'; import request from 'supertest'; import { AASEndpoint } from 'aas-core'; @@ -70,7 +71,7 @@ describe('EndpointsController', function () { app.use(morgan('dev')); app.set('trust proxy', 1); - RegisterRoutes(app); + RegisterRoutes(app, { multer: multer({ dest: './temp' }) }); app.use(errorHandler); }); diff --git a/projects/aas-server/src/test/controller/templates-controller.spec.ts b/projects/aas-server/src/test/controller/templates-controller.spec.ts index 69237543..58980052 100644 --- a/projects/aas-server/src/test/controller/templates-controller.spec.ts +++ b/projects/aas-server/src/test/controller/templates-controller.spec.ts @@ -8,6 +8,7 @@ import 'reflect-metadata'; import { container } from 'tsyringe'; +import multer from 'multer'; import { describe, beforeEach, it, expect, jest } from '@jest/globals'; import express, { Express, json, urlencoded } from 'express'; import morgan from 'morgan'; @@ -60,7 +61,7 @@ describe('TemplateController', () => { app.use(morgan('dev')); app.set('trust proxy', 1); - RegisterRoutes(app); + RegisterRoutes(app, { multer: multer({ dest: './temp' }) }); app.use(errorHandler); }); diff --git a/projects/aas-server/tsconfig.json b/projects/aas-server/tsconfig.json index 693e8274..933bf32e 100644 --- a/projects/aas-server/tsconfig.json +++ b/projects/aas-server/tsconfig.json @@ -8,6 +8,8 @@ "emitDecoratorMetadata": true, "alwaysStrict": true, "useUnknownInCatchVariables": false, + "module": "NodeNext", + "moduleResolution": "NodeNext", "lib": [ "ES2022" ], diff --git a/projects/aas-server/tsoa.json b/projects/aas-server/tsoa.json index c08d961e..8286aed2 100644 --- a/projects/aas-server/tsoa.json +++ b/projects/aas-server/tsoa.json @@ -4,9 +4,6 @@ "controllerPathGlobs": [ "src/app/controller/**/*controller.ts" ], - "multerOpts": { - "dest": "./temp" - }, "spec": { "outputDirectory": "./src/assets", "specVersion": 3, diff --git a/projects/fhg-jest/tsconfig.json b/projects/fhg-jest/tsconfig.json index 562ceaa0..6f080031 100644 --- a/projects/fhg-jest/tsconfig.json +++ b/projects/fhg-jest/tsconfig.json @@ -5,8 +5,6 @@ "outDir": "./build", "noImplicitAny": true, "skipLibCheck": true, - "module": "NodeNext", - "moduleResolution": "NodeNext", "emitDecoratorMetadata": true, "alwaysStrict": true, "useUnknownInCatchVariables": false, diff --git a/tsconfig.json b/tsconfig.json index 3b606c5d..806900b2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,8 +14,8 @@ "resolveJsonModule": true, "allowSyntheticDefaultImports": true, "esModuleInterop": true, - "moduleResolution": "NodeNext", - "module": "NodeNext" + "moduleResolution": "bundler", + "module": "ES2022" }, "ts-node": { "esm": true