Test Failed
Push — master ( 4cf4fc...5851fa )
by Maximo
02:07
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
]);
19
20 4
$router->get('/status', [
21 4
    'Gewaer\Api\Controllers\IndexController',
22
    'status',
23
]);
24
25
/**
26
 * Authentification Calls
27
 * @var [type]
28
 */
29 4
$router->post('/auth', [
30 4
    'Gewaer\Api\Controllers\AuthController',
31
    'login',
32
]);
33
34
//asociate mobile devices
35 4
$router->post('/users/{id}/devices', [
36 4
    'Gewaer\Api\Controllers\UsersController',
37
    'devices',
38
]);
39
40
/**
41
 * Need to understand if using this can be a performance disadvantage in the future
42
 */
43
$defaultCrudRoutes = [
44 4
    'users',
45
    'companies',
46
];
47
48 4
foreach ($defaultCrudRoutes as $key => $route) {
49
    //set the controller name
50 4
    $name = is_int($key) ? $route : $key;
51 4
    $controllerName = ucfirst($name) . 'Controller';
52
53 4
    $router->get('/' . $route, [
54 4
        'Gewaer\Api\Controllers\\' . $controllerName,
55 4
        'index',
56
    ]);
57
58 4
    $router->post('/' . $route, [
59 4
        'Gewaer\Api\Controllers\\' . $controllerName,
60 4
        'create',
61
    ]);
62
63 4
    $router->get('/' . $route . '/{id}', [
64 4
        'Gewaer\Api\Controllers\\' . $controllerName,
65 4
        'getById',
66
    ]);
67
68 4
    $router->put('/' . $route . '/{id}', [
69 4
        'Gewaer\Api\Controllers\\' . $controllerName,
70 4
        'edit',
71
    ]);
72
73 4
    $router->put('/' . $route, [
74 4
        'Gewaer\Api\Controllers\\' . $controllerName,
75 4
        'multipleUpdates',
76
    ]);
77
78 4
    $router->delete('/' . $route . '/{id}', [
79 4
        'Gewaer\Api\Controllers\\' . $controllerName,
80 4
        'delete',
81
    ]);
82
}
83
84 4
$router->post('/users', [
85 4
    'Gewaer\Api\Controllers\AuthController',
86
    'signup',
87
]);
88
89 4
$router->put('/auth/logout', [
90 4
    'Gewaer\Api\Controllers\AuthController',
91
    'logout',
92
]);
93
94 4
$router->post('/auth/forgot', [
95 4
    'Gewaer\Api\Controllers\AuthController',
96
    'recover',
97
]);
98
99 4
$router->post('/auth/reset/{key}', [
100 4
    'Gewaer\Api\Controllers\AuthController',
101
    'reset',
102
]);
103
104
$router->mount();
105