This file contains hidden or 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
| import { RemoteGraphQLDataSource } from '@apollo/gateway'; | |
| import { fetch, Request, Headers } from 'apollo-server-env'; | |
| import { isObject } from '@apollo/gateway/dist/utilities/predicates'; | |
| import FormData from 'form-data'; | |
| import _ from 'lodash'; | |
| export default class FileUploadDataSource extends RemoteGraphQLDataSource { | |
| async process(args) { | |
| const { request, context } = args; |
This file contains hidden or 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
| import { Module } from '@nestjs/common'; | |
| import { MongooseModule } from '@nestjs/mongoose'; | |
| import { IDataServices } from '../../../core'; | |
| import { MongoDataServices } from './mongo-data-services.service'; | |
| @Module({ | |
| providers: [ | |
| { | |
| provide: IDataServices, | |
| useClass: MongoDataServices, |
This file contains hidden or 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
| import { Injectable } from '@nestjs/common'; | |
| import { Book } from '../../../core/entities'; | |
| import { ICrmServices } from '../../../core/abstracts'; | |
| @Injectable() | |
| export class SalesforceService implements ICrmServices { | |
| bookAdded(book: Book): Promise<boolean> { | |
| // Implement salesforce api logic | |
| return Promise.resolve(true); |
This file contains hidden or 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
| import { Injectable, OnApplicationBootstrap } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| import { Model } from 'mongoose'; | |
| import { IDataServices } from '../../../core'; | |
| import { MongoGenericRepository } from './mongo-generic-repository'; | |
| import { | |
| Author, | |
| AuthorDocument, | |
| Book, | |
| BookDocument, |
This file contains hidden or 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
| import { Model } from 'mongoose'; | |
| import { IGenericRepository } from '../../../core'; | |
| export class MongoGenericRepository<T> implements IGenericRepository<T> { | |
| private _repository: Model<T>; | |
| private _populateOnFind: string[]; | |
| constructor(repository: Model<T>, populateOnFind: string[] = []) { | |
| this._repository = repository; | |
| this._populateOnFind = populateOnFind; |
This file contains hidden or 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
| import { Controller, Post, Body } from '@nestjs/common'; | |
| import { CreateBookDto, CreateBookResponseDto } from '../core/dtos'; | |
| import { BookServices, BookFactoryService } from '../services/use-cases/book'; | |
| @Controller('api/book') | |
| export class BookController { | |
| constructor( | |
| private bookServices: BookServices, | |
| private bookFactoryService: BookFactoryService, | |
| ) {} |
This file contains hidden or 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
| import { Book } from '../entities'; | |
| export class CreateBookResponseDto { | |
| success: boolean; | |
| createdBook: Book; | |
| } |
This file contains hidden or 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
| import { IsString, IsNotEmpty, IsDate } from 'class-validator'; | |
| export class CreateBookDto { | |
| @IsString() | |
| @IsNotEmpty() | |
| title: string; | |
| @IsNotEmpty() | |
| authorId: any; |
This file contains hidden or 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
| import { Injectable } from '@nestjs/common'; | |
| import { Book } from '../../../core/entities'; | |
| import { IDataServices, ICrmServices } from '../../../core/abstracts'; | |
| import { CreateBookDto, UpdateBookDto } from '../../../core/dtos'; | |
| import { BookFactoryService } from './book-factory.service'; | |
| @Injectable() | |
| export class BookServices { | |
| constructor( | |
| private dataServices: IDataServices, |
This file contains hidden or 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
| import { Book } from '../entities'; | |
| export abstract class ICrmServices { | |
| abstract bookAdded(book: Book): Promise<boolean>; | |
| } |
NewerOlder