Skip to content

Commit

Permalink
chore: switch to monorepo setup using turborepo ⚡.
Browse files Browse the repository at this point in the history
  • Loading branch information
ezeikel committed Nov 22, 2024
1 parent 1a4d760 commit d1f7dd7
Show file tree
Hide file tree
Showing 77 changed files with 732 additions and 284 deletions.
65 changes: 33 additions & 32 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
.turbo# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
# Dependencies
node_modules
.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage
# Local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# next.js
/.next/
/out/
# Testing
coverage

# production
/build
# Turbo
.turbo

# Vercel
.vercel

# Build Outputs
.next/
out/
build
dist

# misc
.DS_Store
*.pem

# debug
# Debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel
# Misc
.DS_Store
*.pem

# typescript
*.tsbuildinfo
next-env.d.ts

# Sentry Config File
.sentryclirc
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
# VS Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"eslint.useFlatConfig": true
"eslint.useFlatConfig": true,
"typescript.tsdk": "node_modules/typescript/lib"
}
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Cuurly Web App
# Cuurly

This is the Cuurly web app frontend.
A community platform for all things black and mixed textured hair.

## Apps and Packages

This monorepo uses [Turborepo](https://turbo.build/) and contains:

### Apps

- `web`: Next.js web application
- `admin`: Admin dashboard *(coming soon)*
- `mobile`: React Native app *(coming soon)*

### Packages

- `db`: Prisma client and database utilities
- `eslint-config`: ESLint configurations
- `prettier-config`: Prettier configurations
- `tsconfig`: TypeScript configurations
File renamed without changes.
44 changes: 44 additions & 0 deletions apps/web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# Sentry Config File
.sentryclirc
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
3 changes: 3 additions & 0 deletions apps/web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Cuurly Web App

A community platform for all things black and mixed textured hair, built with Next.js.
4 changes: 2 additions & 2 deletions app/[username]/page.tsx → apps/web/app/[username]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import prisma from "@/lib/prisma";
import { db } from "@cuurly/db";

type ProfilePageProps = {
searchParams: Promise<{
Expand All @@ -11,7 +11,7 @@ const ProfilePage = async ({ searchParams }: ProfilePageProps) => {

if (!username) return null;

const user = await prisma.user.findUnique({
const user = await db.user.findUnique({
where: { username },
select: {
id: true,
Expand Down
File renamed without changes.
28 changes: 14 additions & 14 deletions app/actions.ts → apps/web/app/actions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use server";

import { headers } from "next/headers";
import type { Gender, Prisma, User } from "@prisma/client";
import prisma from "@/lib/prisma";
import type { Prisma, DbGenderType, DbUserType } from "@cuurly/db";
import { db } from "@cuurly/db";
import { auth } from "@/auth";
import processFile from "@/utils/processFile";
import type { GetPost } from "@/types";
Expand All @@ -24,14 +24,14 @@ export const getUserId = async (action?: string) => {
return userId;
};

export const getCurrentUser = async (): Promise<User | null> => {
export const getCurrentUser = async (): Promise<DbUserType | null> => {
const userId = await getUserId("get the current user");

if (!userId) {
return null;
}

return prisma.user.findUnique({
return db.user.findUnique({
where: { id: userId },
});
};
Expand All @@ -51,7 +51,7 @@ export const getCurrentUserLikes = async (): Promise<
const userId = await getUserId("get the current user's likes");
if (!userId) return [];

return prisma.like.findMany({
return db.like.findMany({
where: { userId },
include: {
post: {
Expand All @@ -65,7 +65,7 @@ export const getCurrentUserLikes = async (): Promise<
};

export const getAllUsers = async (query?: string) => {
return prisma.user.findMany({
return db.user.findMany({
where: query
? {
username: {
Expand All @@ -85,7 +85,7 @@ export const getUser = async ({
username?: string;
email?: string;
}) => {
return prisma.user.findUnique({
return db.user.findUnique({
where: { id, username, email },
select: {
id: true,
Expand Down Expand Up @@ -127,7 +127,7 @@ export const getUser = async ({
};

export const getPost = async (id: string): Promise<GetPost | null> => {
return prisma.post.findUnique({
return db.post.findUnique({
where: { id },
select: {
id: true,
Expand Down Expand Up @@ -203,13 +203,13 @@ export const getFeed = async () => {
const userId = await getUserId("get the user's feed");
if (!userId) return null;

const followedUsers = await prisma.user
const followedUsers = await db.user
.findUnique({ where: { id: userId } })
?.following();
const followedUserIds =
followedUsers?.map((user: { id: string }) => user.id) ?? [];

return prisma.post.findMany({
return db.post.findMany({
where: {
author: { id: { in: [...followedUserIds, userId] } },
deletedAt: null,
Expand Down Expand Up @@ -268,13 +268,13 @@ export const getExploreFeed = async () => {

if (!userId) return null;

const following = await prisma.user
const following = await db.user
.findUnique({ where: { id: userId } })
.following();
const followingIds =
following?.map((follower: { id: string }) => follower.id) ?? [];

return prisma.post.findMany({
return db.post.findMany({
where: {
author: { id: { notIn: [...followingIds, userId] } },
},
Expand Down Expand Up @@ -315,14 +315,14 @@ export const updateUser = async ({
updatedProfilePicture = { url, publicId };
}

return prisma.user.update({
return db.user.update({
where: { id: userId },
data: {
name: input.name,
username: input.username,
email: input.email,
phoneNumber: input.phoneNumber,
gender: input.gender as Gender,
gender: input.gender as DbGenderType,
profile: {
update: {
bio: input.bio,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions auth.ts → apps/web/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import NextAuth from "next-auth";
import type { AuthConfig, Account, Profile, Session } from "@auth/core/types";
import GoogleProvider from "next-auth/providers/google";
import type { JWT } from "next-auth/jwt";

import prisma from "./lib/prisma";
import { db } from "@cuurly/db";

// function to generate a random username
const randomUsername = () => Math.random().toString(36).substring(2, 15);
Expand All @@ -27,14 +26,14 @@ const config = {
}) {
if (account?.provider === "google") {
const existingUser = profile?.email
? await prisma.user.findUnique({ where: { email: profile.email } })
? await db.user.findUnique({ where: { email: profile.email } })
: null;

if (existingUser) {
return true;
}

await prisma.user.create({
await db.user.create({
data: {
email: profile?.email as string,
name: profile?.name as string,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import classNames from "classnames";
import useUser from "@/hooks/api/useUser";

type LikeButtonProps = {
// eslint-disable-next-line react/no-unused-prop-types
postId: string;
postLikes: { user: { id: string } }[];
};
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions apps/web/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import eslintConfig from "@cuurly/eslint-config";

export default [...eslintConfig];
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit d1f7dd7

Please sign in to comment.