chore: seperate into packages
This commit is contained in:
@@ -9,10 +9,9 @@ import {
|
||||
validatorCompiler,
|
||||
type ZodTypeProvider,
|
||||
} from 'fastify-type-provider-zod';
|
||||
import { StashRuntime } from '@morten-olsen/stash-runtime';
|
||||
|
||||
import { Services } from './utils/utils.services.js';
|
||||
import { systemEndpoints } from './endpoints/system/system.js';
|
||||
import { WarmupService } from './services/warmup/warmup.js';
|
||||
import { documentEndpoints } from './endpoints/documents/documents.js';
|
||||
import { documentFilterEndpoints } from './endpoints/document-filters/document-filters.js';
|
||||
import { documentChunkFilterEndpoints } from './endpoints/document-chunk-filters/document-chunk-filters.js';
|
||||
@@ -26,12 +25,12 @@ class BaseError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
const createApi = async (services: Services = new Services()) => {
|
||||
const createApi = async (runtime: StashRuntime = new StashRuntime()) => {
|
||||
const app = fastify().withTypeProvider<ZodTypeProvider>();
|
||||
app.setValidatorCompiler(validatorCompiler);
|
||||
app.setSerializerCompiler(serializerCompiler);
|
||||
|
||||
app.decorate('services', services);
|
||||
app.decorate('runtime', runtime);
|
||||
|
||||
app.register(fastifyCors);
|
||||
app.register(fastifySwagger, {
|
||||
@@ -92,8 +91,7 @@ const createApi = async (services: Services = new Services()) => {
|
||||
});
|
||||
|
||||
app.addHook('onReady', async () => {
|
||||
const warmupService = app.services.get(WarmupService);
|
||||
await warmupService.ensure();
|
||||
app.runtime.warmup.ensure();
|
||||
});
|
||||
|
||||
await app.register(systemEndpoints, { prefix: '/system' });
|
||||
|
||||
Reference in New Issue
Block a user