diff options
Diffstat (limited to 'start/routes')
-rw-r--r-- | start/routes/api.ts | 82 | ||||
-rw-r--r-- | start/routes/web.ts | 104 |
2 files changed, 95 insertions, 91 deletions
diff --git a/start/routes/api.ts b/start/routes/api.ts index 78282f0..8992154 100644 --- a/start/routes/api.ts +++ b/start/routes/api.ts | |||
@@ -1,51 +1,47 @@ | |||
1 | // As this is currently a rebuild of the initial API we it is grouped in /v2/ | 1 | // As this is currently a rebuild of the initial API we it is grouped in /v2/ |
2 | 2 | ||
3 | import Route from '@ioc:Adonis/Core/Route'; | 3 | import router from '@adonisjs/core/services/router' |
4 | const UserController = () => import('#controllers/Http/UserController') | ||
5 | const ServiceController = () => import('#controllers/Http/ServiceController') | ||
6 | const RecipeController = () => import('#controllers/Http/RecipeController') | ||
4 | 7 | ||
5 | Route.group(() => { | 8 | router |
6 | // User authentification | 9 | .group(() => { |
7 | Route.post('auth/signup', 'UserController.signup').middleware('guest'); | 10 | // User authentification |
8 | Route.post('auth/login', 'UserController.login').middleware('guest'); | 11 | router.post('auth/signup', [UserController, 'signup']).middleware('guest') |
12 | router.post('auth/login', [UserController, 'login']).middleware('guest') | ||
9 | 13 | ||
10 | // User info | 14 | // User info |
11 | Route.get('me', 'UserController.me').middleware('auth:jwt'); | 15 | router.get('me', [UserController, 'me']).middleware('auth:jwt') |
12 | Route.put('me', 'UserController.updateMe').middleware('auth:jwt'); | 16 | router.put('me', [UserController, 'updateMe']).middleware('auth:jwt') |
13 | Route.get('me/newtoken', 'UserController.newToken').middleware('auth:jwt'); | 17 | router.get('me/newtoken', [UserController, 'newToken']).middleware('auth:jwt') |
14 | 18 | ||
15 | // // Service info | 19 | // // Service info |
16 | Route.post('service', 'ServiceController.create').middleware('auth:jwt'); | 20 | router.post('service', [ServiceController, 'create']).middleware('auth:jwt') |
17 | Route.put('service/reorder', 'ServiceController.reorder').middleware( | 21 | router.put('service/reorder', [ServiceController, 'reorder']).middleware('auth:jwt') |
18 | 'auth:jwt', | 22 | router.put('service/:id', [ServiceController, 'edit']).middleware('auth:jwt') |
19 | ); | 23 | router.delete('service/:id', [ServiceController, 'delete']).middleware('auth:jwt') |
20 | Route.put('service/:id', 'ServiceController.edit').middleware('auth:jwt'); | 24 | router.get('me/services', [ServiceController, 'list']).middleware('auth:jwt') |
21 | Route.delete('service/:id', 'ServiceController.delete').middleware( | 25 | router.get('recipe', [ServiceController, 'list']).middleware('auth:jwt') |
22 | 'auth:jwt', | 26 | router.get('icon/:id', [ServiceController, 'icon']) |
23 | ); | ||
24 | Route.get('me/services', 'ServiceController.list').middleware('auth:jwt'); | ||
25 | Route.get('recipe', 'ServiceController.list').middleware('auth:jwt'); | ||
26 | Route.get('icon/:id', 'ServiceController.icon'); | ||
27 | 27 | ||
28 | // Recipe store | 28 | // Recipe store |
29 | Route.get('recipes', 'RecipeController.list'); | 29 | router.get('recipes', [RecipeController, 'list']) |
30 | Route.get('recipes/search', 'RecipeController.search'); | 30 | router.get('recipes/search', [RecipeController, 'search']) |
31 | Route.get('recipes/popular', 'RecipeController.popularRecipes'); | 31 | router.get('recipes/popular', [RecipeController, 'popularRecipes']) |
32 | Route.get('recipes/download/:recipe', 'RecipeController.download'); | 32 | router.get('recipes/download/:recipe', [RecipeController, 'download']) |
33 | Route.post('recipes/update', 'RecipeController.update'); | 33 | router.post('recipes/update', [RecipeController, 'update']) |
34 | 34 | ||
35 | // // Workspaces | 35 | // // Workspaces |
36 | Route.put('workspace/:id', 'WorkspaceController.edit').middleware('auth:jwt'); | 36 | router.put('workspace/:id', 'WorkspaceController.edit').middleware('auth:jwt') |
37 | Route.delete('workspace/:id', 'WorkspaceController.delete').middleware( | 37 | router.delete('workspace/:id', 'WorkspaceController.delete').middleware('auth:jwt') |
38 | 'auth:jwt', | 38 | router.post('workspace', 'WorkspaceController.create').middleware('auth:jwt') |
39 | ); | 39 | router.get('workspace', 'WorkspaceController.list').middleware('auth:jwt') |
40 | Route.post('workspace', 'WorkspaceController.create').middleware('auth:jwt'); | ||
41 | Route.get('workspace', 'WorkspaceController.list').middleware('auth:jwt'); | ||
42 | 40 | ||
43 | // Static responses | 41 | // Static responses |
44 | Route.get('features/:mode?', 'Api/Static/FeaturesController.show'); | 42 | router.get('features/:mode?', 'Api/Static/FeaturesController.show') |
45 | Route.get('services', 'Api/Static/EmptyController.show'); | 43 | router.get('services', 'Api/Static/EmptyController.show') |
46 | Route.get('news', 'Api/Static/EmptyController.show'); | 44 | router.get('news', 'Api/Static/EmptyController.show') |
47 | Route.get( | 45 | router.get('announcements/:version', 'Api/Static/AnnouncementsController.show') |
48 | 'announcements/:version', | 46 | }) |
49 | 'Api/Static/AnnouncementsController.show', | 47 | .prefix('/v1') |
50 | ); | ||
51 | }).prefix('/v1'); | ||
diff --git a/start/routes/web.ts b/start/routes/web.ts index 308abec..fd12bf2 100644 --- a/start/routes/web.ts +++ b/start/routes/web.ts | |||
@@ -1,54 +1,62 @@ | |||
1 | import Route from '@ioc:Adonis/Core/Route'; | 1 | import router from '@adonisjs/core/services/router' |
2 | 2 | ||
3 | // Health check | 3 | // Health check |
4 | Route.get('health', 'HealthController.index'); | 4 | router.get('health', 'HealthController.index') |
5 | 5 | ||
6 | // Legal documents | 6 | // Legal documents |
7 | Route.get('terms', ({ response }) => response.redirect('/terms.html')); | 7 | router.get('terms', ({ response }) => response.redirect('/terms.html')) |
8 | Route.get('privacy', ({ response }) => response.redirect('/privacy.html')); | 8 | router.get('privacy', ({ response }) => response.redirect('/privacy.html')) |
9 | 9 | ||
10 | // Index | 10 | // Index |
11 | Route.get('/', ({ view }) => view.render('others/index')); | 11 | router.get('/', ({ view }) => view.render('others/index')) |
12 | 12 | ||
13 | Route.group(() => { | 13 | router |
14 | Route.group(() => { | 14 | .group(() => { |
15 | // Guest troutes | 15 | router |
16 | Route.group(() => { | 16 | .group(() => { |
17 | Route.get('login', 'Dashboard/LoginController.show'); | 17 | // Guest troutes |
18 | Route.post('login', 'Dashboard/LoginController.login').as('login'); | 18 | router |
19 | 19 | .group(() => { | |
20 | // Reset password | 20 | router.get('login', 'Dashboard/LoginController.show') |
21 | Route.get('forgot', 'Dashboard/ForgotPasswordController.show'); | 21 | router.post('login', 'Dashboard/LoginController.login').as('login') |
22 | Route.post('forgot', 'Dashboard/ForgotPasswordController.forgotPassword'); | 22 | |
23 | 23 | // Reset password | |
24 | Route.get('reset', 'Dashboard/ResetPasswordController.show'); | 24 | router.get('forgot', 'Dashboard/ForgotPasswordController.show') |
25 | Route.post('reset', 'Dashboard/ResetPasswordController.resetPassword'); | 25 | router.post('forgot', 'Dashboard/ForgotPasswordController.forgotPassword') |
26 | }).middleware(['dashboard', 'guest']); | 26 | |
27 | 27 | router.get('reset', 'Dashboard/ResetPasswordController.show') | |
28 | // Authenticated routes | 28 | router.post('reset', 'Dashboard/ResetPasswordController.resetPassword') |
29 | Route.group(() => { | 29 | }) |
30 | Route.get('account', 'Dashboard/AccountController.show'); | 30 | .middleware(['dashboard', 'guest']) |
31 | Route.post('account', 'Dashboard/AccountController.store'); | 31 | |
32 | 32 | // Authenticated routes | |
33 | Route.get('data', 'Dashboard/DataController.show'); | 33 | router |
34 | Route.get('export', 'Dashboard/ExportController.show'); | 34 | .group(() => { |
35 | 35 | router.get('account', 'Dashboard/AccountController.show') | |
36 | Route.get('transfer', 'Dashboard/TransferController.show'); | 36 | router.post('account', 'Dashboard/AccountController.store') |
37 | Route.post('transfer', 'Dashboard/TransferController.import'); | 37 | |
38 | 38 | router.get('data', 'Dashboard/DataController.show') | |
39 | Route.get('delete', 'Dashboard/DeleteController.show'); | 39 | router.get('export', 'Dashboard/ExportController.show') |
40 | Route.post('delete', 'Dashboard/DeleteController.delete'); | 40 | |
41 | 41 | router.get('transfer', 'Dashboard/TransferController.show') | |
42 | Route.get('logout', 'Dashboard/LogOutController.logout'); | 42 | router.post('transfer', 'Dashboard/TransferController.import') |
43 | 43 | ||
44 | Route.get('*', ({ response }) => response.redirect('/user/account')); | 44 | router.get('delete', 'Dashboard/DeleteController.show') |
45 | }).middleware(['dashboard', 'auth:web']); | 45 | router.post('delete', 'Dashboard/DeleteController.delete') |
46 | }).prefix('user'); | 46 | |
47 | 47 | router.get('logout', 'Dashboard/LogOutController.logout') | |
48 | // Franz/Ferdi account import | 48 | |
49 | Route.get('import', ({ view }) => view.render('others/import')); | 49 | router.get('*', ({ response }) => response.redirect('/user/account')) |
50 | Route.post('import', 'UserController.import'); | 50 | }) |
51 | 51 | .middleware(['dashboard', 'auth:web']) | |
52 | // 404 handler | 52 | }) |
53 | Route.get('/*', ({ response }) => response.redirect('/')); | 53 | .prefix('user') |
54 | }).middleware(['dashboard']); | 54 | |
55 | // Franz/Ferdi account import | ||
56 | router.get('import', ({ view }) => view.render('others/import')) | ||
57 | router.post('import', 'UserController.import') | ||
58 | |||
59 | // 404 handler | ||
60 | router.get('/*', ({ response }) => response.redirect('/')) | ||
61 | }) | ||
62 | .middleware(['dashboard']) | ||