Failed Conditions
Push — master ( c6c43f...4678b5 )
by Maximo
03:05
created

api/routes/api.php (1 issue)

1
<?php
0 ignored issues
show
End of line character is invalid; expected "\n" but found "\r\n"
Loading history...
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 4
$router = new RouterCollection($application);
14 4
$router->setPrefix('/v1');
15 4
$router->get('/', [
16 4
    'Gewaer\Api\Controllers\IndexController',
17
    'index',
18
    'options' => [
19
        'jwt' => false,
20
    ]
21
]);
22
23 4
$router->get('/status', [
24 4
    'Gewaer\Api\Controllers\IndexController',
25
    'status',
26
    'options' => [
27
        'jwt' => false,
28
    ]
29
]);
30
31 4
$router->get('/timezones', [
32 4
    'Gewaer\Api\Controllers\TimeZonesController',
33
    'index',
34
]);
35
36
/**
37
 * Authentification Calls
38
 * @var [type]
39
 */
40 4
$router->post('/auth', [
41 4
    'Gewaer\Api\Controllers\AuthController',
42
    'login',
43
    'options' => [
44
        'jwt' => false,
45
    ]
46
]);
47
48
//asociate mobile devices
49 4
$router->post('/users/{id}/devices', [
50 4
    'Gewaer\Api\Controllers\UsersController',
51
    'devices',
52
]);
53
54
/**
55
 * Need to understand if using this can be a performance disadvantage in the future
56
 */
57
$defaultCrudRoutes = [
58 4
    'users',
59
    'companies',
60
    'languages',
61
    'roles',
62
];
63
64 4
foreach ($defaultCrudRoutes as $key => $route) {
65
    //set the controller name
66 4
    $name = is_int($key) ? $route : $key;
67 4
    $controllerName = ucfirst($name) . 'Controller';
68
69 4
    $router->get('/' . $route, [
70 4
        'Gewaer\Api\Controllers\\' . $controllerName,
71 4
        'index',
72
    ]);
73
74 4
    $router->post('/' . $route, [
75 4
        'Gewaer\Api\Controllers\\' . $controllerName,
76 4
        'create',
77
    ]);
78
79 4
    $router->get('/' . $route . '/{id}', [
80 4
        'Gewaer\Api\Controllers\\' . $controllerName,
81 4
        'getById',
82
    ]);
83
84 4
    $router->put('/' . $route . '/{id}', [
85 4
        'Gewaer\Api\Controllers\\' . $controllerName,
86 4
        'edit',
87
    ]);
88
89 4
    $router->put('/' . $route, [
90 4
        'Gewaer\Api\Controllers\\' . $controllerName,
91 4
        'multipleUpdates',
92
    ]);
93
94 4
    $router->delete('/' . $route . '/{id}', [
95 4
        'Gewaer\Api\Controllers\\' . $controllerName,
96 4
        'delete',
97
    ]);
98
}
99
100 4
$router->post('/users', [
101 4
    'Gewaer\Api\Controllers\AuthController',
102
    'signup',
103
    'options' => [
104
        'jwt' => false,
105
    ]
106
]);
107
108 4
$router->put('/auth/logout', [
109 4
    'Gewaer\Api\Controllers\AuthController',
110
    'logout',
111
]);
112
113 4
$router->post('/auth/forgot', [
114 4
    'Gewaer\Api\Controllers\AuthController',
115
    'recover',
116
    'options' => [
117
        'jwt' => false,
118
    ]
119
]);
120
121 4
$router->post('/auth/reset/{key}', [
122 4
    'Gewaer\Api\Controllers\AuthController',
123
    'reset',
124
    'options' => [
125
        'jwt' => false,
126
    ]
127
]);
128
129
$router->mount();
130