mirror of
https://github.com/immich-app/immich.git
synced 2025-12-20 09:15:35 +03:00
feat(web)!: SPA (#5069)
* feat(web): SPA * chore: remove unnecessary prune * feat(web): merge with immich-server * Correct method name * fix: bugs, docs, workflows, etc. * chore: keep dockerignore for dev * chore: remove license * fix: expose 2283 --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
SwaggerDocumentOptions,
|
||||
SwaggerModule,
|
||||
} from '@nestjs/swagger';
|
||||
import { NextFunction, Request, Response } from 'express';
|
||||
import { writeFileSync } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
@@ -56,6 +57,12 @@ const patchOpenAPI = (document: OpenAPIObject) => {
|
||||
document.components.schemas = sortKeys(document.components.schemas);
|
||||
}
|
||||
|
||||
for (const [key, value] of Object.entries(document.paths)) {
|
||||
const newKey = key.replace('/api/', '/');
|
||||
delete document.paths[key];
|
||||
document.paths[newKey] = value;
|
||||
}
|
||||
|
||||
for (const path of Object.values(document.paths)) {
|
||||
const operations = {
|
||||
get: path.get,
|
||||
@@ -94,6 +101,14 @@ const patchOpenAPI = (document: OpenAPIObject) => {
|
||||
return document;
|
||||
};
|
||||
|
||||
export const indexFallback = (excludePaths: string[]) => (req: Request, res: Response, next: NextFunction) => {
|
||||
if (req.url.startsWith('/api') || req.method.toLowerCase() !== 'get' || excludePaths.indexOf(req.url) !== -1) {
|
||||
next();
|
||||
} else {
|
||||
res.sendFile('/www/index.html', { root: process.cwd() });
|
||||
}
|
||||
};
|
||||
|
||||
export const useSwagger = (app: INestApplication, isDev: boolean) => {
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle('Immich')
|
||||
|
||||
Reference in New Issue
Block a user