diff --git a/.gitignore b/.gitignore index 44b6eb2..d1b114d 100644 --- a/.gitignore +++ b/.gitignore @@ -109,3 +109,5 @@ dist # Runtime data /data/**/* !/data/.gitkeep +/static/**/* +!/static/.gitkeep \ No newline at end of file diff --git a/src/misc/constants.ts b/src/misc/constants.ts index a4f8458..0f72f53 100644 --- a/src/misc/constants.ts +++ b/src/misc/constants.ts @@ -2,6 +2,7 @@ import path from 'path' export const PROJECT_ROOT = path.resolve(__dirname, '..', '..') export const DATA_DIR = path.join(PROJECT_ROOT, 'data') +export const STATIC_DIR = path.join(PROJECT_ROOT, 'static') // eslint-disable-next-line @typescript-eslint/no-var-requires export const APP_PACKAGE_JSON = require(path.join(PROJECT_ROOT, 'package.json')) export const APP_VERSION: string = APP_PACKAGE_JSON.version diff --git a/src/web/index.ts b/src/web/index.ts index 5bb9bbb..5537e04 100644 --- a/src/web/index.ts +++ b/src/web/index.ts @@ -1,8 +1,9 @@ import fastify from 'fastify' import fastifySensible from 'fastify-sensible' +import fastifyStatic from 'fastify-static' import { Server } from 'socket.io' import { EntityManager, getManager } from 'typeorm' -import { APP_VERSION } from '../misc/constants' +import { APP_VERSION, STATIC_DIR } from '../misc/constants' import { ENV_IS_DEVELOPMENT } from '../misc/env' import io from './io' import api from './api' @@ -37,6 +38,10 @@ export async function startWebService(): Promise { }) } + await server.register(fastifyStatic, { + root: STATIC_DIR + }) + // Inject manager const manager = getManager() server.decorate('manager', manager) diff --git a/static/.gitkeep b/static/.gitkeep new file mode 100644 index 0000000..e69de29