Skip to content

Commit

Permalink
Merge branch 'dev/textract/service' into codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
dylankapnias-uni committed Jul 24, 2023
2 parents 23a016d + b498871 commit 272f2a4
Show file tree
Hide file tree
Showing 17 changed files with 2,229 additions and 191 deletions.
1,573 changes: 1,478 additions & 95 deletions backend/package-lock.json

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,24 @@
"s": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"start:prod": "node dist/src/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest --detectOpenHandles",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json --detectOpenHandles"
"test:e2e": "jest --config ./test/jest-e2e.json --detectOpenHandles",
"pm2:deploy:app": "npm run build && pm2 start pm2.cfg.json",
"pm2:start:app": "pm2 start pm2.cfg.json",
"pm2:stop:app": "pm2 stop pm2.cfg.json",
"pm2:destroy:app": "pm2 delete pm2.cfg.json",
"pm2:restart:app": "npm run pm2:stop:app && npm run pm2:deploy:app"
},
"dependencies": {
"@angular/platform-browser": "^16.1.6",
"@aws-sdk/client-s3": "^3.350.0",
"@aws-sdk/client-sqs": "^3.370.0",
"@aws-sdk/client-textract": "^3.370.0",
"@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0",
"@nestjs/jwt": "^10.0.3",
Expand Down
11 changes: 11 additions & 0 deletions backend/pm2.cfg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

{
"apps": [
{
"name": "api",
"script": "dist/src/main.js",
"instances": 1,
"exec_mode": "cluster"
}
]
}
6 changes: 6 additions & 0 deletions backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import { S3Service } from './s3/s3.service';
import { User } from './users/entities/user.entity';
import { AssetManagerModule } from './asset_manager/asset_manager.module';
import { ConversionService } from './conversion/conversion.service';
import { TextractController } from './textract/textract.controller';
import { TextractModule } from './textract/textract.module';
import { TextractService } from './textract/textract.service';

@Module({
imports: [
Expand All @@ -40,12 +43,14 @@ import { ConversionService } from './conversion/conversion.service';
S3Module,
FileManagerModule,
AssetManagerModule,
TextractModule,
],
controllers: [
AppController,
AuthController,
S3Controller,
FileManagerController,
TextractController,
],
providers: [
AppService,
Expand All @@ -54,6 +59,7 @@ import { ConversionService } from './conversion/conversion.service';
FoldersService,
S3Service,
ConversionService,
TextractService,
],
})
export class AppModule {}
18 changes: 18 additions & 0 deletions backend/src/textract/textract.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { TextractController } from './textract.controller';

describe('TextractController', () => {
let controller: TextractController;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [TextractController],
}).compile();

controller = module.get<TextractController>(TextractController);
});

it('should be defined', () => {
expect(controller).toBeDefined();
});
});
77 changes: 77 additions & 0 deletions backend/src/textract/textract.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import {
Controller,
Post,
Body,
UseInterceptors,
} from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';
import { MarkdownFileDTO } from '../markdown_files/dto/markdown_file.dto';
import { TextractService } from './textract.service';

@Controller('textract')
export class TextractController {
constructor(
private readonly textractService: TextractService,
) {}
@Post('extract_image')
@UseInterceptors(FileInterceptor('file'))
async extractImage(
@Body() fileDTO: MarkdownFileDTO,
ExtractType: string,
) {
const retVal =
await this.textractService.extractDocument(
'sync',
fileDTO,
ExtractType,
);

console.log(retVal);

return retVal;
}

@Post('extract_test')
@UseInterceptors(FileInterceptor('file'))
async extract_test(
@Body() fileDTO: MarkdownFileDTO,
ExtractType: string,
) {
const retVal =
await this.textractService.test_get(
ExtractType,
);

console.log(retVal);

return retVal;
}

@Post('extract_msg')
@UseInterceptors(FileInterceptor('file'))
async extract_msg(
@Body() fileDTO: MarkdownFileDTO,
ExtractType: string,
) {
const retVal =
await this.textractService.test_msg();

console.log(retVal);

return retVal;
}

@Post('extract_del')
@UseInterceptors(FileInterceptor('file'))
async extract_del(
@Body() fileDTO: MarkdownFileDTO,
ExtractType: string,
) {
const retVal =
await this.textractService.test_del();

console.log(retVal);

return retVal;
}
}
7 changes: 7 additions & 0 deletions backend/src/textract/textract.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Module } from '@nestjs/common';
import { TextractService } from './textract.service';

@Module({
providers: [TextractService]
})
export class TextractModule {}
18 changes: 18 additions & 0 deletions backend/src/textract/textract.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { TextractService } from './textract.service';

describe('TextractService', () => {
let service: TextractService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [TextractService],
}).compile();

service = module.get<TextractService>(TextractService);
});

it('should be defined', () => {
expect(service).toBeDefined();
});
});
Loading

0 comments on commit 272f2a4

Please sign in to comment.