Viktoria435 commited on
Commit
2ff651b
·
1 Parent(s): 08d0920

Refactor file paths in Book, Visitor, and Worker services to use absolute paths

Browse files

- Updated FileManager instances in BookService, VisitorService, and WorkerService to use absolute paths for data files, ensuring correct file access.
- Adjusted import statements in BookController and BookModule to reflect the new absolute path structure.

src/book/book.controller.ts CHANGED
@@ -14,10 +14,10 @@ import { VisitorService } from '../visitor/visitor.service';
14
  import { CreateBookDto } from './dto/create-book.dto';
15
  import { BorrowBookDto } from './dto/borrow-book.dto';
16
  import { ReturnBookDto } from './dto/return-book.dto';
17
- import { DateUtils } from '../utils/date.utils';
18
- import { WorkerService } from '../worker/worker.service';
19
  import { UpdateBookDto } from './dto/update-book.dto';
20
- import { buildDownloadFile } from '../utils/download.utils';
21
 
22
  @Controller('books')
23
  export class BookController {
 
14
  import { CreateBookDto } from './dto/create-book.dto';
15
  import { BorrowBookDto } from './dto/borrow-book.dto';
16
  import { ReturnBookDto } from './dto/return-book.dto';
17
+ import { DateUtils } from 'src/utils/date.utils';
18
+ import { WorkerService } from 'src/worker/worker.service';
19
  import { UpdateBookDto } from './dto/update-book.dto';
20
+ import { buildDownloadFile } from 'src/utils/download.utils';
21
 
22
  @Controller('books')
23
  export class BookController {
src/book/book.module.ts CHANGED
@@ -1,7 +1,7 @@
1
  import { Module } from '@nestjs/common';
2
  import { BookController } from './book.controller';
3
  import { BookService } from './book.service';
4
- import { BookLinkManager } from '../common/book-link-manager';
5
  import { VisitorModule } from '../visitor/visitor.module';
6
  import { WorkerModule } from '../worker/worker.module';
7
 
 
1
  import { Module } from '@nestjs/common';
2
  import { BookController } from './book.controller';
3
  import { BookService } from './book.service';
4
+ import { BookLinkManager } from 'src/common/book-link-manager';
5
  import { VisitorModule } from '../visitor/visitor.module';
6
  import { WorkerModule } from '../worker/worker.module';
7
 
src/book/book.service.ts CHANGED
@@ -15,7 +15,7 @@ import { bookLinkManager } from '../common/book-link-manager';
15
 
16
  @Injectable()
17
  export class BookService {
18
- private file = new FileManager('../data/books.txt');
19
 
20
  async getAll(): Promise<Book[]> {
21
  const lines = await this.file.readLines();
 
15
 
16
  @Injectable()
17
  export class BookService {
18
+ private file = new FileManager('src/data/books.txt');
19
 
20
  async getAll(): Promise<Book[]> {
21
  const lines = await this.file.readLines();
src/data/books.txt CHANGED
@@ -0,0 +1 @@
 
 
1
+ id=5ad76123-5d82-4161-ba49-e170ec514b48;title=Pride and Prejudice;author=Jane Austen;pages=279;year=1813;genre=Romance;status=Available
src/visitor/visitor.service.ts CHANGED
@@ -17,7 +17,7 @@ import { Link } from '../common/Link';
17
 
18
  @Injectable()
19
  export class VisitorService {
20
- private file = new FileManager('../data/visitors.txt');
21
  private visitorLinkManager: VisitorLinkManager = new VisitorLinkManager();
22
 
23
  async getAll(): Promise<Visitor[]> {
 
17
 
18
  @Injectable()
19
  export class VisitorService {
20
+ private file = new FileManager('src/data/visitors.txt');
21
  private visitorLinkManager: VisitorLinkManager = new VisitorLinkManager();
22
 
23
  async getAll(): Promise<Visitor[]> {
src/worker/worker.service.ts CHANGED
@@ -15,7 +15,7 @@ import { Link } from '../common/Link';
15
 
16
  @Injectable()
17
  export class WorkerService {
18
- private file = new FileManager('../data/workers.txt');
19
  private workerLinkManager = new WorkerLinkManager();
20
 
21
  async getAll(): Promise<Worker[]> {
 
15
 
16
  @Injectable()
17
  export class WorkerService {
18
+ private file = new FileManager('src/data/workers.txt');
19
  private workerLinkManager = new WorkerLinkManager();
20
 
21
  async getAll(): Promise<Worker[]> {