forked from sagi/seepur
111 lines
3.3 KiB
JavaScript
111 lines
3.3 KiB
JavaScript
'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')
|
|
|
|
|
|
/*
|
|
/ 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');
|
|
|
|
// reset-password
|
|
Route.post('/password/request/reset', 'AuthController.resetPasswordRequest')
|
|
.validator('ResetPasswordRequest')
|
|
.as('resetPasswordRequest');
|
|
Route.get('/password/reset', 'AuthController.resetPasswordRequestIndex');
|
|
Route.get('/password/reset/:token', 'AuthController.resetPasswordIndex');
|
|
Route.post('/password/reset', 'AuthController.resetPassword')
|
|
.validator('ResetPassword')
|
|
.as('resetPassword');
|
|
|
|
/*
|
|
/ Client API
|
|
*/
|
|
|
|
Route
|
|
.group(() => {
|
|
Route.post('connections/create', 'ClientApiController.createConnection');
|
|
Route.get('user', 'ClientApiController.getUser');
|
|
Route.put('user', 'ClientApiController.updateUser');
|
|
Route.post('child', 'ClientApiController.createChild');
|
|
Route.get('child/:id', 'ClientApiController.getChild');
|
|
Route.post('child/:id', 'ClientApiController.updateChild');
|
|
Route.post('call/create', 'ClientApiController.createCall');
|
|
Route.post('book/create', 'ClientApiController.createBook');
|
|
})
|
|
.prefix('api/v1/client')
|
|
.middleware(['auth']);
|
|
|
|
/**
|
|
* Private book assets
|
|
*/
|
|
Route
|
|
.get(
|
|
'/u/call/:callId/books/:bookId/page/:pageNumber',
|
|
'BookApiController.getPage')
|
|
.middleware(['auth', 'BookContext', 'CallContext', 'BookCallPageAuth']);
|
|
Route.get('/u/books/:bookId/page/:pageNumber', 'BookApiController.getPage')
|
|
.middleware(['auth', 'BookContext', 'BookPageAuth']);
|
|
/**
|
|
* Public book thumbnail
|
|
*/
|
|
Route.get('/u/books/:bookId/thumbnail', 'BookApiController.getThumbnail')
|
|
.middleware(['auth', 'BookContext'])
|
|
/*
|
|
/ Pubic CDN Images
|
|
*/
|
|
Route.get('/u/images/:fileName', 'CdnController.publicImages');
|
|
|
|
/*
|
|
/ Admin API
|
|
*/
|
|
// API
|
|
Route
|
|
.group(() => {
|
|
Route.get('users', 'AdminApiController.getUsers');
|
|
Route.get(
|
|
'settings/email/test/result', 'AdminApiController.testEmailSettings');
|
|
})
|
|
.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']);
|
|
Route.get('/*', 'IndexController.index').as('home');
|