1 | <?php |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
2 | |||
3 | use Baka\Http\RouterCollection; |
||
4 | |||
5 | /* |
||
6 | |-------------------------------------------------------------------------- |
||
7 | | API Routes |
||
8 | |-------------------------------------------------------------------------- |
||
9 | | |
||
10 | | Here is where you can register all of the routes for api. |
||
11 | */ |
||
12 | |||
13 | $router = new RouterCollection($application); |
||
14 | $router->setPrefix('/v1'); |
||
15 | $router->get('/', [ |
||
16 | 'Gewaer\Api\Controllers\IndexController', |
||
17 | 'index', |
||
18 | ]); |
||
19 | |||
20 | $router->get('/status', [ |
||
21 | 'Gewaer\Api\Controllers\IndexController', |
||
22 | 'status', |
||
23 | ]); |
||
24 | |||
25 | /** |
||
26 | * Authentification Calls |
||
27 | * @var [type] |
||
28 | */ |
||
29 | $router->post('/auth', [ |
||
30 | 'Gewaer\Api\Controllers\AuthController', |
||
31 | 'login', |
||
32 | ]); |
||
33 | |||
34 | /** |
||
35 | * Need to understand if using this can be a performance disadvantage in the future |
||
36 | */ |
||
37 | $defaultCrudRoutes = [ |
||
38 | 'users', |
||
39 | 'companies', |
||
40 | ]; |
||
41 | |||
42 | foreach ($defaultCrudRoutes as $key => $route) { |
||
43 | //set the controller name |
||
44 | $name = is_int($key) ? $route : $key; |
||
45 | $controllerName = ucfirst($name) . 'Controller'; |
||
46 | |||
47 | $router->get('/' . $route, [ |
||
48 | 'Gewaer\Api\Controllers\\' . $controllerName, |
||
49 | 'index', |
||
50 | ]); |
||
51 | |||
52 | $router->post('/' . $route, [ |
||
53 | 'Gewaer\Api\Controllers\\' . $controllerName, |
||
54 | 'create', |
||
55 | ]); |
||
56 | |||
57 | $router->get('/' . $route . '/{id}', [ |
||
58 | 'Gewaer\Api\Controllers\\' . $controllerName, |
||
59 | 'getById', |
||
60 | ]); |
||
61 | |||
62 | $router->put('/' . $route . '/{id}', [ |
||
63 | 'Gewaer\Api\Controllers\\' . $controllerName, |
||
64 | 'edit', |
||
65 | ]); |
||
66 | |||
67 | $router->put('/' . $route, [ |
||
68 | 'Gewaer\Api\Controllers\\' . $controllerName, |
||
69 | 'multipleUpdates', |
||
70 | ]); |
||
71 | |||
72 | $router->delete('/' . $route . '/{id}', [ |
||
73 | 'Gewaer\Api\Controllers\\' . $controllerName, |
||
74 | 'delete', |
||
75 | ]); |
||
76 | } |
||
77 | |||
78 | $router->post('/users', [ |
||
79 | 'Gewaer\Api\Controllers\AuthController', |
||
80 | 'signup', |
||
81 | ]); |
||
82 | |||
83 | $router->mount(); |
||
84 |