service refactor to namespaces

This commit is contained in:
Michael Dausmann
2024-02-17 10:49:23 +11:00
parent d8f20d9896
commit 23c248a08b
10 changed files with 80 additions and 90 deletions

View File

@@ -1,4 +1,4 @@
import NotesService from '~~/lib/services/notes.service';
import { NotesService } from '~~/lib/services/notes.service';
import {
accountHasSpecialFeature,
adminProcedure,
@@ -11,9 +11,8 @@ import { z } from 'zod';
export const notesRouter = router({
getForActiveAccount: memberProcedure.query(async ({ ctx, input }) => {
const notesService = new NotesService();
const notes = ctx.activeAccountId
? await notesService.getNotesForAccountId(ctx.activeAccountId)
? await NotesService.getNotesForAccountId(ctx.activeAccountId)
: [];
return {
notes
@@ -22,8 +21,7 @@ export const notesRouter = router({
getById: publicProcedure
.input(z.object({ note_id: z.number() }))
.query(async ({ ctx, input }) => {
const notesService = new NotesService();
const note = await notesService.getNoteById(input.note_id);
const note = await NotesService.getNoteById(input.note_id);
return {
note
};
@@ -31,9 +29,8 @@ export const notesRouter = router({
createNote: readWriteProcedure
.input(z.object({ note_text: z.string() }))
.mutation(async ({ ctx, input }) => {
const notesService = new NotesService();
const note = ctx.activeAccountId
? await notesService.createNote(ctx.activeAccountId, input.note_text)
? await NotesService.createNote(ctx.activeAccountId, input.note_text)
: null;
return {
note
@@ -42,9 +39,8 @@ export const notesRouter = router({
deleteNote: adminProcedure
.input(z.object({ note_id: z.number() }))
.mutation(async ({ ctx, input }) => {
const notesService = new NotesService();
const note = ctx.activeAccountId
? await notesService.deleteNote(input.note_id)
? await NotesService.deleteNote(input.note_id)
: null;
return {
note
@@ -54,9 +50,8 @@ export const notesRouter = router({
.use(accountHasSpecialFeature)
.input(z.object({ user_prompt: z.string() }))
.query(async ({ ctx, input }) => {
const notesService = new NotesService();
const noteText = ctx.activeAccountId
? await notesService.generateAINoteFromPrompt(
? await NotesService.generateAINoteFromPrompt(
input.user_prompt,
ctx.activeAccountId
)