Skip to content

Commit

Permalink
remove hoisting --- poooooggeers
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusmarminge committed Nov 23, 2024
1 parent 507fa5f commit 2c0fa8c
Show file tree
Hide file tree
Showing 12 changed files with 287 additions and 431 deletions.
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
node-linker=hoisted
link-workspace-packages=true
4 changes: 2 additions & 2 deletions apps/expo/src/utils/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export const signIn = async () => {
};

export const useUser = () => {
const { data: session } = api.auth.getSession.useQuery();
return session?.user ?? null;
const { data: user } = api.auth.getSession.useQuery();
return user;
};

export const useSignIn = () => {
Expand Down
1 change: 0 additions & 1 deletion apps/expo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"~/*": ["./src/*"]
},
"jsx": "react-native",
"types": ["nativewind/types"],
"checkJs": false,
"moduleSuffixes": [".ios", ".android", ".native", ""]
},
Expand Down
9 changes: 8 additions & 1 deletion packages/api/src/router/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ import { protectedProcedure, publicProcedure } from "../trpc";

export const authRouter = {
getSession: publicProcedure.query(({ ctx }) => {
return ctx.session;
const user = ctx.session?.user;
if (!user) return null;

return {
id: user.id,
name: user.name ?? null,
image: user.image ?? null,
};
}),
getSecretMessage: protectedProcedure.query(() => {
return "you can see this secret message!";
Expand Down
12 changes: 7 additions & 5 deletions packages/api/src/router/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ export const postRouter = {

create: protectedProcedure
.input(CreatePostSchema)
.mutation(({ ctx, input }) => {
return ctx.db.insert(Post).values(input);
.mutation(async ({ ctx, input }) => {
await ctx.db.insert(Post).values(input);
}),

delete: protectedProcedure.input(z.string()).mutation(({ ctx, input }) => {
return ctx.db.delete(Post).where(eq(Post.id, input));
}),
delete: protectedProcedure
.input(z.string())
.mutation(async ({ ctx, input }) => {
await ctx.db.delete(Post).where(eq(Post.id, input));
}),
} satisfies TRPCRouterRecord;
1 change: 1 addition & 0 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@acme/eslint-config": "workspace:*",
"@acme/prettier-config": "workspace:*",
"@acme/tsconfig": "workspace:*",
"@types/react": "catalog:react18",
"eslint": "catalog:",
"prettier": "catalog:",
"typescript": "catalog:"
Expand Down
1 change: 1 addition & 0 deletions packages/auth/src/index.rsc.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// <reference types="react/canary" />
import { cache } from "react";
import NextAuth from "next-auth";

Expand Down
Loading

0 comments on commit 2c0fa8c

Please sign in to comment.