Skip to content

Commit

Permalink
feat: improve backend
Browse files Browse the repository at this point in the history
close #57 close #58
  • Loading branch information
pociej committed May 8, 2024
1 parent ad85734 commit 9fdb283
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
4 changes: 4 additions & 0 deletions backend/src/fastify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export const startupFastifyServer = async (): Promise<FastifyInstance> => {
logger: false,
});

fastify.addHook("onRoute", (routeOptions) => {
routeOptions.url = `/api${routeOptions.url}`;
});

fastify.register(fastifySensible);
fastify.register(fastifyMultipart);
fastify.register(FastifySSEPlugin);
Expand Down
3 changes: 0 additions & 3 deletions backend/src/services/user/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ export const userService = fastifyPlugin(
fastify.get("/me", {
onRequest: [fastify.authenticate],
handler: async (request: FastifyRequest, reply) => {
console.log("using mongo uri", container.cradle.connectionString);
const userService = container.cradle.userService;
const requestUser = request.user;
const user = await userService.findById(requestUser._id);

console.log("user", user);
if (!user) {
throw new Error(`User not found with id ${requestUser._id}`);
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/.env.development
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VITE_BACKEND_URL=http://127.0.0.1:5174
VITE_BACKEND_URL=http://127.0.0.1:5174/api
2 changes: 1 addition & 1 deletion frontend/.env.production
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VITE_BACKEND_URL=http://0.0.0.0:5174
VITE_BACKEND_URL=http://0.0.0.0:5174/api
2 changes: 1 addition & 1 deletion frontend/src/hooks/userUserData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const useUserData = (): {
const { data, error, isLoading } = useSWR<UserData>(
`${import.meta.env.VITE_BACKEND_URL}/me`,
fetcher,
{ refreshInterval: 10000 }
{ refreshInterval: 1000 }
);
return {
userData: data,
Expand Down

0 comments on commit 9fdb283

Please sign in to comment.