feat: add redis (#242)
* feat: add refis * feat: add redis package Co-authored-by: Meier Lukas <meierschlumpf@gmail.com> * feat: add example docker compose, add redis connection in package * fix: usage of client after subscribe * feat: add logger for redis * refactor: format files Co-authored-by: Meier Lukas <meierschlumpf@gmail.com> --------- Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import { createSalt, hashPassword } from "@homarr/auth";
|
||||
import type { Database } from "@homarr/db";
|
||||
import { createId, eq, schema } from "@homarr/db";
|
||||
import { users } from "@homarr/db/schema/sqlite";
|
||||
import { exampleChannel } from "@homarr/redis";
|
||||
import { validation, z } from "@homarr/validation";
|
||||
|
||||
import { createTRPCRouter, publicProcedure } from "../trpc";
|
||||
@@ -106,13 +107,14 @@ export const userRouter = createTRPCRouter({
|
||||
})
|
||||
.where(eq(users.id, input.userId));
|
||||
}),
|
||||
setMessage: publicProcedure.input(z.string()).mutation(async ({ input }) => {
|
||||
await exampleChannel.publish({ message: input });
|
||||
}),
|
||||
test: publicProcedure.subscription(() => {
|
||||
return observable<number>((emit) => {
|
||||
let counter = 0;
|
||||
setInterval(() => {
|
||||
counter = counter + 1;
|
||||
emit.next(counter);
|
||||
}, 1000);
|
||||
return observable<{ message: string }>((emit) => {
|
||||
exampleChannel.subscribe((message) => {
|
||||
emit.next(message);
|
||||
});
|
||||
});
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user