chore: seperate into packages
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
import { documentChunkFilterSchema, documentChunksFindResultSchema } from '@morten-olsen/stash-runtime';
|
||||
import type { FastifyPluginAsyncZod } from 'fastify-type-provider-zod';
|
||||
|
||||
import {
|
||||
documentChunkFilterSchema,
|
||||
documentChunksFindResultSchema,
|
||||
DocumentChunksService,
|
||||
} from '#root/services/document-chunks/document-chunks.js';
|
||||
|
||||
const documentChunkFilterEndpoints: FastifyPluginAsyncZod = async (instance) => {
|
||||
instance.route({
|
||||
method: 'POST',
|
||||
@@ -20,9 +15,8 @@ const documentChunkFilterEndpoints: FastifyPluginAsyncZod = async (instance) =>
|
||||
},
|
||||
},
|
||||
handler: async (req, reply) => {
|
||||
const { services } = instance;
|
||||
const documentChunksService = services.get(DocumentChunksService);
|
||||
const response = await documentChunksService.find(req.body);
|
||||
const { runtime } = instance;
|
||||
const response = await runtime.documentChunks.find(req.body);
|
||||
await reply.send(response);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import { documentFilterSchema, documentFindResultSchema } from '@morten-olsen/stash-runtime';
|
||||
import type { FastifyPluginAsyncZod } from 'fastify-type-provider-zod';
|
||||
|
||||
import {
|
||||
documentFilterSchema,
|
||||
documentFindResultSchema,
|
||||
DocumentsService,
|
||||
} from '#root/services/documents/documents.js';
|
||||
|
||||
const documentFilterEndpoints: FastifyPluginAsyncZod = async (instance) => {
|
||||
instance.route({
|
||||
method: 'POST',
|
||||
@@ -20,9 +15,8 @@ const documentFilterEndpoints: FastifyPluginAsyncZod = async (instance) => {
|
||||
},
|
||||
},
|
||||
handler: async (req, reply) => {
|
||||
const { services } = instance;
|
||||
const documentsService = services.get(DocumentsService);
|
||||
const response = await documentsService.find(req.body);
|
||||
const { runtime } = instance;
|
||||
const response = await runtime.documents.find(req.body);
|
||||
await reply.send(response);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import { documentUpsertResultSchema, documentUpsertSchema } from '@morten-olsen/stash-runtime';
|
||||
import type { FastifyPluginAsyncZod } from 'fastify-type-provider-zod';
|
||||
|
||||
import {
|
||||
DocumentsService,
|
||||
documentUpsertResultSchema,
|
||||
documentUpsertSchema,
|
||||
} from '#root/services/documents/documents.js';
|
||||
|
||||
const documentEndpoints: FastifyPluginAsyncZod = async (instance) => {
|
||||
instance.route({
|
||||
method: 'POST',
|
||||
@@ -20,9 +15,8 @@ const documentEndpoints: FastifyPluginAsyncZod = async (instance) => {
|
||||
},
|
||||
},
|
||||
handler: async (req, reply) => {
|
||||
const { services } = instance;
|
||||
const documentsService = services.get(DocumentsService);
|
||||
const response = await documentsService.upsert(req.body);
|
||||
const { runtime } = instance;
|
||||
const response = await runtime.documents.upsert(req.body);
|
||||
await reply.send(response);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import type { FastifyPluginAsyncZod } from 'fastify-type-provider-zod';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { DatabaseService } from '#root/services/database/database.js';
|
||||
|
||||
const systemEndpoints: FastifyPluginAsyncZod = async (instance) => {
|
||||
instance.route({
|
||||
method: 'GET',
|
||||
@@ -18,9 +16,8 @@ const systemEndpoints: FastifyPluginAsyncZod = async (instance) => {
|
||||
},
|
||||
},
|
||||
handler: async (_, reply) => {
|
||||
const { services } = instance;
|
||||
const databaseService = services.get(DatabaseService);
|
||||
const db = await databaseService.getInstance();
|
||||
const { runtime } = instance;
|
||||
const db = await runtime.database.getInstance();
|
||||
await db.raw('SELECT 1=1');
|
||||
await reply.send({
|
||||
status: 'ok',
|
||||
|
||||
Reference in New Issue
Block a user