Test Failed
Push — master ( d0ec41...3b9ce6 )
by Maximo
02:08
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
/**
32
 * Authentification Calls
33
 * @var [type]
34
 */
35 4
$router->post('/auth', [
36 4
    'Gewaer\Api\Controllers\AuthController',
37
    'login',
38
    'options' => [
39
        'jwt' => false,
40
    ]
41
]);
42
43
//asociate mobile devices
44 4
$router->post('/users/{id}/devices', [
45 4
    'Gewaer\Api\Controllers\UsersController',
46
    'devices',
47
]);
48
49
/**
50
 * Need to understand if using this can be a performance disadvantage in the future
51
 */
52
$defaultCrudRoutes = [
53 4
    'users',
54
    'companies',
55
];
56
57 4
foreach ($defaultCrudRoutes as $key => $route) {
58
    //set the controller name
59 4
    $name = is_int($key) ? $route : $key;
60 4
    $controllerName = ucfirst($name) . 'Controller';
61
62 4
    $router->get('/' . $route, [
63 4
        'Gewaer\Api\Controllers\\' . $controllerName,
64 4
        'index',
65
    ]);
66
67 4
    $router->post('/' . $route, [
68 4
        'Gewaer\Api\Controllers\\' . $controllerName,
69 4
        'create',
70
    ]);
71
72 4
    $router->get('/' . $route . '/{id}', [
73 4
        'Gewaer\Api\Controllers\\' . $controllerName,
74 4
        'getById',
75
    ]);
76
77 4
    $router->put('/' . $route . '/{id}', [
78 4
        'Gewaer\Api\Controllers\\' . $controllerName,
79 4
        'edit',
80
    ]);
81
82 4
    $router->put('/' . $route, [
83 4
        'Gewaer\Api\Controllers\\' . $controllerName,
84 4
        'multipleUpdates',
85
    ]);
86
87 4
    $router->delete('/' . $route . '/{id}', [
88 4
        'Gewaer\Api\Controllers\\' . $controllerName,
89 4
        'delete',
90
    ]);
91
}
92
93 4
$router->post('/users', [
94 4
    'Gewaer\Api\Controllers\AuthController',
95
    'signup',
96
    'options' => [
97
        'jwt' => false,
98
    ]
99
]);
100
101 4
$router->put('/auth/logout', [
102 4
    'Gewaer\Api\Controllers\AuthController',
103
    'logout',
104
]);
105
106 4
$router->post('/auth/forgot', [
107 4
    'Gewaer\Api\Controllers\AuthController',
108
    'recover',
109
    'options' => [
110
        'jwt' => false,
111
    ]
112
]);
113
114 4
$router->post('/auth/reset/{key}', [
115 4
    'Gewaer\Api\Controllers\AuthController',
116
    'reset',
117
    'options' => [
118
        'jwt' => false,
119
    ]
120
]);
121
122
$router->mount();
123