parent
540a2de74b
commit
a586a0fbc7
@ -1,22 +0,0 @@ |
|||||||
import { Test, TestingModule } from '@nestjs/testing'; |
|
||||||
import { HelloWorldController } from './controller'; |
|
||||||
import { HelloWorldService } from './service'; |
|
||||||
|
|
||||||
describe('HelloWorldController', () => { |
|
||||||
let helloWorldController: HelloWorldController; |
|
||||||
|
|
||||||
beforeEach(async () => { |
|
||||||
const app: TestingModule = await Test.createTestingModule({ |
|
||||||
controllers: [HelloWorldController], |
|
||||||
providers: [HelloWorldService], |
|
||||||
}).compile(); |
|
||||||
|
|
||||||
helloWorldController = app.get<HelloWorldController>(HelloWorldController); |
|
||||||
}); |
|
||||||
|
|
||||||
describe('root', () => { |
|
||||||
it('should return "Hello World!"', () => { |
|
||||||
expect(helloWorldController.getHello()).toBe('Hello World!'); |
|
||||||
}); |
|
||||||
}); |
|
||||||
}); |
|
@ -1,12 +0,0 @@ |
|||||||
import { Controller, Get } from '@nestjs/common'; |
|
||||||
import { HelloWorldService } from './service'; |
|
||||||
|
|
||||||
@Controller('hello-world') |
|
||||||
export class HelloWorldController { |
|
||||||
constructor(private readonly helloWorldService: HelloWorldService) {} |
|
||||||
|
|
||||||
@Get() |
|
||||||
getHello(): string { |
|
||||||
return this.helloWorldService.getHello(); |
|
||||||
} |
|
||||||
} |
|
@ -1,8 +0,0 @@ |
|||||||
import { Injectable } from '@nestjs/common'; |
|
||||||
|
|
||||||
@Injectable() |
|
||||||
export class HelloWorldService { |
|
||||||
getHello(): string { |
|
||||||
return 'Hello World!'; |
|
||||||
} |
|
||||||
} |
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
@ -1,12 +1,24 @@ |
|||||||
import { Process, Processor } from '@nestjs/bull'; |
import { Process, Processor } from '@nestjs/bull'; |
||||||
import { Injectable } from '@nestjs/common'; |
import { Injectable } from '@nestjs/common'; |
||||||
|
import { ScreenshotterService } from './screenshotter.service'; |
||||||
import { QUEUE_NAME, ScreenshotJob } from './shared'; |
import { QUEUE_NAME, ScreenshotJob } from './shared'; |
||||||
|
|
||||||
@Injectable() |
@Injectable() |
||||||
@Processor(QUEUE_NAME) |
@Processor(QUEUE_NAME) |
||||||
export class ScreenshotsProcessor { |
export class ScreenshotsProcessor { |
||||||
|
constructor(private readonly screenshotterService: ScreenshotterService) {} |
||||||
|
|
||||||
@Process() |
@Process() |
||||||
async handleScreenshotJob(job: ScreenshotJob) { |
async handleScreenshotJob(job: ScreenshotJob) { |
||||||
job.moveToCompleted('abc') |
try { |
||||||
|
const imageData = await this.screenshotterService.takeScreenshot({ |
||||||
|
url: job.data.pageUrl, |
||||||
|
imageType: job.data.imageType, |
||||||
|
}) |
||||||
|
|
||||||
|
job.moveToCompleted(imageData.toString('base64')) |
||||||
|
} catch(err) { |
||||||
|
job.moveToFailed({ message: JSON.stringify(err) }) |
||||||
|
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue