Test Failed
Push — master ( e7e248...cb9afd )
by Maximo
02:40 queued 40s
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
$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
];
40
41
foreach ($defaultCrudRoutes as $key => $route) {
42
    //set the controller name
43
    $name = is_int($key) ? $route : $key;
44
    $controllerName = ucfirst($name) . 'Controller';
45
46
    $router->get('/' . $route, [
47
        'Gewaer\Api\Controllers\\' . $controllerName,
48
        'index',
49
    ]);
50
51
    $router->post('/' . $route, [
52
        'Gewaer\Api\Controllers\\' . $controllerName,
53
        'create',
54
    ]);
55
56
    $router->get('/' . $route . '/{id}', [
57
        'Gewaer\Api\Controllers\\' . $controllerName,
58
        'getById',
59
    ]);
60
61
    $router->put('/' . $route . '/{id}', [
62
        'Gewaer\Api\Controllers\\' . $controllerName,
63
        'edit',
64
    ]);
65
66
    $router->put('/' . $route, [
67
        'Gewaer\Api\Controllers\\' . $controllerName,
68
        'multipleUpdates',
69
    ]);
70
71
    $router->delete('/' . $route . '/{id}', [
72
        'Gewaer\Api\Controllers\\' . $controllerName,
73
        'delete',
74
    ]);
75
}
76
77
$router->post('/users', [
78
    'Gewaer\Api\Controllers\AuthController',
79
    'signup',
80
]);
81
82
$router->mount();
83