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
const { generateApi } = require("swagger-typescript-api"); | |
const path = require("path"); | |
const fs = require("fs"); | |
const output = path.resolve(process.cwd(), "./src/services"); | |
generateApi({ | |
url: "http://localhost:8000/api-json", | |
output, | |
generateClient: true, |
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
package main | |
import ( | |
"encoding/json" | |
"github.com/streadway/amqp" | |
. "gofast/helpers" | |
. "gofast/types" | |
"log" | |
) |
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 Redis from "ioredis"; | |
// Create pub and sub clients | |
const sub = new Redis(); | |
const pub = new Redis(); | |
// Set the queue names | |
const queue = "getHello"; | |
const replyQueue = `${queue}.reply`; |
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 amqp, { Message, Channel } from "amqplib/callback_api"; | |
const handleMessage = (message: Message, channel: Channel) => { | |
// Parse message | |
const content = JSON.parse(message.content.toString()) as IncomingMessage; | |
// Get properties | |
const { replyTo, correlationId } = message.properties; | |
// Reply to message 5 times |
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 { Prisma } from "@prisma/client"; | |
import Redis from "ioredis"; | |
const mutationActions = ["create", "update", "delete", "deleteMany", "updateMany"]; | |
const queryActions = ["findUnique", "findMany", "count"]; | |
const allActions = [...mutationActions, ...queryActions]; | |
export function cacheMiddleware( | |
redis: Redis, | |
cacheDuration = 100 // 100 seconds |