diff options
Diffstat (limited to 'start')
-rw-r--r-- | start/env.ts | 4 | ||||
-rw-r--r-- | start/events.ts | 18 | ||||
-rw-r--r-- | start/kernel.ts | 6 | ||||
-rw-r--r-- | start/routes.ts | 4 | ||||
-rw-r--r-- | start/routes/api.ts | 81 | ||||
-rw-r--r-- | start/routes/web.ts | 64 |
6 files changed, 103 insertions, 74 deletions
diff --git a/start/env.ts b/start/env.ts index 3e1702e..c51a472 100644 --- a/start/env.ts +++ b/start/env.ts | |||
@@ -11,7 +11,7 @@ | |||
11 | | and hence do not rename or move this file to a different location. | 11 | | and hence do not rename or move this file to a different location. |
12 | | | 12 | | |
13 | */ | 13 | */ |
14 | import { Env } from '@adonisjs/core/env' | 14 | import { Env } from '@adonisjs/core/env'; |
15 | 15 | ||
16 | export default await Env.create(new URL('../', import.meta.url), { | 16 | export default await Env.create(new URL('../', import.meta.url), { |
17 | HOST: Env.schema.string({ format: 'host' }), | 17 | HOST: Env.schema.string({ format: 'host' }), |
@@ -21,4 +21,4 @@ export default await Env.create(new URL('../', import.meta.url), { | |||
21 | APP_NAME: Env.schema.string(), | 21 | APP_NAME: Env.schema.string(), |
22 | 22 | ||
23 | NODE_ENV: Env.schema.enum(['development', 'production', 'test'] as const), | 23 | NODE_ENV: Env.schema.enum(['development', 'production', 'test'] as const), |
24 | }) | 24 | }); |
diff --git a/start/events.ts b/start/events.ts index faedc29..9fe05e3 100644 --- a/start/events.ts +++ b/start/events.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { Config } from '@adonisjs/core/config' | 1 | import { Config } from '@adonisjs/core/config'; |
2 | import emitter from '@adonisjs/core/services/emitter' | 2 | import emitter from '@adonisjs/core/services/emitter'; |
3 | import mail from '@adonisjs/mail/services/main' | 3 | import mail from '@adonisjs/mail/services/main'; |
4 | 4 | ||
5 | /* | 5 | /* |
6 | |-------------------------------------------------------------------------- | 6 | |-------------------------------------------------------------------------- |
@@ -14,8 +14,8 @@ import mail from '@adonisjs/mail/services/main' | |||
14 | emitter.on('forgot::password', async ({ user, token }) => { | 14 | emitter.on('forgot::password', async ({ user, token }) => { |
15 | try { | 15 | try { |
16 | // eslint-disable-next-line no-console | 16 | // eslint-disable-next-line no-console |
17 | console.log('Sending message') | 17 | console.log('Sending message'); |
18 | await mail.send((message) => { | 18 | await mail.send(message => { |
19 | message | 19 | message |
20 | .subject('[Ferdium] Forgot Password') | 20 | .subject('[Ferdium] Forgot Password') |
21 | .to(user.email) | 21 | .to(user.email) |
@@ -24,10 +24,10 @@ emitter.on('forgot::password', async ({ user, token }) => { | |||
24 | appUrl: Config.get('app.url'), | 24 | appUrl: Config.get('app.url'), |
25 | username: user.username, | 25 | username: user.username, |
26 | token, | 26 | token, |
27 | }) | 27 | }); |
28 | }) | 28 | }); |
29 | } catch (error) { | 29 | } catch (error) { |
30 | // eslint-disable-next-line no-console | 30 | // eslint-disable-next-line no-console |
31 | console.log(`Couldn't send mail: ${error}`) | 31 | console.log(`Couldn't send mail: ${error}`); |
32 | } | 32 | } |
33 | }) | 33 | }); |
diff --git a/start/kernel.ts b/start/kernel.ts index 99a0820..0081844 100644 --- a/start/kernel.ts +++ b/start/kernel.ts | |||
@@ -9,7 +9,7 @@ | |||
9 | | | 9 | | |
10 | */ | 10 | */ |
11 | 11 | ||
12 | import { server } from '@adonisjs/core/services/server' | 12 | import { server } from '@adonisjs/core/services/server'; |
13 | 13 | ||
14 | /* | 14 | /* |
15 | |-------------------------------------------------------------------------- | 15 | |-------------------------------------------------------------------------- |
@@ -23,7 +23,7 @@ import { server } from '@adonisjs/core/services/server' | |||
23 | server.middleware.register([ | 23 | server.middleware.register([ |
24 | () => import('@ioc:Adonis/Core/BodyParser'), | 24 | () => import('@ioc:Adonis/Core/BodyParser'), |
25 | () => import('@ioc:Adonis/Addons/Shield'), | 25 | () => import('@ioc:Adonis/Addons/Shield'), |
26 | ]) | 26 | ]); |
27 | 27 | ||
28 | /* | 28 | /* |
29 | |-------------------------------------------------------------------------- | 29 | |-------------------------------------------------------------------------- |
@@ -46,4 +46,4 @@ server.middleware.registerNamed({ | |||
46 | dashboard: () => import('App/Middleware/Dashboard'), | 46 | dashboard: () => import('App/Middleware/Dashboard'), |
47 | guest: () => import('App/Middleware/AllowGuestOnly'), | 47 | guest: () => import('App/Middleware/AllowGuestOnly'), |
48 | shield: () => import('@ioc:Adonis/Addons/Shield'), | 48 | shield: () => import('@ioc:Adonis/Addons/Shield'), |
49 | }) | 49 | }); |
diff --git a/start/routes.ts b/start/routes.ts index 7c62909..ea090c9 100644 --- a/start/routes.ts +++ b/start/routes.ts | |||
@@ -18,5 +18,5 @@ | |||
18 | | | 18 | | |
19 | */ | 19 | */ |
20 | 20 | ||
21 | import './routes/api.js' | 21 | import './routes/api.js'; |
22 | import './routes/web.js' | 22 | import './routes/web.js'; |
diff --git a/start/routes/api.ts b/start/routes/api.ts index 8992154..77c3046 100644 --- a/start/routes/api.ts +++ b/start/routes/api.ts | |||
@@ -1,47 +1,68 @@ | |||
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 router from '@adonisjs/core/services/router' | 3 | import router from '@adonisjs/core/services/router'; |
4 | const UserController = () => import('#controllers/Http/UserController') | 4 | const UserController = () => import('#controllers/Http/UserController'); |
5 | const ServiceController = () => import('#controllers/Http/ServiceController') | 5 | const ServiceController = () => import('#controllers/Http/ServiceController'); |
6 | const RecipeController = () => import('#controllers/Http/RecipeController') | 6 | const RecipeController = () => import('#controllers/Http/RecipeController'); |
7 | 7 | ||
8 | router | 8 | router |
9 | .group(() => { | 9 | .group(() => { |
10 | // User authentification | 10 | // User authentification |
11 | router.post('auth/signup', [UserController, 'signup']).middleware('guest') | 11 | router.post('auth/signup', [UserController, 'signup']).middleware('guest'); |
12 | router.post('auth/login', [UserController, 'login']).middleware('guest') | 12 | router.post('auth/login', [UserController, 'login']).middleware('guest'); |
13 | 13 | ||
14 | // User info | 14 | // User info |
15 | router.get('me', [UserController, 'me']).middleware('auth:jwt') | 15 | router.get('me', [UserController, 'me']).middleware('auth:jwt'); |
16 | router.put('me', [UserController, 'updateMe']).middleware('auth:jwt') | 16 | router.put('me', [UserController, 'updateMe']).middleware('auth:jwt'); |
17 | router.get('me/newtoken', [UserController, 'newToken']).middleware('auth:jwt') | 17 | router |
18 | .get('me/newtoken', [UserController, 'newToken']) | ||
19 | .middleware('auth:jwt'); | ||
18 | 20 | ||
19 | // // Service info | 21 | // // Service info |
20 | router.post('service', [ServiceController, 'create']).middleware('auth:jwt') | 22 | router |
21 | router.put('service/reorder', [ServiceController, 'reorder']).middleware('auth:jwt') | 23 | .post('service', [ServiceController, 'create']) |
22 | router.put('service/:id', [ServiceController, 'edit']).middleware('auth:jwt') | 24 | .middleware('auth:jwt'); |
23 | router.delete('service/:id', [ServiceController, 'delete']).middleware('auth:jwt') | 25 | router |
24 | router.get('me/services', [ServiceController, 'list']).middleware('auth:jwt') | 26 | .put('service/reorder', [ServiceController, 'reorder']) |
25 | router.get('recipe', [ServiceController, 'list']).middleware('auth:jwt') | 27 | .middleware('auth:jwt'); |
26 | router.get('icon/:id', [ServiceController, 'icon']) | 28 | router |
29 | .put('service/:id', [ServiceController, 'edit']) | ||
30 | .middleware('auth:jwt'); | ||
31 | router | ||
32 | .delete('service/:id', [ServiceController, 'delete']) | ||
33 | .middleware('auth:jwt'); | ||
34 | router | ||
35 | .get('me/services', [ServiceController, 'list']) | ||
36 | .middleware('auth:jwt'); | ||
37 | router.get('recipe', [ServiceController, 'list']).middleware('auth:jwt'); | ||
38 | router.get('icon/:id', [ServiceController, 'icon']); | ||
27 | 39 | ||
28 | // Recipe store | 40 | // Recipe store |
29 | router.get('recipes', [RecipeController, 'list']) | 41 | router.get('recipes', [RecipeController, 'list']); |
30 | router.get('recipes/search', [RecipeController, 'search']) | 42 | router.get('recipes/search', [RecipeController, 'search']); |
31 | router.get('recipes/popular', [RecipeController, 'popularRecipes']) | 43 | router.get('recipes/popular', [RecipeController, 'popularRecipes']); |
32 | router.get('recipes/download/:recipe', [RecipeController, 'download']) | 44 | router.get('recipes/download/:recipe', [RecipeController, 'download']); |
33 | router.post('recipes/update', [RecipeController, 'update']) | 45 | router.post('recipes/update', [RecipeController, 'update']); |
34 | 46 | ||
35 | // // Workspaces | 47 | // // Workspaces |
36 | router.put('workspace/:id', 'WorkspaceController.edit').middleware('auth:jwt') | 48 | router |
37 | router.delete('workspace/:id', 'WorkspaceController.delete').middleware('auth:jwt') | 49 | .put('workspace/:id', 'WorkspaceController.edit') |
38 | router.post('workspace', 'WorkspaceController.create').middleware('auth:jwt') | 50 | .middleware('auth:jwt'); |
39 | router.get('workspace', 'WorkspaceController.list').middleware('auth:jwt') | 51 | router |
52 | .delete('workspace/:id', 'WorkspaceController.delete') | ||
53 | .middleware('auth:jwt'); | ||
54 | router | ||
55 | .post('workspace', 'WorkspaceController.create') | ||
56 | .middleware('auth:jwt'); | ||
57 | router.get('workspace', 'WorkspaceController.list').middleware('auth:jwt'); | ||
40 | 58 | ||
41 | // Static responses | 59 | // Static responses |
42 | router.get('features/:mode?', 'Api/Static/FeaturesController.show') | 60 | router.get('features/:mode?', 'Api/Static/FeaturesController.show'); |
43 | router.get('services', 'Api/Static/EmptyController.show') | 61 | router.get('services', 'Api/Static/EmptyController.show'); |
44 | router.get('news', 'Api/Static/EmptyController.show') | 62 | router.get('news', 'Api/Static/EmptyController.show'); |
45 | router.get('announcements/:version', 'Api/Static/AnnouncementsController.show') | 63 | router.get( |
64 | 'announcements/:version', | ||
65 | 'Api/Static/AnnouncementsController.show', | ||
66 | ); | ||
46 | }) | 67 | }) |
47 | .prefix('/v1') | 68 | .prefix('/v1'); |
diff --git a/start/routes/web.ts b/start/routes/web.ts index fd12bf2..2907e62 100644 --- a/start/routes/web.ts +++ b/start/routes/web.ts | |||
@@ -1,14 +1,14 @@ | |||
1 | import router from '@adonisjs/core/services/router' | 1 | import router from '@adonisjs/core/services/router'; |
2 | 2 | ||
3 | // Health check | 3 | // Health check |
4 | router.get('health', 'HealthController.index') | 4 | router.get('health', 'HealthController.index'); |
5 | 5 | ||
6 | // Legal documents | 6 | // Legal documents |
7 | router.get('terms', ({ response }) => response.redirect('/terms.html')) | 7 | router.get('terms', ({ response }) => response.redirect('/terms.html')); |
8 | router.get('privacy', ({ response }) => response.redirect('/privacy.html')) | 8 | router.get('privacy', ({ response }) => response.redirect('/privacy.html')); |
9 | 9 | ||
10 | // Index | 10 | // Index |
11 | router.get('/', ({ view }) => view.render('others/index')) | 11 | router.get('/', ({ view }) => view.render('others/index')); |
12 | 12 | ||
13 | router | 13 | router |
14 | .group(() => { | 14 | .group(() => { |
@@ -17,46 +17,54 @@ router | |||
17 | // Guest troutes | 17 | // Guest troutes |
18 | router | 18 | router |
19 | .group(() => { | 19 | .group(() => { |
20 | router.get('login', 'Dashboard/LoginController.show') | 20 | router.get('login', 'Dashboard/LoginController.show'); |
21 | router.post('login', 'Dashboard/LoginController.login').as('login') | 21 | router.post('login', 'Dashboard/LoginController.login').as('login'); |
22 | 22 | ||
23 | // Reset password | 23 | // Reset password |
24 | router.get('forgot', 'Dashboard/ForgotPasswordController.show') | 24 | router.get('forgot', 'Dashboard/ForgotPasswordController.show'); |
25 | router.post('forgot', 'Dashboard/ForgotPasswordController.forgotPassword') | 25 | router.post( |
26 | 'forgot', | ||
27 | 'Dashboard/ForgotPasswordController.forgotPassword', | ||
28 | ); | ||
26 | 29 | ||
27 | router.get('reset', 'Dashboard/ResetPasswordController.show') | 30 | router.get('reset', 'Dashboard/ResetPasswordController.show'); |
28 | router.post('reset', 'Dashboard/ResetPasswordController.resetPassword') | 31 | router.post( |
32 | 'reset', | ||
33 | 'Dashboard/ResetPasswordController.resetPassword', | ||
34 | ); | ||
29 | }) | 35 | }) |
30 | .middleware(['dashboard', 'guest']) | 36 | .middleware(['dashboard', 'guest']); |
31 | 37 | ||
32 | // Authenticated routes | 38 | // Authenticated routes |
33 | router | 39 | router |
34 | .group(() => { | 40 | .group(() => { |
35 | router.get('account', 'Dashboard/AccountController.show') | 41 | router.get('account', 'Dashboard/AccountController.show'); |
36 | router.post('account', 'Dashboard/AccountController.store') | 42 | router.post('account', 'Dashboard/AccountController.store'); |
37 | 43 | ||
38 | router.get('data', 'Dashboard/DataController.show') | 44 | router.get('data', 'Dashboard/DataController.show'); |
39 | router.get('export', 'Dashboard/ExportController.show') | 45 | router.get('export', 'Dashboard/ExportController.show'); |
40 | 46 | ||
41 | router.get('transfer', 'Dashboard/TransferController.show') | 47 | router.get('transfer', 'Dashboard/TransferController.show'); |
42 | router.post('transfer', 'Dashboard/TransferController.import') | 48 | router.post('transfer', 'Dashboard/TransferController.import'); |
43 | 49 | ||
44 | router.get('delete', 'Dashboard/DeleteController.show') | 50 | router.get('delete', 'Dashboard/DeleteController.show'); |
45 | router.post('delete', 'Dashboard/DeleteController.delete') | 51 | router.post('delete', 'Dashboard/DeleteController.delete'); |
46 | 52 | ||
47 | router.get('logout', 'Dashboard/LogOutController.logout') | 53 | router.get('logout', 'Dashboard/LogOutController.logout'); |
48 | 54 | ||
49 | router.get('*', ({ response }) => response.redirect('/user/account')) | 55 | router.get('*', ({ response }) => |
56 | response.redirect('/user/account'), | ||
57 | ); | ||
50 | }) | 58 | }) |
51 | .middleware(['dashboard', 'auth:web']) | 59 | .middleware(['dashboard', 'auth:web']); |
52 | }) | 60 | }) |
53 | .prefix('user') | 61 | .prefix('user'); |
54 | 62 | ||
55 | // Franz/Ferdi account import | 63 | // Franz/Ferdi account import |
56 | router.get('import', ({ view }) => view.render('others/import')) | 64 | router.get('import', ({ view }) => view.render('others/import')); |
57 | router.post('import', 'UserController.import') | 65 | router.post('import', 'UserController.import'); |
58 | 66 | ||
59 | // 404 handler | 67 | // 404 handler |
60 | router.get('/*', ({ response }) => response.redirect('/')) | 68 | router.get('/*', ({ response }) => response.redirect('/')); |
61 | }) | 69 | }) |
62 | .middleware(['dashboard']) | 70 | .middleware(['dashboard']); |