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 Stripe from 'stripe'; | |
import { UserWithSubscription } from './user.server'; | |
export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, { | |
apiVersion: '2022-11-15', | |
}); | |
export const stripeCheckout = async ({ | |
priceId, |
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 { Subscription, User } from '.prisma/client'; | |
import { isBefore } from 'date-fns'; | |
import { db } from './db.server'; | |
import { USER_STATUS } from './types/user'; | |
export type UserWithSubscription = User & { | |
subscription: Subscription | null; | |
status: USER_STATUS; | |
}; |
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 { PrismaClient } from '@prisma/client'; | |
const db = new PrismaClient(); | |
import { add } from 'date-fns'; | |
async function seed() { | |
await Promise.all( | |
getUsers().map((user) => { | |
return db.user.create({ data: user }); | |
}) | |
); |
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
// This is your Prisma schema file, | |
// learn more about it in the docs: https://pris.ly/d/prisma-schema | |
generator client { | |
provider = "prisma-client-js" | |
} | |
datasource db { | |
provider = "postgresql" | |
url = env("DATABASE_URL") |
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
version: "3.8" | |
services: | |
db: | |
image: postgres | |
restart: always | |
environment: | |
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} | |
ports: | |
- 54322:5432 | |
volumes: |
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
//FailOnError -> handles error | |
func FailOnError(err error, msg string) { | |
if err != nil { | |
log.Fatalf("%s: %s", msg, err) | |
} | |
} |
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
func Task2Controller(c *gin.Context) { | |
ch := lib.RabbitChannel | |
err := ch.Publish( | |
"", // exchange | |
constants.QUEUE, // routing key | |
false, // mandatory | |
false, // immediate | |
amqp.Publishing{ | |
ContentType: "text/plain", | |
Body: nil, |
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
func Task1Controller(c *gin.Context) { | |
ch := lib.RabbitChannel | |
err := ch.Publish( | |
"", // exchange | |
constants.QUEUE, // routing key | |
false, // mandatory | |
false, // immediate | |
amqp.Publishing{ | |
ContentType: "text/plain", | |
Body: nil, |
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
func main() { | |
connection, channel := lib.SetupRabbbitMQConnectionChannel() | |
defer connection.Close() | |
defer channel.Close() | |
requestQueue, err := channel.QueueDeclare( | |
constants.QUEUE, // name | |
true, // durable | |
false, // delete when unused |
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 ( | |
QUEUE = "queue-1" | |
USERNAME = "admin" | |
PASSWORD = "admin" | |
HOST = "localhost" | |
PORT = "5672" | |
TASK1 = "task-1" | |
TASK2 = "task-2" |