diff --git a/config.d.ts b/config.d.ts index 4da50fb..6ca0f2a 100644 --- a/config.d.ts +++ b/config.d.ts @@ -223,6 +223,7 @@ export interface AiWarpConfig { }[]; }; module?: string; + showAiWarpHomepage?: boolean; aiProvider: | { openai: { diff --git a/index.ts b/index.ts index b5ca864..771657e 100644 --- a/index.ts +++ b/index.ts @@ -1,6 +1,8 @@ +import { join } from 'node:path' import { platformaticService, Stackable } from '@platformatic/service' import fastifyUser from 'fastify-user' import fastifyPlugin from 'fastify-plugin' +import fastifyStatic from '@fastify/static' import { schema } from './lib/schema.js' import { Generator } from './lib/generator.js' import { AiWarpConfig } from './config.js' @@ -19,6 +21,12 @@ const stackable: Stackable = async function (fastify, opts) { await fastify.register(rateLimitPlugin, opts) await fastify.register(apiPlugin, opts) + if (config.showAiWarpHomepage !== undefined && config.showAiWarpHomepage) { + await fastify.register(fastifyStatic, { + root: join(import.meta.dirname, 'static') + }) + } + await fastify.register(platformaticService, opts) } diff --git a/lib/schema.ts b/lib/schema.ts index 5baa543..faf8021 100644 --- a/lib/schema.ts +++ b/lib/schema.ts @@ -7,6 +7,10 @@ const aiWarpSchema = { properties: { ...schema.schema.properties, module: { type: 'string' }, + showAiWarpHomepage: { + type: 'boolean', + default: true + }, aiProvider: { type: 'object', oneOf: [ diff --git a/package-lock.json b/package-lock.json index 8e42471..9efcbaf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "@azure/openai": "^1.0.0-beta.12", "@fastify/error": "^3.4.1", "@fastify/rate-limit": "^9.1.0", + "@fastify/static": "^7.0.3", "@fastify/type-provider-typebox": "^4.0.0", "@platformatic/config": "^1.24.0", "@platformatic/generators": "^1.24.0", @@ -565,9 +566,9 @@ } }, "node_modules/@fastify/static": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/@fastify/static/-/static-7.0.1.tgz", - "integrity": "sha512-i1p/nELMknAisNfnjo7yhfoUOdKzA+n92QaMirv2NkZrJ1Wl12v2nyTYlDwPN8XoStMBAnRK/Kx6zKmfrXUPXw==", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/@fastify/static/-/static-7.0.3.tgz", + "integrity": "sha512-2tmTdF+uFCykasutaO6k4/wOt7eXyi7m3dGuCPo5micXzv0qt6ttb/nWnDYL/BlXjYGfp1JI4a1gyluTIylvQA==", "dependencies": { "@fastify/accept-negotiator": "^1.0.0", "@fastify/send": "^2.0.0", diff --git a/package.json b/package.json index 0c33a12..1e1f47e 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "start-ai-warp": "./dist/cli/start.js" }, "scripts": { - "build": "tsc --build", + "build": "tsc --build && cp -r ./static ./dist/", "build:config": "node ./dist/lib/schema.js --dump-schema | json2ts > config.d.ts", "clean": "rm -fr ./dist", "lint": "ts-standard | snazzy", @@ -38,6 +38,7 @@ "@azure/openai": "^1.0.0-beta.12", "@fastify/error": "^3.4.1", "@fastify/rate-limit": "^9.1.0", + "@fastify/static": "^7.0.3", "@fastify/type-provider-typebox": "^4.0.0", "@platformatic/config": "^1.24.0", "@platformatic/generators": "^1.24.0", diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..f967d67 --- /dev/null +++ b/static/index.html @@ -0,0 +1,88 @@ + + + + + + AI Warp + + +
+ + + +
+ +

+ + + +