Refactor code to remove unused imports and routes

This commit is contained in:
Simon Larsen 2024-04-26 14:30:17 +01:00
parent caf3377cee
commit a71190493a
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
2 changed files with 36 additions and 44 deletions

View File

@ -17,7 +17,6 @@ import HTTPResponse from 'Common/Types/API/HTTPResponse';
import HTTPErrorResponse from 'Common/Types/API/HTTPErrorResponse';
import { StaticPath, ViewsPath } from './Utils/Config';
import NotFoundUtil from './Utils/NotFound';
import ServerErrorUtil from './Utils/ServerError';
// improt API
import './API/BlogAPI';
@ -1064,13 +1063,6 @@ const HomeFeatureSet: FeatureSet = {
app.get('/*', (_req: ExpressRequest, res: ExpressResponse) => {
return NotFoundUtil.renderNotFound(res);
});
app.get(
'/server-error',
(_req: ExpressRequest, res: ExpressResponse) => {
return ServerErrorUtil.renderServerError(res);
}
);
},
};

View File

@ -198,6 +198,42 @@ const init: InitFunction = async (
});
}
return app;
};
const addDefaultRoutes: PromiseVoidFunction = async (): Promise<void> => {
app.post('*', (req: ExpressRequest, res: ExpressResponse) => {
return Response.sendErrorResponse(
req,
res,
new NotFoundException('Not found')
);
});
app.put('*', (req: ExpressRequest, res: ExpressResponse) => {
return Response.sendErrorResponse(
req,
res,
new NotFoundException('Not found')
);
});
app.delete('*', (req: ExpressRequest, res: ExpressResponse) => {
return Response.sendErrorResponse(
req,
res,
new NotFoundException('Not found')
);
});
app.get('*', (req: ExpressRequest, res: ExpressResponse) => {
return Response.sendErrorResponse(
req,
res,
new NotFoundException('Not found')
);
});
// Attach Error Handler.
app.use(
(
@ -252,42 +288,6 @@ const init: InitFunction = async (
}
}
);
return app;
};
const addDefaultRoutes: PromiseVoidFunction = async (): Promise<void> => {
app.post('*', (req: ExpressRequest, res: ExpressResponse) => {
return Response.sendErrorResponse(
req,
res,
new NotFoundException('Not found')
);
});
app.put('*', (req: ExpressRequest, res: ExpressResponse) => {
return Response.sendErrorResponse(
req,
res,
new NotFoundException('Not found')
);
});
app.delete('*', (req: ExpressRequest, res: ExpressResponse) => {
return Response.sendErrorResponse(
req,
res,
new NotFoundException('Not found')
);
});
app.get('*', (req: ExpressRequest, res: ExpressResponse) => {
return Response.sendErrorResponse(
req,
res,
new NotFoundException('Not found')
);
});
};
export default { init, addDefaultRoutes };