|
1 | 1 | <?php |
2 | 2 |
|
3 | 3 | use Limber\Router\Router; |
| 4 | +use Controllers\LoginController; |
4 | 5 | use Controllers\DatabaseController; |
5 | 6 | use Controllers\CollectionController; |
| 7 | +use Controllers\Controller; |
6 | 8 |
|
7 | 9 | $router = new Router(); |
8 | 10 |
|
9 | 11 | $router->get('/', function() { |
10 | | - header('Location: /queryDatabase'); |
11 | | - exit; |
| 12 | + |
| 13 | + LoginController::ensureUserIsLogged(); |
| 14 | + |
| 15 | + Controller::redirectTo('/queryDatabase'); |
| 16 | + |
| 17 | +}); |
| 18 | + |
| 19 | +// XXX This hack makes index to work in sub-folder case. |
| 20 | +$router->get(MPG_SERVER_PATH . '/index', function() { |
| 21 | + |
| 22 | + LoginController::ensureUserIsLogged(); |
| 23 | + |
| 24 | + Controller::redirectTo('/queryDatabase'); |
| 25 | + |
12 | 26 | }); |
13 | 27 |
|
14 | 28 | $router->get( |
15 | | - '/createDatabase', |
| 29 | + MPG_SERVER_PATH . '/login', |
| 30 | + LoginController::class . '@renderViewAction' |
| 31 | +); |
| 32 | + |
| 33 | +$router->post( |
| 34 | + MPG_SERVER_PATH . '/login', |
| 35 | + LoginController::class . '@renderViewAction' |
| 36 | +); |
| 37 | + |
| 38 | +$router->get( |
| 39 | + MPG_SERVER_PATH . '/createDatabase', |
16 | 40 | DatabaseController::class . '@renderCreateViewAction' |
17 | 41 | ); |
18 | 42 |
|
19 | 43 | $router->get( |
20 | | - '/queryDatabase', |
| 44 | + MPG_SERVER_PATH . '/queryDatabase', |
21 | 45 | DatabaseController::class . '@renderQueryViewAction' |
22 | 46 | ); |
23 | 47 |
|
24 | 48 | $router->post( |
25 | | - '/ajax/database/listCollections', |
| 49 | + MPG_SERVER_PATH . '/ajaxDatabaseListCollections', |
26 | 50 | DatabaseController::class . '@listCollectionsAction' |
27 | 51 | ); |
28 | 52 |
|
29 | 53 | $router->post( |
30 | | - '/ajax/database/createCollection', |
| 54 | + MPG_SERVER_PATH . '/ajaxDatabaseCreateCollection', |
31 | 55 | DatabaseController::class . '@createCollectionAction' |
32 | 56 | ); |
33 | 57 |
|
34 | 58 | $router->post( |
35 | | - '/ajax/collection/insertOne', |
| 59 | + MPG_SERVER_PATH . '/ajaxCollectionInsertOne', |
36 | 60 | CollectionController::class . '@insertOneAction' |
37 | 61 | ); |
38 | 62 |
|
39 | 63 | $router->post( |
40 | | - '/ajax/collection/count', |
| 64 | + MPG_SERVER_PATH . '/ajaxCollectionCount', |
41 | 65 | CollectionController::class . '@countAction' |
42 | 66 | ); |
43 | 67 |
|
44 | 68 | $router->post( |
45 | | - '/ajax/collection/deleteOne', |
| 69 | + MPG_SERVER_PATH . '/ajaxCollectionDeleteOne', |
46 | 70 | CollectionController::class . '@deleteOneAction' |
47 | 71 | ); |
48 | 72 |
|
49 | 73 | $router->post( |
50 | | - '/ajax/collection/find', |
| 74 | + MPG_SERVER_PATH . '/ajaxCollectionFind', |
51 | 75 | CollectionController::class . '@findAction' |
52 | 76 | ); |
53 | 77 |
|
54 | 78 | $router->post( |
55 | | - '/ajax/collection/updateOne', |
| 79 | + MPG_SERVER_PATH . '/ajaxCollectionUpdateOne', |
56 | 80 | CollectionController::class . '@updateOneAction' |
57 | 81 | ); |
58 | 82 |
|
59 | 83 | $router->post( |
60 | | - '/ajax/collection/enumFields', |
| 84 | + MPG_SERVER_PATH . '/ajaxCollectionEnumFields', |
61 | 85 | CollectionController::class . '@enumFieldsAction' |
62 | 86 | ); |
63 | 87 |
|
64 | 88 | $router->get( |
65 | | - '/manageIndexes', |
| 89 | + MPG_SERVER_PATH . '/manageIndexes', |
66 | 90 | CollectionController::class . '@renderIndexesViewAction' |
67 | 91 | ); |
68 | 92 |
|
69 | 93 | $router->post( |
70 | | - '/ajax/collection/createIndex', |
| 94 | + MPG_SERVER_PATH . '/ajaxCollectionCreateIndex', |
71 | 95 | CollectionController::class . '@createIndexAction' |
72 | 96 | ); |
73 | 97 |
|
74 | 98 | $router->post( |
75 | | - '/ajax/collection/listIndexes', |
| 99 | + MPG_SERVER_PATH . '/ajaxCollectionListIndexes', |
76 | 100 | CollectionController::class . '@listIndexesAction' |
77 | 101 | ); |
78 | 102 |
|
79 | 103 | $router->post( |
80 | | - '/ajax/collection/dropIndex', |
| 104 | + MPG_SERVER_PATH . '/ajaxCollectionDropIndex', |
81 | 105 | CollectionController::class . '@dropIndexAction' |
82 | 106 | ); |
| 107 | + |
| 108 | +$router->get( |
| 109 | + MPG_SERVER_PATH . '/logout', |
| 110 | + LoginController::class . '@logoutAction' |
| 111 | +); |
0 commit comments