Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into develop
  • Loading branch information
AbdulAhadArain committed Feb 1, 2023
2 parents 9e57abc + f960a59 commit 0e4f93d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
PORT=3000
MONGODB_URL=mongodb://127.0.0.1:27017/multiswap-node
QUEUE=Transaction
GATEWAY_BACKEND_URL=
GATEWAY_BACKEND_URL=https://api-leaderboard.dev.svcs.ferrumnetwork.io
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Redis Version `v7.0.8`

Run the Redis Server in your machine by using `redis-server` command

Run this command `cp .env.example .env` to create .env file

Run `yarn` OR `yarn install` at the root of the repo

Run `yarn dev` to run Server
7 changes: 6 additions & 1 deletion src/services/job.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { JobRequestBody } from '../interfaces';
import dotenv from 'dotenv';
dotenv.config();

const queue = new Queue(process.env.QUEUE as string);
const queue = new Queue(process.env.QUEUE as string, {
connection: {
host: process.env.REDIS_HOST as string,
port: Number(process.env.REDIS_PORT) as number,
},
});

export const addJobs = async (jobBody: JobRequestBody): Promise<Job> => {
const job = await queue.add(jobBody.name, jobBody);
Expand Down
6 changes: 6 additions & 0 deletions src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ const worker = new Worker(
process.env.QUEUE as string,
async job =>
await web3Service.getTransactionReceipt(job.data.txId, job.data.rpcURL),
{
connection: {
host: process.env.REDIS_HOST as string,
port: Number(process.env.REDIS_PORT) as number,
},
},
);
worker.on('completed', async job => {
console.info(`${job.id} has completed!`);
Expand Down

0 comments on commit 0e4f93d

Please sign in to comment.