Move next js project to archive (#207)

This commit is contained in:
Aaron Po
2026-04-20 02:30:25 -04:00
committed by GitHub
parent 92ec16ce93
commit d47e3ed7f0
347 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
import DBClient from '@/prisma/DBClient';
import {
CreateBeerPostLike,
FindBeerPostLikeById,
GetBeerPostLikeCount,
RemoveBeerPostLike,
} from './types';
/**
* Creates a new beer post like.
*
* @param params - The parameters object for creating the beer post like.
* @param params.beerPostId - The ID of the beer post.
* @param params.likedById - The ID of the user who will like the beer post.
* @returns A promise that resolves to the newly created beer post like.
*/
export const createBeerPostLikeService: CreateBeerPostLike = async ({
beerPostId,
likedById,
}) =>
DBClient.instance.beerPostLike.create({
data: {
beerPost: { connect: { id: beerPostId } },
likedBy: { connect: { id: likedById } },
},
});
/**
* Retrieves a beer post like by ID.
*
* @param params - The parameters object for retrieving the beer post like.
* @param params.beerPostId - The ID of the beer post.
* @param params.likedById - The ID of the user who liked the beer post.
* @returns A promise that resolves to the beer post like.
*/
export const findBeerPostLikeByIdService: FindBeerPostLikeById = async ({
beerPostId,
likedById,
}) => DBClient.instance.beerPostLike.findFirst({ where: { beerPostId, likedById } });
/**
* Removes a beer post like.
*
* @param params - The parameters object for removing the beer post like.
* @param params.beerPostLikeId - The ID of the beer post like to remove.
* @returns A promise that resolves to the removed beer post like.
*/
export const removeBeerPostLikeService: RemoveBeerPostLike = async ({ beerPostLikeId }) =>
DBClient.instance.beerPostLike.delete({ where: { id: beerPostLikeId } });
/**
* Retrieves the number of likes for a beer post.
*
* @param params - The parameters object for retrieving the number of likes for a beer
* post.
* @param params.beerPostId - The ID of the beer post.
* @returns A promise that resolves to the number of likes for a beer post.
*/
export const getBeerPostLikeCountService: GetBeerPostLikeCount = async ({ beerPostId }) =>
DBClient.instance.beerPostLike.count({ where: { beerPostId } });

View File

@@ -0,0 +1,11 @@
import { z } from 'zod';
const BeerPostLikeSchema = z.object({
id: z.string().cuid(),
beerPostId: z.string().cuid(),
likedById: z.string().cuid(),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date().nullable(),
});
export default BeerPostLikeSchema;

View File

@@ -0,0 +1,23 @@
import GetUserSchema from '@/services/users/auth/schema/GetUserSchema';
import { z } from 'zod';
import BeerPostLikeSchema from '../schema/BeerPostLikeSchema';
type User = z.infer<typeof GetUserSchema>;
type ReturnSchema = z.infer<typeof BeerPostLikeSchema>;
export type CreateBeerPostLike = (args: {
beerPostId: string;
likedById: User['id'];
}) => Promise<ReturnSchema>;
export type FindBeerPostLikeById = (args: {
beerPostId: string;
likedById: User['id'];
}) => Promise<ReturnSchema | null>;
export type RemoveBeerPostLike = (args: {
beerPostLikeId: string;
}) => Promise<ReturnSchema>;
export type GetBeerPostLikeCount = (args: { beerPostId: string }) => Promise<number>;

View File

@@ -0,0 +1,63 @@
import DBClient from '@/prisma/DBClient';
import {
CreateBeerStyleLike,
FindBeerStyleLike,
GetBeerStyleLikeCount,
RemoveBeerStyleLike,
} from './types';
/**
* Creates a new beer style like.
*
* @param params - The parameters object for creating the beer style like.
* @param params.beerStyleId - The ID of the beer style.
* @param params.likedById - The ID of the user who will like the beer style.
* @returns A promise that resolves to the newly created beer style like.
*/
export const createBeerStyleLikeService: CreateBeerStyleLike = async ({
beerStyleId,
likedById,
}) =>
DBClient.instance.beerStyleLike.create({
data: {
beerStyle: { connect: { id: beerStyleId } },
likedBy: { connect: { id: likedById } },
},
});
/**
* Retrieves a beer style like by ID.
*
* @param params - The parameters object for retrieving the beer style like.
* @param params.beerStyleId - The ID of the beer style.
* @param params.likedById - The ID of the user who liked the beer style.
* @returns A promise that resolves to the beer style like.
*/
export const findBeerStyleLikeService: FindBeerStyleLike = async ({
beerStyleId,
likedById,
}) => DBClient.instance.beerStyleLike.findFirst({ where: { beerStyleId, likedById } });
/**
* Removes a beer style like.
*
* @param params - The parameters object for removing the beer style like.
* @param params.beerStyleLikeId - The ID of the beer style like to remove.
* @returns A promise that resolves to the removed beer style like.
*/
export const removeBeerStyleLikeService: RemoveBeerStyleLike = async ({
beerStyleLikeId,
}) => DBClient.instance.beerStyleLike.delete({ where: { id: beerStyleLikeId } });
/**
* Retrieves the number of likes for a beer style.
*
* @param params - The parameters object for retrieving the number of likes for a beer
* style.
* @param params.beerStyleId - The ID of the beer style.
* @returns A promise that resolves to the number of likes for a beer style.
*/
export const getBeerStyleLikeCountService: GetBeerStyleLikeCount = async ({
beerStyleId,
}) => DBClient.instance.beerStyleLike.count({ where: { beerStyleId } });

View File

@@ -0,0 +1,11 @@
import { z } from 'zod';
const BeerStyleLikeSchema = z.object({
id: z.string().cuid(),
beerStyleId: z.string().cuid(),
likedById: z.string().cuid(),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date().nullable(),
});
export default BeerStyleLikeSchema;

View File

@@ -0,0 +1,23 @@
import GetUserSchema from '@/services/users/auth/schema/GetUserSchema';
import { z } from 'zod';
import BeerStyleLikeSchema from '../schema/BeerStyleLikeSchema';
type User = z.infer<typeof GetUserSchema>;
type ReturnSchema = z.infer<typeof BeerStyleLikeSchema>;
export type CreateBeerStyleLike = (args: {
beerStyleId: string;
likedById: User['id'];
}) => Promise<ReturnSchema>;
export type FindBeerStyleLike = (args: {
beerStyleId: string;
likedById: User['id'];
}) => Promise<ReturnSchema | null>;
export type RemoveBeerStyleLike = (args: {
beerStyleLikeId: string;
}) => Promise<ReturnSchema>;
export type GetBeerStyleLikeCount = (args: { beerStyleId: string }) => Promise<number>;

View File

@@ -0,0 +1,63 @@
import DBClient from '@/prisma/DBClient';
import {
CreateBreweryPostLike,
FindBreweryPostLike,
GetBreweryPostLikeCount,
RemoveBreweryPostLike,
} from './types';
/**
* Creates a new brewery post like.
*
* @param params - The parameters object for creating the brewery post like.
* @param params.breweryPostId - The ID of the brewery post.
* @param params.likedById - The ID of the user who will like the brewery post.
* @returns A promise that resolves to the newly created brewery post like.
*/
export const createBreweryPostLikeService: CreateBreweryPostLike = async ({
breweryPostId,
likedById,
}) =>
DBClient.instance.breweryPostLike.create({
data: {
breweryPost: { connect: { id: breweryPostId } },
likedBy: { connect: { id: likedById } },
},
});
/**
* Retrieves a brewery post like by ID.
*
* @param params - The parameters object for retrieving the brewery post like.
* @param params.breweryPostId - The ID of the brewery post.
* @param params.likedById - The ID of the user who liked the brewery post.
* @returns A promise that resolves to the brewery post like.
*/
export const findBreweryPostLikeService: FindBreweryPostLike = async ({
breweryPostId,
likedById,
}) =>
DBClient.instance.breweryPostLike.findFirst({ where: { breweryPostId, likedById } });
/**
* Removes a brewery post like.
*
* @param params - The parameters object for removing the brewery post like.
* @param params.breweryPostLikeId - The ID of the brewery post like to remove.
* @returns A promise that resolves to the removed brewery post like.
*/
export const removeBreweryPostLikeService: RemoveBreweryPostLike = async ({
breweryPostLikeId,
}) => DBClient.instance.breweryPostLike.delete({ where: { id: breweryPostLikeId } });
/**
* Retrieves the number of likes for a brewery post.
*
* @param params - The parameters object for retrieving the number of likes for a brewery
* @param params.breweryPostId - The ID of the brewery post.
* @returns A promise that resolves to the number of likes for a brewery post.
*/
export const getBreweryPostLikeCountService: GetBreweryPostLikeCount = async ({
breweryPostId,
}) => DBClient.instance.breweryPostLike.count({ where: { breweryPostId } });

View File

@@ -0,0 +1,11 @@
import { z } from 'zod';
const BreweryPostLikeSchema = z.object({
id: z.string().cuid(),
breweryPostId: z.string().cuid(),
likedById: z.string().cuid(),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date().nullable(),
});
export default BreweryPostLikeSchema;

View File

@@ -0,0 +1,24 @@
import GetUserSchema from '@/services/users/auth/schema/GetUserSchema';
import { z } from 'zod';
import BreweryPostLikeSchema from '../schema/BreweryPostLikeSchema';
type User = z.infer<typeof GetUserSchema>;
type ReturnSchema = z.infer<typeof BreweryPostLikeSchema>;
export type CreateBreweryPostLike = (args: {
breweryPostId: string;
likedById: User['id'];
}) => Promise<ReturnSchema>;
export type FindBreweryPostLike = (args: {
breweryPostId: string;
likedById: User['id'];
}) => Promise<ReturnSchema | null>;
export type RemoveBreweryPostLike = (args: {
breweryPostLikeId: string;
}) => Promise<ReturnSchema>;
export type GetBreweryPostLikeCount = (args: {
breweryPostId: string;
}) => Promise<number>;