This file contains 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
{ | |
"$schema": "http://json-schema.org/draft-07/schema#", | |
"$id": "http://fintrac-canafe.gc.ca/reporting-gen2/api/str/v1/schema#", | |
"title": "Suspicious Transaction Report Schema", | |
"type": "object", | |
"additionalProperties": false, | |
"properties": { | |
"reportDetails": { | |
"type": "object", | |
"minItems": 1, |
This file contains 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
/* eslint-disable prefer-destructuring */ | |
const { promisify } = require("util"); | |
function scanRedis(pattern) { | |
const scan = promisify(redisClient.scan).bind(redisClient); | |
const result = []; | |
let cursor = "0"; | |
do { | |
// eslint-disable-next-line no-await-in-loop |
This file contains 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
const express = require('express') | |
const app = express() | |
app.use(express.json()) | |
// Ideally, roles should be stored in your database (as a table or collection) | |
const roles = [ | |
{ | |
id: 1, |
This file contains 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
const express = require('express') | |
const redis = require('redis') | |
const app = express() | |
app.use(express.json()) | |
const redisClient = redis.createClient({ | |
legacyMode: true, | |
url: 'your-redis-url-from-redis-cloud' | |
}) |
This file contains 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
const express = require('express'); | |
const redis = require('redis'); | |
const rateLimit = require('express-rate-limit'); | |
const RedisStore = require('rate-limit-redis'); | |
const app = express() | |
const redisClient = redis.createClient({ legacyMode: true }) | |
redisClient.connect() | |
redisClient.on("ready", () => console.log("Successfully connected to redis")); |
This file contains 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
const express = require('express') | |
const session = require('express-session') | |
const redis = require('redis') | |
const RedisStore = require('connect-redis')(session); | |
const uuid = require("uid-safe"); | |
const app = express() | |
const redisClient = redis.createClient({ legacyMode: true, url: 'your-redis-url-from-redis-cloud' }) | |
redisClient.connect() |
This file contains 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
async function checkIfEmailExist(request, response) { | |
const email = request.body.email; | |
/** | |
** We want to get users with the email specified in the request. | |
*/ | |
const user = await UserModel.find({ email: email }) | |
return response.json(user) | |
} |
This file contains 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
curl https://api.paystack.co/plan | |
-H "Authorization: Bearer YOUR_SECRET_KEY" | |
-H "Content-Type: application/json" | |
-d '{ "name": "Monthly Retainer", | |
"interval": "monthly", | |
"amount": 500000 | |
}' | |
-X POST |
This file contains 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
const amqp = require("amqplib"); | |
const dayjs = require("dayjs"); | |
const DELAY_EXCHANGE = "my-delay-exchange"; | |
const routingKey = "myapp.message.post"; | |
const queueName = "message-queue"; | |
// Connects to RabbitMQ | |
async function connectToRabbitMQ() { | |
const conn = await amqp.connect(process.env.RABBITMQ_CONN_STRING); |
This file contains 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
const DELAY_EXCHANGE_NAME = "my_delay_exchange"; | |
const options = { | |
autoDelete: false, | |
durable: true, | |
passive: true, | |
arguments: { | |
"x-delayed-type": "direct", | |
}, | |
}; | |
NewerOlder