Yuki Takei hai 1 ano
pai
achega
052c704b5a
Modificáronse 1 ficheiros con 12 adicións e 0 borrados
  1. 12 0
      apps/app/src/server/middlewares/application-not-installed.ts

+ 12 - 0
apps/app/src/server/middlewares/application-not-installed.ts

@@ -3,6 +3,9 @@ import createError, { isHttpError } from 'http-errors';
 
 import type Crowi from '../crowi';
 
+/**
+ * Middleware factory to check if the application is already installed
+ */
 export const generateCheckerMiddleware = (crowi: Crowi) => async(req: Request, res: Response, next: NextFunction): Promise<void> => {
   const { appService } = crowi;
 
@@ -15,10 +18,16 @@ export const generateCheckerMiddleware = (crowi: Crowi) => async(req: Request, r
   return next();
 };
 
+/**
+ * Middleware to return HttpError 409 if the application is already installed
+ */
 export const allreadyInstalledMiddleware = async(req: Request, res: Response, next: NextFunction): Promise<void> => {
   return next(createError(409, 'Application is already installed'));
 };
 
+/**
+ * Error handler to handle errors as API errors
+ */
 export const handleAsApiError = (error: Error, req: Request, res: Response, next: NextFunction): void => {
   if (error == null) {
     return next();
@@ -33,6 +42,9 @@ export const handleAsApiError = (error: Error, req: Request, res: Response, next
   next();
 };
 
+/**
+ * Error handler to redirect to top page on error
+ */
 export const redirectToTopOnError = (error: Error, req: Request, res: Response, next: NextFunction): void => {
   if (error != null) {
     return res.redirect('/');