hotfix-feat(dataset): implement file upload with validation and error handling

- Implemented file upload functionality for datasets using multipart requests.
- Added file size and type validation using VineJS.
- Added file name length validation.
- Added file scan to remove infected files.
- Implemented aggregated upload limit to prevent exceeding the server's capacity.
- Added error handling for file upload failures, including temporary file cleanup.
- Updated the `DatasetController` to handle file uploads, validation, and database transactions.
- Updated the `bodyparser.ts` config to process the file upload manually.
- Updated the `api.ts` routes to fetch the statistic data.
- Updated the `main.ts` store to fetch the statistic data.
- Updated the `Dashboard.vue` to display the submitters only for administrator role.
- Updated the `CardBoxWidget.vue` to display the submitters.
- Updated the `ServerError.vue` to use the LayoutGuest.vue.
- Updated the `AuthController.ts` and `start/routes.ts` to handle the database connection errors.
- Updated the `app/exceptions/handler.ts` to handle the database connection errors.
- Updated the `package.json` to use the correct version of the `@adonisjs/bodyparser`.
This commit is contained in:
Kaimbacher 2025-03-26 14:19:06 +01:00
parent a25f8bf6f7
commit b93e46207f
15 changed files with 637 additions and 200 deletions

View file

@ -106,7 +106,14 @@ router
// Auth routes
router
.get('/app/login', ({ inertia }: HttpContext) => {
.get('/app/login', async({ inertia }: HttpContext) => {
try {
await db.connection().rawQuery('SELECT 1');
} catch (error) {
if (error.code === 'ECONNREFUSED') {
throw error;
}
}
return inertia.render('Auth/Login');
})
.as('app.login.show');
@ -246,18 +253,11 @@ router.get('/settings/user/security', [UserController, 'accountInfo']).as('setti
router.post('/settings/user/store', [UserController, 'accountInfoStore']).as('account.password.store').use(middleware.auth());
router.get('/settings/profile/edit', [UserController, 'profile']).as('settings.profile.edit').use(middleware.auth());
router
.put('/settings/profile/:id/update', [UserController, 'profileUpdate'])
.as('settings.profile.update')
.where('id', router.matchers.number())
.use(middleware.auth());
router
.put('/settings/password/update', [UserController, 'passwordUpdate'])
.as('settings.password.update')
.use(middleware.auth());
.put('/settings/profile/:id/update', [UserController, 'profileUpdate'])
.as('settings.profile.update')
.where('id', router.matchers.number())
.use(middleware.auth());
router.put('/settings/password/update', [UserController, 'passwordUpdate']).as('settings.password.update').use(middleware.auth());
// Submitter routes
router

View file

@ -20,7 +20,7 @@ router
router.get('/dataset/:publish_id', [DatasetController, 'findOne']).as('dataset.findOne');
router.get('/sitelinks/:year', [HomeController, 'findDocumentsPerYear']);
router.get('/years', [HomeController, 'findYears']);
router.get('/statistic/:year', [HomeController, 'findPublicationsPerMonth']);
router.get('/statistic', [HomeController, 'findPublicationsPerMonth']);
router.get('/download/:id', [FileController, 'findOne']).as('file.findOne');