2023-03-03 15:54:28 +00:00
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Routes
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| This file is dedicated for defining HTTP routes. A single file is enough
|
|
|
|
| for majority of projects, however you can define routes in different
|
|
|
|
| files and just make sure to import them inside this file. For example
|
|
|
|
|
|
|
|
|
| Define routes in following two files
|
|
|
|
| ├── start/routes/cart.ts
|
|
|
|
| ├── start/routes/customer.ts
|
|
|
|
|
|
|
|
|
| and then import them inside `start/routes.ts` as follows
|
|
|
|
|
|
|
|
|
| import './routes/cart'
|
|
|
|
| import './routes/customer''
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2024-03-14 19:25:27 +00:00
|
|
|
import OaiController from '#controllers/Http/Oai/OaiController';
|
|
|
|
|
|
|
|
import router from '@adonisjs/core/services/router';
|
|
|
|
import type { HttpContext } from '@adonisjs/core/http';
|
|
|
|
|
2023-03-03 15:54:28 +00:00
|
|
|
// import Inertia from '@ioc:EidelLev/Inertia';
|
2024-03-14 19:25:27 +00:00
|
|
|
import AuthValidator from '#app/Validators/AuthValidator';
|
|
|
|
// import HealthCheck from '@ioc:Adonis/Core/HealthCheck';
|
|
|
|
import User from '#app/Models/User';
|
|
|
|
import AuthController from '#controllers/Http/Auth/AuthController';
|
|
|
|
import UserController from '#controllers/Http/Auth/UserController';
|
|
|
|
import AdminUserController from '#controllers/Http/Admin/UsersController';
|
|
|
|
import RoleController from '#controllers/Http/Admin/RoleController';
|
|
|
|
|
|
|
|
import DatasetController from '#app/Controllers/Http/Submitter/DatasetController';
|
|
|
|
import PersonController from '#app/Controllers/Http/Submitter/PersonController';
|
|
|
|
import EditorDatasetController from '#app/Controllers/Http/Editor/DatasetController';
|
|
|
|
import ReviewerDatasetController from '#app/Controllers/Http/Reviewer/DatasetController';
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2024-03-14 19:25:27 +00:00
|
|
|
import './routes/api.js';
|
|
|
|
import { middleware } from './kernel.js'
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
|
2024-03-14 19:25:27 +00:00
|
|
|
// router.get('health', async ({ response }) => {
|
|
|
|
// const report = await HealthCheck.getReport();
|
|
|
|
// return report.healthy ? response.ok(report) : response.badRequest(report);
|
|
|
|
// });
|
|
|
|
router.get('/health', ({ response }: HttpContext) => response.noContent());
|
|
|
|
|
2023-12-01 09:44:19 +00:00
|
|
|
//oai:
|
2023-07-17 17:13:30 +00:00
|
|
|
// Route.get( '/oai', 'Oai/RequestController.index').as('oai');
|
2024-03-14 19:25:27 +00:00
|
|
|
router.group(() => {
|
|
|
|
router.get('/oai', [OaiController, 'index']).as('get');
|
|
|
|
router.post('/oai', [OaiController, 'index']).as('post');
|
|
|
|
})
|
|
|
|
.as('oai');
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-12-01 09:44:19 +00:00
|
|
|
//old solution:
|
2024-03-14 19:25:27 +00:00
|
|
|
router.get('/welcome', async ({ view }: HttpContext) => {
|
|
|
|
return view.render('welcome');
|
|
|
|
})
|
|
|
|
.as('welcome');
|
|
|
|
|
|
|
|
router.get('/', async ({ response }: HttpContext) => {
|
|
|
|
return response.redirect().toRoute('apps.dashboard');
|
|
|
|
})
|
|
|
|
.as('dashboard');
|
|
|
|
|
|
|
|
// apps group
|
|
|
|
router.group(() => {
|
|
|
|
router.get('/dashboard', async ({ inertia }: HttpContext) => {
|
|
|
|
return inertia.render('Dashboard');
|
|
|
|
})
|
|
|
|
.as('dashboard');
|
|
|
|
|
|
|
|
router.get('/map', async ({ inertia }: HttpContext) => {
|
|
|
|
return inertia.render('Map');
|
|
|
|
})
|
|
|
|
.as('map');
|
|
|
|
|
|
|
|
router.get('/', async ({ inertia }: HttpContext) => {
|
|
|
|
const users = await User.query().orderBy('login');
|
|
|
|
return inertia.render('App', {
|
|
|
|
testing: 'this is a test',
|
|
|
|
users: users,
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.as('index');
|
|
|
|
|
|
|
|
// Route.get('/login', async ({ inertia }) => {
|
|
|
|
// return inertia.render('Auth/Login');
|
|
|
|
// }).as('login.show');
|
|
|
|
|
|
|
|
router.get('/register', async ({ inertia }: HttpContext) => {
|
|
|
|
return inertia.render('register-view/register-view-component');
|
|
|
|
})
|
|
|
|
.as('register.show');
|
|
|
|
|
|
|
|
router.post('/register', async ({ request, response }: HttpContext) => {
|
|
|
|
console.log({
|
|
|
|
registerBody: request.body(),
|
|
|
|
});
|
|
|
|
|
|
|
|
const data = await request.validate(AuthValidator);
|
|
|
|
console.log({ data });
|
|
|
|
|
|
|
|
return response.redirect().toRoute('app.index');
|
|
|
|
})
|
|
|
|
.as('register.store');
|
|
|
|
})
|
2023-12-12 14:22:25 +00:00
|
|
|
.prefix('apps')
|
|
|
|
.as('apps')
|
2024-03-14 19:25:27 +00:00
|
|
|
.use(middleware.auth());
|
2023-12-15 16:17:33 +00:00
|
|
|
|
2024-03-14 19:25:27 +00:00
|
|
|
|
2023-10-20 13:26:25 +00:00
|
|
|
|
2023-03-03 15:54:28 +00:00
|
|
|
// Route.on("/login").render("signin");
|
2024-03-14 19:25:27 +00:00
|
|
|
router.get('/app/login', ({ inertia }: HttpContext) => {
|
|
|
|
return inertia.render('Auth/Login');
|
2023-03-03 15:54:28 +00:00
|
|
|
}).as('app.login.show');
|
|
|
|
|
2024-03-14 19:25:27 +00:00
|
|
|
router.post('/app/login', [AuthController, 'login']).as('login.store');
|
|
|
|
router.post('/app/twoFactorChallenge', [AuthController, 'twoFactorChallenge']).as('login.twoFactorChallenge');
|
|
|
|
router.post('/signout', [AuthController, 'logout']).as('logout');
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-11-27 16:17:22 +00:00
|
|
|
// administrator
|
2024-03-14 19:25:27 +00:00
|
|
|
router.group(() => {
|
|
|
|
router.get('/settings', async ({ inertia }: HttpContext) => {
|
|
|
|
return inertia.render('Admin/Settings');
|
|
|
|
})
|
|
|
|
.as('overview');
|
|
|
|
|
|
|
|
// user routes
|
|
|
|
router.get('/user', [AdminUserController, 'index']).as('user.index').use(middleware.can(['user-list']));
|
|
|
|
router.get('/user/create', [AdminUserController, 'create']).as('user.create').use(middleware.can(['user-create']));
|
|
|
|
router.post('/user/store', [AdminUserController, 'store']).as('user.store').use(middleware.can(['user-create']));
|
|
|
|
router.get('/user/:id', [AdminUserController, 'show']).as('user.show').where('id', router.matchers.number());
|
|
|
|
router.get('/user/:id/edit', [AdminUserController, 'edit']).as('user.edit').where('id', router.matchers.number()).use(middleware.can(['user-edit']));
|
|
|
|
router.put('/user/:id/update', [AdminUserController, 'update'])
|
|
|
|
.as('user.update')
|
|
|
|
.where('id', router.matchers.number())
|
|
|
|
.use(middleware.can(['user-edit']));
|
|
|
|
// // Route.delete('/user/:id', [AdminUserController, 'destroy'])
|
|
|
|
// // .as('user.destroy')
|
|
|
|
// // .where('id', Route.matchers.number())
|
|
|
|
// // .use(middleware.can(['user-delete']));
|
|
|
|
// // Route.resource('user', 'AdminUserController');
|
|
|
|
|
|
|
|
router.get('/role', [RoleController, 'index']).as('role.index').use(middleware.can(['user-list']));
|
|
|
|
router.get('/role/create', [RoleController, 'create']).as('role.create').use(middleware.can(['user-create']));
|
|
|
|
router.post('/role/store', [RoleController, 'store']).as('role.store').use(middleware.can(['user-create']));
|
|
|
|
router.get('/role/:id', [RoleController, 'show']).as('role.show').where('id', router.matchers.number());
|
|
|
|
router.get('/role/:id/edit', [RoleController, 'edit']).as('role.edit').where('id', router.matchers.number()).use(middleware.can(['user-edit']));
|
|
|
|
router.put('/role/:id/update', [RoleController, 'update'])
|
|
|
|
.as('role.update')
|
|
|
|
.where('id', router.matchers.number())
|
|
|
|
.use(middleware.can(['user-edit']));
|
|
|
|
// // Route.delete('/role/:id', [RoleController, 'destroy'])
|
|
|
|
// // .as('role.destroy')
|
|
|
|
// // .where('id', Route.matchers.number())
|
|
|
|
// // .use(middleware.can(['user-delete']));
|
|
|
|
})
|
2023-03-03 15:54:28 +00:00
|
|
|
.prefix('admin')
|
2023-12-15 16:17:33 +00:00
|
|
|
.as('settings')
|
2024-03-14 19:25:27 +00:00
|
|
|
.use([middleware.auth(), middleware.is(['administrator', 'moderator'])])
|
|
|
|
// .middleware(['auth', 'is:administrator,moderator']);
|
2023-12-29 14:54:49 +00:00
|
|
|
|
2024-03-14 19:25:27 +00:00
|
|
|
router.get('/settings/user/security', [UserController, 'accountInfo'])
|
2023-12-01 09:44:19 +00:00
|
|
|
.as('settings.user')
|
2024-03-14 19:25:27 +00:00
|
|
|
.use(middleware.auth());
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2024-03-14 19:25:27 +00:00
|
|
|
router.post('/settings/user/store', [UserController, 'accountInfoStore'])
|
2023-12-29 14:54:49 +00:00
|
|
|
.as('account.password.store')
|
2024-03-14 19:25:27 +00:00
|
|
|
.use(middleware.auth());
|
2023-03-03 15:54:28 +00:00
|
|
|
// Route::post('change-password', 'UserController@changePasswordStore')->name('admin.account.password.store');
|
2023-03-17 15:13:37 +00:00
|
|
|
|
2023-12-29 14:54:49 +00:00
|
|
|
|
|
|
|
|
2023-11-27 16:17:22 +00:00
|
|
|
// submitter:
|
2024-03-14 19:25:27 +00:00
|
|
|
router.group(() => {
|
|
|
|
|
|
|
|
router.get('/dataset', [DatasetController, 'index']).as('dataset.list').use([middleware.auth(), middleware.can(['dataset-list'])]);
|
|
|
|
router.get('/dataset/create', [DatasetController, 'create']).as('dataset.create').use([middleware.auth(), middleware.can(['dataset-submit'])]);
|
|
|
|
router.post('/dataset/first/first-step', [DatasetController, 'firstStep'])
|
2023-03-17 15:13:37 +00:00
|
|
|
.as('dataset.first.step')
|
2024-03-14 19:25:27 +00:00
|
|
|
.use([middleware.auth(), middleware.can(['dataset-submit'])]);
|
|
|
|
router.post('/dataset/second/second-step', [DatasetController, 'secondStep'])
|
2023-03-17 15:13:37 +00:00
|
|
|
.as('dataset.second.step')
|
2024-03-14 19:25:27 +00:00
|
|
|
.use([middleware.auth(), middleware.can(['dataset-submit'])]);
|
|
|
|
router.post('/dataset/second/third-step', [DatasetController, 'thirdStep'])
|
2023-03-24 10:41:52 +00:00
|
|
|
.as('dataset.third.step')
|
2024-03-14 19:25:27 +00:00
|
|
|
.use([middleware.auth(), middleware.can(['dataset-submit'])]);
|
|
|
|
router.post('/dataset/submit', [DatasetController, 'store']).as('dataset.submit').use([middleware.auth(), middleware.can(['dataset-submit'])]);
|
2023-06-01 12:29:56 +00:00
|
|
|
|
2024-03-14 19:25:27 +00:00
|
|
|
router.get('/dataset/:id/release', [DatasetController, 'release'])
|
2023-06-27 16:23:18 +00:00
|
|
|
.as('dataset.release')
|
2024-03-14 19:25:27 +00:00
|
|
|
.where('id', router.matchers.number())
|
|
|
|
.use([middleware.auth(), middleware.can(['dataset-edit'])]);
|
|
|
|
router.put('/dataset/:id/releaseupdate', [DatasetController, 'releaseUpdate'])
|
|
|
|
.as('dataset.releaseUpdate')
|
|
|
|
.use([middleware.auth(), middleware.can(['dataset-edit'])]);
|
|
|
|
router.get('/dataset/:id/edit', [DatasetController, 'edit'])
|
2023-07-17 17:13:30 +00:00
|
|
|
.as('dataset.edit')
|
2024-03-14 19:25:27 +00:00
|
|
|
.where('id', router.matchers.number())
|
|
|
|
.use([middleware.auth(), middleware.can(['dataset-edit'])]);
|
|
|
|
router.put('/dataset/:id/update', [DatasetController,'update'])
|
2023-11-30 12:40:32 +00:00
|
|
|
.as('dataset.update')
|
2024-03-14 19:25:27 +00:00
|
|
|
.where('id', router.matchers.number())
|
|
|
|
.use([middleware.auth(), middleware.can(['dataset-edit'])]);
|
2023-11-30 12:40:32 +00:00
|
|
|
|
2024-03-14 19:25:27 +00:00
|
|
|
router.get('/dataset/:id/delete', [DatasetController, 'delete']).as('dataset.delete').use([middleware.auth(), middleware.can(['dataset-delete'])]);
|
|
|
|
router.put('/dataset/:id/deleteupdate', [DatasetController, 'deleteUpdate'])
|
2023-09-05 16:18:42 +00:00
|
|
|
.as('dataset.deleteUpdate')
|
2024-03-14 19:25:27 +00:00
|
|
|
.use([middleware.auth(), middleware.can(['dataset-delete'])]);
|
2023-06-27 16:23:18 +00:00
|
|
|
|
2024-03-14 19:25:27 +00:00
|
|
|
router.get('/person', [PersonController, 'index']).as('person.index').use([middleware.auth()]);
|
|
|
|
|
2023-03-17 15:13:37 +00:00
|
|
|
})
|
|
|
|
.prefix('submitter');
|
|
|
|
// .middleware(['auth', 'can:dataset-list,dataset-publish']);
|
|
|
|
// .middleware(['auth', 'is:submitter']);
|
2023-10-17 13:45:41 +00:00
|
|
|
|
2023-11-30 12:40:32 +00:00
|
|
|
// editor:
|
2024-03-14 19:25:27 +00:00
|
|
|
router.group(() => {
|
|
|
|
router.get('/dataset', [EditorDatasetController, 'index']).as('editor.dataset.list').use([middleware.auth(), middleware.can(['dataset-editor-list'])]);
|
|
|
|
router.get('dataset/:id/receive', [EditorDatasetController, 'receive'])
|
2023-11-30 12:40:32 +00:00
|
|
|
.as('editor.dataset.receive')
|
2024-03-14 19:25:27 +00:00
|
|
|
.where('id', router.matchers.number())
|
|
|
|
.use([middleware.auth(), middleware.can(['dataset-receive'])]);
|
|
|
|
router.put('dataset/:id/receive', [EditorDatasetController, 'receiveUpdate'])
|
2023-12-12 14:22:25 +00:00
|
|
|
.as('editor.dataset.receiveUpdate')
|
2024-03-14 19:25:27 +00:00
|
|
|
.where('id', router.matchers.number())
|
|
|
|
.use([middleware.auth(), middleware.can(['dataset-receive'])]);
|
|
|
|
router.get('dataset/:id/approve', [EditorDatasetController, 'approve'])
|
2023-12-12 14:22:25 +00:00
|
|
|
.as('editor.dataset.approve')
|
2024-03-14 19:25:27 +00:00
|
|
|
.where('id', router.matchers.number())
|
|
|
|
.use([middleware.auth(), middleware.can(['dataset-approve'])]);
|
|
|
|
router.put('dataset/:id/approve', [EditorDatasetController, 'approveUpdate'])
|
2023-12-12 14:22:25 +00:00
|
|
|
.as('editor.dataset.approveUpdate')
|
2024-03-14 19:25:27 +00:00
|
|
|
.where('id', router.matchers.number())
|
|
|
|
.use([middleware.auth(), middleware.can(['dataset-approve'])]);
|
|
|
|
|
|
|
|
router.get('dataset/:id/publish', [EditorDatasetController, 'publish'])
|
2024-01-04 15:40:05 +00:00
|
|
|
.as('editor.dataset.publish')
|
2024-03-14 19:25:27 +00:00
|
|
|
.where('id', router.matchers.number())
|
|
|
|
.use([middleware.auth(), middleware.can(['dataset-publish'])]);
|
|
|
|
router.put('dataset/:id/publish', [EditorDatasetController, 'publishUpdate'])
|
2024-01-04 15:40:05 +00:00
|
|
|
.as('editor.dataset.publishUpdate')
|
2024-03-14 19:25:27 +00:00
|
|
|
.where('id', router.matchers.number())
|
|
|
|
.use([middleware.auth(), middleware.can(['dataset-publish'])]);
|
|
|
|
|
|
|
|
router.get('dataset/:id/doi', [EditorDatasetController, 'doiCreate'])
|
2024-01-26 08:39:03 +00:00
|
|
|
.as('editor.dataset.doi')
|
2024-03-14 19:25:27 +00:00
|
|
|
.where('id', router.matchers.number())
|
|
|
|
.use([middleware.auth(), middleware.can(['dataset-publish'])]);
|
|
|
|
router.put('dataset/:publish_id/doi', [EditorDatasetController, 'doiStore'])
|
2024-01-26 08:39:03 +00:00
|
|
|
.as('editor.dataset.doiStore')
|
2024-03-14 19:25:27 +00:00
|
|
|
.where('id', router.matchers.number())
|
|
|
|
.use([middleware.auth(), middleware.can(['dataset-publish'])]);
|
2023-11-30 12:40:32 +00:00
|
|
|
|
2024-03-14 19:25:27 +00:00
|
|
|
router.put('/dataset/:id/update', [EditorDatasetController, 'update'])
|
2023-11-30 12:40:32 +00:00
|
|
|
.as('editor.dataset.update')
|
2024-03-14 19:25:27 +00:00
|
|
|
.use([middleware.auth(), middleware.can(['dataset-editor-edit'])]);
|
2023-10-17 13:45:41 +00:00
|
|
|
})
|
2023-10-20 13:26:25 +00:00
|
|
|
.prefix('editor');
|
2024-01-04 15:40:05 +00:00
|
|
|
|
|
|
|
// reviewer:
|
2024-03-14 19:25:27 +00:00
|
|
|
router.group(() => {
|
|
|
|
router.get('/dataset', [ReviewerDatasetController, 'index']).as('reviewer.dataset.list').use([middleware.auth(), middleware.can(['dataset-review-list'])]);
|
|
|
|
router.get('dataset/:id/review', [ReviewerDatasetController, 'review'])
|
2024-01-04 15:40:05 +00:00
|
|
|
.as('reviewer.dataset.review')
|
2024-03-14 19:25:27 +00:00
|
|
|
.where('id', router.matchers.number())
|
|
|
|
.use([middleware.auth(), middleware.can(['dataset-review'])]);
|
|
|
|
router.put('dataset/:id/review', [ReviewerDatasetController, 'reviewUpdate'])
|
2024-01-04 15:40:05 +00:00
|
|
|
.as('reviewer.dataset.reviewUpdate')
|
2024-03-14 19:25:27 +00:00
|
|
|
.where('id', router.matchers.number())
|
|
|
|
.use([middleware.auth(), middleware.can(['dataset-review'])]);
|
|
|
|
router.get('dataset/:id/reject', [ReviewerDatasetController, 'reject'])
|
2024-01-04 15:40:05 +00:00
|
|
|
.as('reviewer.dataset.reject')
|
2024-03-14 19:25:27 +00:00
|
|
|
.where('id', router.matchers.number())
|
|
|
|
.use([middleware.auth(), middleware.can(['dataset-review-reject'])]);
|
|
|
|
router.put('dataset/:id/reject', [ReviewerDatasetController, 'rejectUpdate'])
|
|
|
|
.as('reviewer.dataset.rejectUpdate')
|
|
|
|
.where('id', router.matchers.number())
|
|
|
|
.use([middleware.auth(), middleware.can(['dataset-review-reject'])]);
|
|
|
|
// Route.put('dataset/:id/approve', [ReviewerDatasetController, 'approveUpdate'])
|
2024-01-04 15:40:05 +00:00
|
|
|
// .as('editor.dataset.approveUpdate')
|
|
|
|
// .where('id', Route.matchers.number())
|
|
|
|
// .middleware(['auth', 'can:dataset-approve']);
|
|
|
|
|
2024-03-14 19:25:27 +00:00
|
|
|
// Route.put('/dataset/:id/update', [ReviewerDatasetController, 'update')
|
2024-01-04 15:40:05 +00:00
|
|
|
// .as('editor.dataset.update')
|
|
|
|
// .middleware(['auth', 'can:dataset-editor-edit']);
|
|
|
|
})
|
2024-03-14 19:25:27 +00:00
|
|
|
|
2024-01-04 15:40:05 +00:00
|
|
|
.prefix('reviewer');
|