Skip to content

Commit

Permalink
fix response
Browse files Browse the repository at this point in the history
  • Loading branch information
jhowbhz committed Sep 22, 2023
1 parent 3238278 commit 10c3a13
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/controllers/PAController.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import utils from '../utils/utils';
import validation from '../validations/validation';
import puppeteer from "puppeteer";
import { Request, Response } from 'express';

import * as Captcha from '2captcha-ts';
import { Request, Response } from 'express';
class Pa {

index = async (req: Request, res: Response) => {
Expand All @@ -13,19 +12,24 @@ class Pa {
const webhook = req.body.webhook as string;
const twocaptchaapikey = req.body.twocaptchaapikey as string;

if(!twocaptchaapikey){
return res.status(400).json({ message: 'Informe a chave da API do 2captcha para esse DETRAN, pois o mesmo possui captcha.' });
}

const errors = validation.generic(placa, renavam);

if (errors) {
return res.status(400).json(errors);
}

const multas = await this.scrap(placa, renavam, twocaptchaapikey, webhook);

res.status(200).json(multas);
if(!twocaptchaapikey){
return res.status(400).json({ message: 'Informe a chave da API do 2captcha para esse DETRAN, pois o mesmo possui captcha.' });
}

await this.scrap(placa, renavam, twocaptchaapikey, webhook);

res.status(200).json({
placa,
renavam,
message: 'As multas serão enviadas para o webhook',
webhook: webhook
});

}

Expand Down
1 change: 1 addition & 0 deletions src/controllers/PIController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Pi {
const twocaptchaapikey = req.body.twocaptchaapikey as string;

const errors = validation.generic(placa, renavam);

if (errors) {
return res.status(400).json(errors);
}
Expand Down

0 comments on commit 10c3a13

Please sign in to comment.