-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
answered the questions; add route to upload file; added docFactory; a…
…dded dotenv (for local dev);
- Loading branch information
Showing
15 changed files
with
172 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
HTTP_PORT=3000 | ||
|
||
#DB_HOST=postgres # for running in docker-compose | ||
DB_HOST=localhost | ||
#DB_HOST=localhost # for running locally | ||
DB_HOST=postgres | ||
DB_PORT=5432 | ||
DB_USERNAME=curex | ||
DB_PASSWORD=dbpassword | ||
DB_NAME=curex-db | ||
DB_SYNCHRONIZE=true # todo: add more controll on this env var (on prod) | ||
|
||
UPLOAD_FILE_MAX_SIZE_BITES=123000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
{ | ||
"name": "exchange-office", | ||
"version": "0.0.1", | ||
"description": "", | ||
"author": "", | ||
"description": "Test task for AYA", | ||
"author": "[email protected]", | ||
"private": true, | ||
"license": "UNLICENSED", | ||
"scripts": { | ||
"build": "nest build", | ||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", | ||
"start": "nest start", | ||
"start:dev": "nest start --watch", | ||
"start:debug": "nest start --debug --watch", | ||
"start:dev": "NODE_OPTIONS='-r dotenv/config' nest start --watch", | ||
"start:debug": "NODE_OPTIONS='-r dotenv/config' nest start --debug --watch", | ||
"start:import": "NODE_OPTIONS='-r dotenv/config' ts-node src/main-import-file.ts", | ||
"start:prod": "node dist/main", | ||
"start:import": "ts-node src/main-import-file.ts", | ||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", | ||
"test": "jest", | ||
"test:watch": "jest --watch", | ||
|
@@ -37,10 +37,12 @@ | |
"@nestjs/testing": "^9.0.0", | ||
"@types/express": "^4.17.13", | ||
"@types/jest": "29.5.1", | ||
"@types/multer": "^1.4.7", | ||
"@types/node": "18.16.12", | ||
"@types/supertest": "^2.0.11", | ||
"@typescript-eslint/eslint-plugin": "^5.0.0", | ||
"@typescript-eslint/parser": "^5.0.0", | ||
"dotenv": "^16.3.1", | ||
"eslint": "^8.0.1", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,29 @@ | ||
import { Controller, Get } from '@nestjs/common'; | ||
import { | ||
Controller, | ||
Get, | ||
Post, | ||
Query, | ||
UploadedFile, | ||
UseInterceptors, | ||
} from '@nestjs/common'; | ||
import { FileInterceptor } from '@nestjs/platform-express'; | ||
import { Express } from 'express'; | ||
|
||
import { fileUploadOptions } from '../config'; | ||
import { DbImportService } from './db-import.service'; | ||
|
||
@Controller('db') | ||
export class DbController { | ||
constructor(private readonly dbImportService: DbImportService) {} | ||
|
||
@Get('import') | ||
async import() { | ||
// todo: think, which params to accept if we need to import from uploaded file | ||
return this.dbImportService.importFileContentToDb(); | ||
async import(@Query('filename') fileName?: string) { | ||
return this.dbImportService.importFileFromDiskToDb(fileName); | ||
} | ||
|
||
@Post('import-file') | ||
@UseInterceptors(FileInterceptor('file', fileUploadOptions)) | ||
async handleFileImport(@UploadedFile() file: Express.Multer.File) { | ||
return this.dbImportService.uploadFileToDb(file.buffer.toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { IDocument } from './interfaces'; | ||
import { Document } from './document'; | ||
|
||
export const documentFactory = (): IDocument => { | ||
// todo: define separate doc classes for any new file formats | ||
return new Document(); | ||
}; |
Oops, something went wrong.