refactor(server): build resources (#10958)

This commit is contained in:
Jason Rasmussen 2024-07-08 14:53:18 -04:00 committed by GitHub
parent 04d0f575b7
commit 5f25e2ce82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 38 additions and 25 deletions

View file

@ -2,8 +2,7 @@ import { Inject, Injectable } from '@nestjs/common';
import { Cron, CronExpression, Interval } from '@nestjs/schedule';
import { NextFunction, Request, Response } from 'express';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { ONE_HOUR, WEB_ROOT } from 'src/constants';
import { ONE_HOUR, resourcePaths } from 'src/constants';
import { ILoggerRepository } from 'src/interfaces/logger.interface';
import { AuthService } from 'src/services/auth.service';
import { JobService } from 'src/services/job.service';
@ -56,9 +55,9 @@ export class ApiService {
ssr(excludePaths: string[]) {
let index = '';
try {
index = readFileSync(join(WEB_ROOT, 'index.html')).toString();
index = readFileSync(resourcePaths.web.indexHtml).toString();
} catch {
this.logger.warn('Unable to open `www/index.html, skipping SSR.');
this.logger.warn(`Unable to open ${resourcePaths.web.indexHtml}, skipping SSR.`);
}
return async (request: Request, res: Response, next: NextFunction) => {