Skip to content

Commit

Permalink
query-repeat
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpolman committed Jun 12, 2024
1 parent 84f7e3b commit 31bddec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { TwitterQuery as TwitterQueryParser } from '@thxnetwork/common/twitter';
import { BadRequestError } from '@thxnetwork/api/util/errors';
import TwitterQueryService from '@thxnetwork/api/services/TwitterQueryService';

const validation = [param('id').isMongoId(), body('operators').customSanitizer((ops) => TwitterQueryParser.parse(ops))];
const validation = [
param('id').isMongoId(),
body('frequencyInHours').isInt(),
body('operators').customSanitizer((ops) => TwitterQueryParser.parse(ops)),
];

const controller = async (req: Request, res: Response) => {
const query = TwitterQueryParser.create(req.body.operators);
Expand All @@ -17,6 +21,7 @@ const controller = async (req: Request, res: Response) => {

const twitterQuery = await TwitterQuery.create({
poolId: req.params.id,
frequencyInHours: req.body.frequencyInHours,
operators: req.body.operators,
defaults: req.body.defaults,
query,
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/app/models/TwitterQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const TwitterQuery = mongoose.model<TwitterQueryDocument>(
{
poolId: String,
query: String,
frequencyInHours: Number,
operators: {
from: [String],
to: [String],
Expand Down
1 change: 1 addition & 0 deletions libs/common/src/lib/types/Twitter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ type TTwitterQuery = {
createdAt: Date;
poolId: string;
query: string;
frequencyInHours: number;
posts: TTwitterPost[];
operators: TTwitterOperators;
defaults: {
Expand Down

0 comments on commit 31bddec

Please sign in to comment.