diff --git a/angular.json b/angular.json index 4de689e..a04f750 100644 --- a/angular.json +++ b/angular.json @@ -84,10 +84,7 @@ "apps/sample-platform/tsconfig.app.json", "apps/sample-platform/tsconfig.spec.json" ], - "exclude": [ - "**/node_modules/**", - "!apps/sample-platform/**" - ] + "exclude": ["**/node_modules/**", "!apps/sample-platform/**"] } }, "test": { @@ -122,13 +119,8 @@ "lint": { "builder": "@angular-devkit/build-angular:tslint", "options": { - "tsConfig": [ - "apps/sample-platform-e2e/tsconfig.e2e.json" - ], - "exclude": [ - "**/node_modules/**", - "!apps/sample-platform-e2e/**" - ] + "tsConfig": ["apps/sample-platform-e2e/tsconfig.e2e.json"], + "exclude": ["**/node_modules/**", "!apps/sample-platform-e2e/**"] } } } @@ -146,9 +138,7 @@ "outputPath": "dist/apps/api", "main": "apps/api/src/main.ts", "tsConfig": "apps/api/tsconfig.app.json", - "assets": [ - "apps/api/src/assets" - ] + "assets": ["apps/api/src/assets"] }, "configurations": { "production": { @@ -177,10 +167,7 @@ "apps/api/tsconfig.app.json", "apps/api/tsconfig.spec.json" ], - "exclude": [ - "**/node_modules/**", - "!apps/api/**" - ] + "exclude": ["**/node_modules/**", "!apps/api/**"] } }, "test": { @@ -320,10 +307,7 @@ "libs/testing/tsconfig.lib.json", "libs/testing/tsconfig.spec.json" ], - "exclude": [ - "**/node_modules/**", - "!libs/testing/**" - ] + "exclude": ["**/node_modules/**", "!libs/testing/**"] } }, "test": { @@ -380,10 +364,7 @@ "libs/api-implementation/xml/tsconfig.lib.json", "libs/api-implementation/xml/tsconfig.spec.json" ], - "exclude": [ - "**/node_modules/**", - "!libs/api-implementation/xml/**" - ] + "exclude": ["**/node_modules/**", "!libs/api-implementation/xml/**"] } }, "test": { @@ -488,6 +469,67 @@ "style": "scss" } } + }, + "api-implementation-samples": { + "root": "libs/api-implementation/samples", + "sourceRoot": "libs/api-implementation/samples/src", + "projectType": "library", + "schematics": {}, + "architect": { + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "libs/api-implementation/samples/tsconfig.lib.json", + "libs/api-implementation/samples/tsconfig.spec.json" + ], + "exclude": [ + "**/node_modules/**", + "!libs/api-implementation/samples/**" + ] + } + }, + "test": { + "builder": "@nrwl/jest:jest", + "options": { + "jestConfig": "libs/api-implementation/samples/jest.config.js", + "tsConfig": "libs/api-implementation/samples/tsconfig.spec.json", + "passWithNoTests": true + } + } + } + }, + "frontend-samples": { + "projectType": "library", + "root": "libs/frontend/samples", + "sourceRoot": "libs/frontend/samples/src", + "prefix": "new-sample-platform", + "architect": { + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "libs/frontend/samples/tsconfig.lib.json", + "libs/frontend/samples/tsconfig.spec.json" + ], + "exclude": ["**/node_modules/**", "!libs/frontend/samples/**"] + } + }, + "test": { + "builder": "@nrwl/jest:jest", + "options": { + "jestConfig": "libs/frontend/samples/jest.config.js", + "tsConfig": "libs/frontend/samples/tsconfig.spec.json", + "passWithNoTests": true, + "setupFile": "libs/frontend/samples/src/test-setup.ts" + } + } + }, + "schematics": { + "@nrwl/angular:component": { + "style": "scss" + } + } } }, "cli": { @@ -504,4 +546,4 @@ } }, "defaultProject": "sample-platform" -} \ No newline at end of file +} diff --git a/apps/api/src/app/app.module.ts b/apps/api/src/app/app.module.ts index ed57d36..06638e6 100644 --- a/apps/api/src/app/app.module.ts +++ b/apps/api/src/app/app.module.ts @@ -2,11 +2,17 @@ import { Module } from '@nestjs/common'; import { AppController } from './app.controller'; import { VMOrchestrationModule } from '../../../../libs/api-implementation/orchestration/src'; -import { ApiImplementationRegressionTestsModule } from '../../../../libs/api-implementation/regression-tests/src' -import { ApiImplementationDatabaseModule } from '../../../../libs/api-implementation/database/src' +import { ApiImplementationRegressionTestsModule } from '@new-sample-platform/api-implementation/regression-tests'; +import { ApiImplementationDatabaseModule } from '@new-sample-platform/api-implementation/database'; +import { ApiImplementationSamplesModule } from '@new-sample-platform/api-implementation/samples' @Module({ - imports: [VMOrchestrationModule, ApiImplementationRegressionTestsModule, ApiImplementationDatabaseModule], + imports: [ + VMOrchestrationModule, + ApiImplementationRegressionTestsModule, + ApiImplementationDatabaseModule, + ApiImplementationSamplesModule + ], controllers: [AppController], providers: [], }) diff --git a/apps/sample-platform/proxy.conf.json b/apps/sample-platform/proxy.conf.json index 62a1e7b..37da373 100644 --- a/apps/sample-platform/proxy.conf.json +++ b/apps/sample-platform/proxy.conf.json @@ -1,6 +1,8 @@ { - "/api": { - "target": "http://localhost:3333", - "secure": false + "/api/*": { + "target": "http://localhost:3333", + "secure": false, + "changeOrigin": true, + "logLevel": "debug" } -} +} \ No newline at end of file diff --git a/apps/sample-platform/src/app/app.module.ts b/apps/sample-platform/src/app/app.module.ts index cf184b2..34e18d4 100644 --- a/apps/sample-platform/src/app/app.module.ts +++ b/apps/sample-platform/src/app/app.module.ts @@ -1,6 +1,7 @@ import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; +import { FlexLayoutModule } from '@angular/flex-layout'; import { AppComponent } from './app.component'; import { HttpClientModule } from '@angular/common/http'; import { RoutingModule } from './routing.module'; @@ -15,6 +16,7 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; @NgModule({ declarations: [AppComponent], imports: [ + FlexLayoutModule, BrowserModule, HttpClientModule, RoutingModule, diff --git a/apps/sample-platform/src/app/routing.module.ts b/apps/sample-platform/src/app/routing.module.ts index 31965d8..40e1a61 100644 --- a/apps/sample-platform/src/app/routing.module.ts +++ b/apps/sample-platform/src/app/routing.module.ts @@ -13,6 +13,13 @@ const routes: Routes = [ (mod) => mod.FrontendRegressionTestModule ) }, + { + path: 'samples', + loadChildren: () => + import('@new-sample-platform/frontend/samples').then( + (mod) => mod.FrontendSamplesModule + ) + } ]; @NgModule({ diff --git a/config.ts b/config.ts index 80b35b1..f349d03 100644 --- a/config.ts +++ b/config.ts @@ -4,5 +4,6 @@ export enum AppConfig { GITHUB_API_LINK = "https://api.github.com/", CCEXTRACTOR_REPO_NAME = "ccextractor", CCEXTRACTOR_REPO_OWNER = "zelzhan", - MONGO_CONNECTION_STRING = "mongodb://mongo:27017/test" + MONGO_CONNECTION_STRING = "mongodb://mongo:27017/test", + PATH_TO_MOUNTED_BUCKET = "/path/to/bucket/" } diff --git a/libs/api-implementation/samples/README.md b/libs/api-implementation/samples/README.md new file mode 100644 index 0000000..05bbd81 --- /dev/null +++ b/libs/api-implementation/samples/README.md @@ -0,0 +1,7 @@ +# api-implementation-samples + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `ng test api-implementation-samples` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/api-implementation/samples/jest.config.js b/libs/api-implementation/samples/jest.config.js new file mode 100644 index 0000000..1e4a4d0 --- /dev/null +++ b/libs/api-implementation/samples/jest.config.js @@ -0,0 +1,10 @@ +module.exports = { + name: 'api-implementation-samples', + preset: '../../../jest.config.js', + testEnvironment: 'node', + transform: { + '^.+\\.[tj]sx?$': 'ts-jest', + }, + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'], + coverageDirectory: '../../../coverage/libs/api-implementation/samples', +}; diff --git a/libs/api-implementation/samples/src/index.ts b/libs/api-implementation/samples/src/index.ts new file mode 100644 index 0000000..b0fd743 --- /dev/null +++ b/libs/api-implementation/samples/src/index.ts @@ -0,0 +1 @@ +export * from './lib/api-implementation-samples.module'; diff --git a/libs/api-implementation/samples/src/lib/api-implementation-samples.module.ts b/libs/api-implementation/samples/src/lib/api-implementation-samples.module.ts new file mode 100644 index 0000000..6d1cc39 --- /dev/null +++ b/libs/api-implementation/samples/src/lib/api-implementation-samples.module.ts @@ -0,0 +1,11 @@ +import { Module } from '@nestjs/common'; + +import { SamplesController } from './samples.controller' +import { SamplesService } from './services/samples.service'; + +@Module({ + controllers: [SamplesController], + providers: [SamplesService], + exports: [], +}) +export class ApiImplementationSamplesModule {} diff --git a/libs/api-implementation/samples/src/lib/samples.controller.ts b/libs/api-implementation/samples/src/lib/samples.controller.ts new file mode 100644 index 0000000..8f9c207 --- /dev/null +++ b/libs/api-implementation/samples/src/lib/samples.controller.ts @@ -0,0 +1,24 @@ +import { + Controller, + Post, + UseInterceptors, + UploadedFile, +} from '@nestjs/common'; +import { FileInterceptor } from '@nestjs/platform-express'; +import { SamplesService } from './services/samples.service'; + +@Controller('samples') +export class SamplesController { + constructor(private service: SamplesService) {} + + @Post('upload') + @UseInterceptors(FileInterceptor('file')) + uploadFile(@UploadedFile() file) { + try { + this.service.writeToBucket(file); + } catch (error) { + return 'Error while writing the file to the bucket' + } + return 200 + } +} diff --git a/libs/api-implementation/samples/src/lib/services/samples.service.ts b/libs/api-implementation/samples/src/lib/services/samples.service.ts new file mode 100644 index 0000000..1007e69 --- /dev/null +++ b/libs/api-implementation/samples/src/lib/services/samples.service.ts @@ -0,0 +1,18 @@ +import { Injectable } from '@nestjs/common'; +import { writeFileSync } from 'fs'; +import { AppConfig } from '../../../../../../config'; +@Injectable() +export class SamplesService { + async writeToBucket(file) { + try { + writeFileSync( + AppConfig.PATH_TO_MOUNTED_BUCKET + file.originalname, + file.buffer + ); + } catch (error) { + console.error(`Error occured while writing the file to the bucket`); + console.debug(error.stack); + throw error; + } + } +} diff --git a/libs/api-implementation/samples/tsconfig.json b/libs/api-implementation/samples/tsconfig.json new file mode 100644 index 0000000..e65708f --- /dev/null +++ b/libs/api-implementation/samples/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "types": ["node", "jest"], + "target": "es6" + }, + "include": ["**/*.ts"] +} diff --git a/libs/api-implementation/samples/tsconfig.lib.json b/libs/api-implementation/samples/tsconfig.lib.json new file mode 100644 index 0000000..9c463b5 --- /dev/null +++ b/libs/api-implementation/samples/tsconfig.lib.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "../../../dist/out-tsc", + "declaration": true, + "rootDir": "./src", + "types": ["node"] + }, + "exclude": ["**/*.spec.ts"], + "include": ["**/*.ts"] +} diff --git a/libs/api-implementation/samples/tsconfig.spec.json b/libs/api-implementation/samples/tsconfig.spec.json new file mode 100644 index 0000000..1798b37 --- /dev/null +++ b/libs/api-implementation/samples/tsconfig.spec.json @@ -0,0 +1,15 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "**/*.spec.ts", + "**/*.spec.tsx", + "**/*.spec.js", + "**/*.spec.jsx", + "**/*.d.ts" + ] +} diff --git a/libs/api-implementation/samples/tslint.json b/libs/api-implementation/samples/tslint.json new file mode 100644 index 0000000..2cdd298 --- /dev/null +++ b/libs/api-implementation/samples/tslint.json @@ -0,0 +1,5 @@ +{ + "extends": "../../../tslint.json", + "linterOptions": { "exclude": ["!**/*"] }, + "rules": {} +} diff --git a/libs/frontend/regression-test/src/lib/containers/list-regression-tests/list-regression-tests.component.ts b/libs/frontend/regression-test/src/lib/containers/list-regression-tests/list-regression-tests.component.ts index b4582d2..3991369 100644 --- a/libs/frontend/regression-test/src/lib/containers/list-regression-tests/list-regression-tests.component.ts +++ b/libs/frontend/regression-test/src/lib/containers/list-regression-tests/list-regression-tests.component.ts @@ -16,7 +16,6 @@ export class ListRegressionTestsComponent implements OnInit { this.getData().subscribe((data: any) => { this.dataSource = data }) - console.log(this.dataSource) } ngOnInit(): void { } diff --git a/libs/frontend/samples/README.md b/libs/frontend/samples/README.md new file mode 100644 index 0000000..d427e2f --- /dev/null +++ b/libs/frontend/samples/README.md @@ -0,0 +1,7 @@ +# frontend-samples + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test frontend-samples` to execute the unit tests. diff --git a/libs/frontend/samples/jest.config.js b/libs/frontend/samples/jest.config.js new file mode 100644 index 0000000..02f5566 --- /dev/null +++ b/libs/frontend/samples/jest.config.js @@ -0,0 +1,10 @@ +module.exports = { + name: 'frontend-samples', + preset: '../../../jest.config.js', + coverageDirectory: '../../../coverage/libs/frontend/samples', + snapshotSerializers: [ + 'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js', + 'jest-preset-angular/build/AngularSnapshotSerializer.js', + 'jest-preset-angular/build/HTMLCommentSerializer.js', + ], +}; diff --git a/libs/frontend/samples/src/index.ts b/libs/frontend/samples/src/index.ts new file mode 100644 index 0000000..2228487 --- /dev/null +++ b/libs/frontend/samples/src/index.ts @@ -0,0 +1 @@ +export * from './lib/frontend-samples.module'; diff --git a/libs/frontend/samples/src/lib/components/dialog/dialog.component.html b/libs/frontend/samples/src/lib/components/dialog/dialog.component.html new file mode 100644 index 0000000..7f7804e --- /dev/null +++ b/libs/frontend/samples/src/lib/components/dialog/dialog.component.html @@ -0,0 +1,28 @@ + +