Skip to content

Commit

Permalink
fix: memperbaiki eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
reacto11mecha committed Jul 2, 2024
1 parent ef2c7df commit ce538fb
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 19 deletions.
1 change: 0 additions & 1 deletion apps/clients/chooser/src/components/scanner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export function ScannerComponent() {
const participantAttended =
api.clientConsumer.checkParticipantAttended.useMutation({
onSuccess() {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
setQRCode(participantAttended.variables!);
},
});
Expand Down
1 change: 0 additions & 1 deletion apps/clients/chooser/src/context/participant-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export const ParticipantProvider = ({
export const useParticipant = () =>
useContext(ParticipantContext) as IParticipantContext;

// eslint-disable-next-line react/display-name
export const ensureQRIDExist = (Element: React.FC) => () => {
const { qrId } = useParticipant();

Expand Down
2 changes: 1 addition & 1 deletion apps/processor/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AppRouter } from "@sora-vp/api";
import type { inferRouterOutputs } from "@trpc/server";
import { createTRPCProxyClient, httpLink } from "@trpc/client";
import { type inferRouterOutputs } from "@trpc/server";
import superjson from "superjson";

import { env } from "./env";
Expand Down
23 changes: 10 additions & 13 deletions apps/processor/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-misused-promises */
import amqp from "amqplib";
import { z } from "zod";

Expand All @@ -16,18 +19,12 @@ const inputValidator = z.object({

const consumeMessagesFromQueue = async () => {
try {
logger.info("[DB] Connecting to Database...");

await db;

logger.info("[DB] Connected!");

logger.debug(`[MQ] MQ AMQP: ${env.PROCESSOR_AMQP_URL}`);
logger.debug(`[MQ] MQ AMQP: ${env.AMQP_URL}`);
logger.debug(`[TRPC] TRPC URL: ${env.PROCESSOR_API_URL}`);

logger.info("[MQ] Connecting to RabbitMQ instance");

const connection = await amqp.connect(env.PROCESSOR_AMQP_URL);
const connection = await amqp.connect(env.AMQP_URL);
const channel = await connection.createChannel();

const exchange = "vote";
Expand All @@ -40,7 +37,7 @@ const consumeMessagesFromQueue = async () => {

logger.info("[MQ] Connected! Waiting for queue...");

channel.consume(queue, async (msg) => {
await channel.consume(queue, async (msg) => {
if (!msg) {
logger.warn("Consumer has been cancelled or channel has been closed.");
return;
Expand Down Expand Up @@ -103,8 +100,8 @@ const consumeMessagesFromQueue = async () => {

const participantContainer = participantRawQuery.at(0) as unknown as {
name: string;
already_attended: boolean;
already_choosing: boolean;
already_attended: number;
already_choosing: number;
qr_id: string;
sub_part: string;
}[];
Expand Down Expand Up @@ -170,7 +167,7 @@ const consumeMessagesFromQueue = async () => {

const candidate = candidateContainer.at(0);

if (candidate!.candidate_must_one !== 1) {
if (candidate?.candidate_must_one !== 1) {
channel.sendToQueue(
msg.properties.replyTo,
Buffer.from(
Expand Down Expand Up @@ -229,4 +226,4 @@ const consumeMessagesFromQueue = async () => {
}
};

consumeMessagesFromQueue();
void consumeMessagesFromQueue();
6 changes: 4 additions & 2 deletions apps/processor/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ export const canVoteNow = (settings: TSettings) => {
const currentTime = new Date().getTime();

const canVote =
(waktuMulai as number) <= currentTime &&
(waktuSelesai as number) >= currentTime &&
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
waktuMulai! <= currentTime &&
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
waktuSelesai! >= currentTime &&
settings.canVote;

return canVote;
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/router/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const clientRouter = {
if (!messageFromQueue.success)
throw new TRPCError({
code: "BAD_REQUEST",
message: messageFromQueue.message as string,
message: messageFromQueue.message!,
});

return { message: "Berhasil memilih kandidat!" };
Expand Down

0 comments on commit ce538fb

Please sign in to comment.