Last active
January 4, 2023 16:21
-
-
Save benjaminudoh10/ac2f9367a0f297c5987e1c1bded8a361 to your computer and use it in GitHub Desktop.
Bullqueue blog - Add endpoint for processing payment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import express, { Request, Response } from 'express'; | |
const app = express(); | |
... | |
app.post('/process-payment', (request: Request, response: Response) => { | |
const { cardNumber, cvv, cardExpiry } = request.body; | |
const queue = new QueueService().getQueue(Queues.DEFAULT); | |
// add job to queue | |
queue.add(JobType.PROCESS_PAYMENT, { cardNumber, cvv, cardExpiry }); | |
return response | |
.status(200) | |
.json({ | |
message: 'Card charge in progress, you will be notified once complete', | |
}) | |
.end(); | |
}); | |
export { app }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment