Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #4

Merged
merged 2 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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