2020-01-14 01:57:43 +00:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Routes
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Http routes are entry points to your web application. You can create
|
|
|
|
| routes for different URL's and bind Controller actions to them.
|
|
|
|
|
|
|
|
|
| A complete guide on routing is available here.
|
|
|
|
| http://adonisjs.com/docs/4.1/routing
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @type {typeof import('@adonisjs/framework/src/Route/Manager')} */
|
|
|
|
const Route = use('Route')
|
|
|
|
|
2020-01-18 20:46:06 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
/ Auth
|
|
|
|
*/
|
|
|
|
Route.get('/logout', 'AuthController.logout').as('logout').middleware(['auth']);
|
|
|
|
Route.get('/register', 'AuthController.registerIndex').as('register');
|
|
|
|
Route.get('/login', 'AuthController.loginIndex').as('login');
|
|
|
|
Route.post('/register', 'AuthController.register').validator('Register');
|
|
|
|
Route.post('/login', 'AuthController.login').validator('Login');
|
|
|
|
|
2020-05-13 01:30:11 +00:00
|
|
|
// reset-password
|
2020-05-18 00:39:53 +00:00
|
|
|
Route.post('/password/request/reset', 'AuthController.resetPasswordRequest')
|
|
|
|
.validator('ResetPasswordRequest')
|
|
|
|
.as('resetPasswordRequest');
|
|
|
|
Route.get('/password/reset', 'AuthController.resetPasswordRequestIndex');
|
|
|
|
Route.get('/password/reset/:token', 'AuthController.resetPasswordIndex');
|
2020-05-13 01:30:11 +00:00
|
|
|
Route.post('/password/reset', 'AuthController.resetPassword')
|
|
|
|
.validator('ResetPassword')
|
|
|
|
.as('resetPassword');
|
|
|
|
|
2020-01-26 22:16:16 +00:00
|
|
|
/*
|
2020-03-17 22:16:34 +00:00
|
|
|
/ Client API
|
2020-01-26 22:16:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
Route
|
2020-03-17 22:16:34 +00:00
|
|
|
.group(() => {
|
2020-04-12 14:25:42 +00:00
|
|
|
Route.post('connections/create', 'ClientApiController.createConnection');
|
2020-03-17 22:16:34 +00:00
|
|
|
Route.get('user', 'ClientApiController.getUser');
|
2020-05-23 21:32:25 +00:00
|
|
|
Route.put('user', 'ClientApiController.updateUser');
|
2020-03-17 22:16:34 +00:00
|
|
|
Route.post('child', 'ClientApiController.createChild');
|
2020-04-12 14:25:42 +00:00
|
|
|
Route.get('child/:id', 'ClientApiController.getChild');
|
2020-05-21 01:18:56 +00:00
|
|
|
Route.post('child/:id', 'ClientApiController.updateChild');
|
2020-04-12 14:25:42 +00:00
|
|
|
Route.post('call/create', 'ClientApiController.createCall');
|
2020-05-24 19:59:44 +00:00
|
|
|
Route.post('book/create', 'ClientApiController.createBook');
|
2020-03-17 22:16:34 +00:00
|
|
|
})
|
|
|
|
.prefix('api/v1/client')
|
2020-01-26 22:16:16 +00:00
|
|
|
.middleware(['auth']);
|
2020-02-02 22:42:18 +00:00
|
|
|
|
2020-04-29 23:45:50 +00:00
|
|
|
/**
|
|
|
|
* Private book assets
|
|
|
|
*/
|
2020-04-30 02:34:14 +00:00
|
|
|
Route
|
|
|
|
.get(
|
|
|
|
'/u/call/:callId/books/:bookId/page/:pageNumber',
|
|
|
|
'BookApiController.getPage')
|
2020-06-04 23:07:34 +00:00
|
|
|
.middleware(['auth', 'BookContext', 'CallContext', 'BookCallPageAuth']);
|
|
|
|
Route.get('/u/books/:bookId/page/:pageNumber', 'BookApiController.getPage')
|
|
|
|
.middleware(['auth', 'BookContext', 'BookPageAuth']);
|
2020-04-30 02:34:14 +00:00
|
|
|
/**
|
|
|
|
* Public book thumbnail
|
|
|
|
*/
|
|
|
|
Route.get('/u/books/:bookId/thumbnail', 'BookApiController.getThumbnail')
|
|
|
|
.middleware(['auth', 'BookContext'])
|
2020-03-17 22:16:34 +00:00
|
|
|
/*
|
|
|
|
/ Pubic CDN Images
|
|
|
|
*/
|
|
|
|
Route.get('/u/images/:fileName', 'CdnController.publicImages');
|
2020-02-02 22:42:18 +00:00
|
|
|
|
2020-03-17 22:16:34 +00:00
|
|
|
/*
|
|
|
|
/ Admin API
|
|
|
|
*/
|
|
|
|
// API
|
2020-02-02 22:42:18 +00:00
|
|
|
Route
|
2020-03-17 22:16:34 +00:00
|
|
|
.group(() => {
|
|
|
|
Route.get('users', 'AdminApiController.getUsers');
|
2020-05-13 01:30:11 +00:00
|
|
|
Route.get(
|
|
|
|
'settings/email/test/result', 'AdminApiController.testEmailSettings');
|
2020-03-17 22:16:34 +00:00
|
|
|
})
|
|
|
|
.prefix('/api/v1/admin')
|
|
|
|
.middleware(['auth', 'adminAuth']);
|
|
|
|
Route
|
|
|
|
.group(() => {
|
|
|
|
//
|
|
|
|
Route.get('/*', 'AdminController.index');
|
|
|
|
})
|
|
|
|
.prefix('admin')
|
|
|
|
.middleware(['auth', 'adminAuth']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Basic APIs */
|
|
|
|
// Route
|
|
|
|
// .get(
|
|
|
|
// '/users/profile',
|
|
|
|
// ({request, response, auth}) => {
|
|
|
|
// console.log('twergsg');
|
|
|
|
// const u = auth.user.publicJSON();
|
|
|
|
|
|
|
|
// response.send(u);
|
|
|
|
// // return auth.user;
|
|
|
|
// })
|
|
|
|
// .middleware(['auth']);
|
2020-02-02 22:42:18 +00:00
|
|
|
Route.get('/*', 'IndexController.index').as('home');
|