api.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /*
  3. * Registra todas las rutas y middlewares de la API.
  4. */
  5. $app->use('api/v1/auth/me', '\App\Middlewares\Api\AuthMiddleware@verify');
  6. $app->use('api/v1/auth/logout', '\App\Middlewares\Api\AuthMiddleware@verify');
  7. $app->use('api/v1/auth/refresh', '\App\Middlewares\Api\AuthMiddleware@verify');
  8. $app->use('api/v1/tags', '\App\Middlewares\Api\AuthMiddleware@verify');
  9. $app->use('api/v1/tags/:uuid', '\App\Middlewares\Api\AuthMiddleware@verify');
  10. $app->use('api/v1/notes', '\App\Middlewares\Api\AuthMiddleware@verify');
  11. $app->use('api/v1/notes/:uuid', '\App\Middlewares\Api\AuthMiddleware@verify');
  12. $app->use('api/v1/profile', '\App\Middlewares\Api\AuthMiddleware@verify');
  13. $app->use('api/v1/users', ['\App\Middlewares\Api\AuthMiddleware@verify', '\App\Middlewares\Api\RoleMiddleware@isAdmin']);
  14. $app->use('api/v1/users/:uuid', ['\App\Middlewares\Api\AuthMiddleware@verify', '\App\Middlewares\Api\RoleMiddleware@isAdmin']);
  15. /*
  16. * Registro de rutas.
  17. */
  18. $app->all('api', '\App\Controllers\Api\ApiController@index');
  19. $app->all('api/v1', '\App\Controllers\Api\ApiController@index');
  20. $app->post('api/v1/auth/login', '\App\Controllers\Api\AuthController@login');
  21. $app->get('api/v1/auth/me', '\App\Controllers\Api\AuthController@me');
  22. $app->get('api/v1/auth/logout', '\App\Controllers\Api\AuthController@logout');
  23. $app->get('api/v1/auth/refresh', '\App\Controllers\Api\AuthController@refresh');
  24. $app->put('api/v1/profile', '\App\Controllers\Api\ProfileController@update');
  25. $app->post('api/v1/tags', '\App\Controllers\Api\TagController@create');
  26. $app->get('api/v1/tags', '\App\Controllers\Api\TagController@index');
  27. $app->get('api/v1/tags/:uuid', '\App\Controllers\Api\TagController@show');
  28. $app->put('api/v1/tags/:uuid', '\App\Controllers\Api\TagController@update');
  29. $app->delete('api/v1/tags/:uuid', '\App\Controllers\Api\TagController@delete');
  30. $app->post('api/v1/notes', '\App\Controllers\Api\NoteController@create');
  31. $app->get('api/v1/notes', '\App\Controllers\Api\NoteController@index');
  32. $app->get('api/v1/notes/:uuid', '\App\Controllers\Api\NoteController@show');
  33. $app->put('api/v1/notes/:uuid', '\App\Controllers\Api\NoteController@update');
  34. $app->delete('api/v1/notes/:uuid', '\App\Controllers\Api\NoteController@delete');
  35. $app->post('api/v1/users', '\App\Controllers\Api\UserController@create');
  36. $app->get('api/v1/users', '\App\Controllers\Api\UserController@index');
  37. $app->get('api/v1/users/:uuid', '\App\Controllers\Api\UserController@show');
  38. $app->put('api/v1/users/:uuid', '\App\Controllers\Api\UserController@update');
  39. $app->delete('api/v1/users/:uuid', '\App\Controllers\Api\UserController@delete');
  40. $app->all('api/:wildcard', '\App\Controllers\Api\ApiController@error404');