feat: Convert ts files to js files for controllers
This commit is contained in:
@@ -1,11 +1,9 @@
|
|||||||
import { Response } from 'express';
|
|
||||||
import { IJSONObject, IRequest } from '@automatisch/types';
|
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import { serialize } from 'php-serialize';
|
import { serialize } from 'php-serialize';
|
||||||
import Billing from '../../helpers/billing/index.ee';
|
import Billing from '../../helpers/billing/index.ee';
|
||||||
import appConfig from '../../config/app';
|
import appConfig from '../../config/app';
|
||||||
|
|
||||||
export default async (request: IRequest, response: Response) => {
|
export default async (request, response) => {
|
||||||
if (!verifyWebhook(request)) {
|
if (!verifyWebhook(request)) {
|
||||||
return response.sendStatus(401);
|
return response.sendStatus(401);
|
||||||
}
|
}
|
||||||
@@ -23,14 +21,14 @@ export default async (request: IRequest, response: Response) => {
|
|||||||
return response.sendStatus(200);
|
return response.sendStatus(200);
|
||||||
};
|
};
|
||||||
|
|
||||||
const verifyWebhook = (request: IRequest) => {
|
const verifyWebhook = (request) => {
|
||||||
const signature = request.body.p_signature;
|
const signature = request.body.p_signature;
|
||||||
|
|
||||||
const keys = Object.keys(request.body)
|
const keys = Object.keys(request.body)
|
||||||
.filter((key) => key !== 'p_signature')
|
.filter((key) => key !== 'p_signature')
|
||||||
.sort();
|
.sort();
|
||||||
|
|
||||||
const sorted: IJSONObject = {};
|
const sorted = {};
|
||||||
keys.forEach((key) => {
|
keys.forEach((key) => {
|
||||||
sorted[key] = request.body[key];
|
sorted[key] = request.body[key];
|
||||||
});
|
});
|
@@ -1,12 +1,10 @@
|
|||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { Response } from 'express';
|
|
||||||
import { IRequest } from '@automatisch/types';
|
|
||||||
|
|
||||||
import Connection from '../../models/connection';
|
import Connection from '../../models/connection';
|
||||||
import logger from '../../helpers/logger';
|
import logger from '../../helpers/logger';
|
||||||
import handler from '../../helpers/webhook-handler';
|
import handler from '../../helpers/webhook-handler';
|
||||||
|
|
||||||
export default async (request: IRequest, response: Response) => {
|
export default async (request, response) => {
|
||||||
const computedRequestPayload = {
|
const computedRequestPayload = {
|
||||||
headers: request.headers,
|
headers: request.headers,
|
||||||
body: request.body,
|
body: request.body,
|
||||||
@@ -22,7 +20,7 @@ export default async (request: IRequest, response: Response) => {
|
|||||||
.findById(connectionId)
|
.findById(connectionId)
|
||||||
.throwIfNotFound();
|
.throwIfNotFound();
|
||||||
|
|
||||||
if (!await connection.verifyWebhook(request)) {
|
if (!(await connection.verifyWebhook(request))) {
|
||||||
return response.sendStatus(401);
|
return response.sendStatus(401);
|
||||||
}
|
}
|
||||||
|
|
@@ -1,11 +1,8 @@
|
|||||||
import { Response } from 'express';
|
|
||||||
import { IRequest } from '@automatisch/types';
|
|
||||||
|
|
||||||
import Flow from '../../models/flow';
|
import Flow from '../../models/flow';
|
||||||
import logger from '../../helpers/logger';
|
import logger from '../../helpers/logger';
|
||||||
import handler from '../../helpers/webhook-handler';
|
import handler from '../../helpers/webhook-handler';
|
||||||
|
|
||||||
export default async (request: IRequest, response: Response) => {
|
export default async (request, response) => {
|
||||||
const computedRequestPayload = {
|
const computedRequestPayload = {
|
||||||
headers: request.headers,
|
headers: request.headers,
|
||||||
body: request.body,
|
body: request.body,
|
Reference in New Issue
Block a user