Skip to content

Instantly share code, notes, and snippets.

View dipeshhkc's full-sized avatar
🏠
Working from home

Dipesh KC dipeshhkc

🏠
Working from home
View GitHub Profile
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,
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;
};
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 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")
version: "3.8"
services:
db:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
ports:
- 54322:5432
volumes:
//FailOnError -> handles error
func FailOnError(err error, msg string) {
if err != nil {
log.Fatalf("%s: %s", msg, err)
}
}
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,
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,
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
const (
QUEUE = "queue-1"
USERNAME = "admin"
PASSWORD = "admin"
HOST = "localhost"
PORT = "5672"
TASK1 = "task-1"
TASK2 = "task-2"