clqms-be/app/Config/Routes.php
mahdahar eb883cf059 feat: Add V2 UI with JWT auth, DaisyUI 5, and theme system
- Implement JWT authentication with HTTP-only cookies
- Create /v2/* namespace to avoid conflicts with existing frontend
- Upgrade to DaisyUI 5 + Tailwind CSS 4
- Add light/dark theme toggle with smooth transitions
- Build login page, dashboard, and patient list UI
- Protect V2 routes with auth middleware
- Add comprehensive documentation

No breaking changes - all new features under /v2/* namespace
2025-12-30 08:48:13 +07:00

265 lines
10 KiB
PHP

<?php
use CodeIgniter\Router\RouteCollection;
/**
* @var RouteCollection $routes
*/
$routes->options('(:any)', function () {
return '';
});
$routes->group('api', ['filter' => 'auth'], function($routes) {
$routes->get('dashboard', 'Dashboard::index');
$routes->get('result', 'Result::index');
$routes->get('sample', 'Sample::index');
});
// Public Routes (no auth required)
$routes->get('/v2/login', 'PagesController::login');
// Protected Page Routes - V2 (requires auth)
$routes->group('v2', ['filter' => 'auth'], function ($routes) {
$routes->get('/', 'PagesController::dashboard');
$routes->get('dashboard', 'PagesController::dashboard');
$routes->get('patients', 'PagesController::patients');
$routes->get('requests', 'PagesController::requests');
$routes->get('settings', 'PagesController::settings');
});
// Faker
$routes->get('faker/faker-patient/(:num)', 'faker\FakerPatient::sendMany/$1');
$routes->group('api', function ($routes) {
// Auth
$routes->group('auth', function ($routes) {
$routes->post('login', 'Auth::login');
$routes->post('change_pass', 'Auth::change_pass');
$routes->post('register', 'Auth::register');
$routes->get('check', 'Auth::checkAuth');
$routes->post('logout', 'Auth::logout');
});
// Patient
$routes->group('patient', function ($routes) {
$routes->get('/', 'Patient\Patient::index');
$routes->post('/', 'Patient\Patient::create');
$routes->get('(:num)', 'Patient\Patient::show/$1');
$routes->delete('/', 'Patient\Patient::delete');
$routes->patch('/', 'Patient\Patient::update');
$routes->get('check', 'Patient\Patient::patientCheck');
});
// PatVisit
$routes->group('patvisit', function ($routes) {
$routes->get('/', 'PatVisit::index');
$routes->post('/', 'PatVisit::create');
$routes->get('patient/(:num)', 'PatVisit::showByPatient/$1');
$routes->get('(:any)', 'PatVisit::show/$1');
$routes->delete('/', 'PatVisit::delete');
$routes->patch('/', 'PatVisit::update');
});
$routes->group('patvisitadt', function ($routes) {
$routes->post('/', 'PatVisit::createADT');
$routes->patch('/', 'PatVisit::updateADT');
});
// Master Data
$routes->group('race', function ($routes) {
$routes->get('/', 'Race::index');
$routes->get('(:num)', 'Race::show/$1');
});
$routes->group('country', function ($routes) {
$routes->get('/', 'Country::index');
$routes->get('(:num)', 'Country::show/$1');
});
$routes->group('religion', function ($routes) {
$routes->get('/', 'Religion::index');
$routes->get('(:num)', 'Religion::show/$1');
});
$routes->group('ethnic', function ($routes) {
$routes->get('/', 'Ethnic::index');
$routes->get('(:num)', 'Ethnic::show/$1');
});
// Location
$routes->group('location', function ($routes) {
$routes->get('/', 'Location::index');
$routes->get('(:num)', 'Location::show/$1');
$routes->post('/', 'Location::create');
$routes->patch('/', 'Location::update');
$routes->delete('/', 'Location::delete');
});
// Contact
$routes->group('contact', function ($routes) {
$routes->get('/', 'Contact\Contact::index');
$routes->get('(:num)', 'Contact\Contact::show/$1');
$routes->post('/', 'Contact\Contact::create');
$routes->patch('/', 'Contact\Contact::update');
$routes->delete('/', 'Contact\Contact::delete');
});
$routes->group('occupation', function ($routes) {
$routes->get('/', 'Contact\Occupation::index');
$routes->get('(:num)', 'Contact\Occupation::show/$1');
$routes->post('/', 'Contact\Occupation::create');
$routes->patch('/', 'Contact\Occupation::update');
//$routes->delete('/', 'Contact\Occupation::delete');
});
$routes->group('medicalspecialty', function ($routes) {
$routes->get('/', 'Contact\MedicalSpecialty::index');
$routes->get('(:num)', 'Contact\MedicalSpecialty::show/$1');
$routes->post('/', 'Contact\MedicalSpecialty::create');
$routes->patch('/', 'Contact\MedicalSpecialty::update');
});
// ValueSet
$routes->group('valueset', function ($routes) {
$routes->get('/', 'ValueSet\ValueSet::index');
$routes->get('(:num)', 'ValueSet\ValueSet::show/$1');
$routes->get('valuesetdef/(:segment)', 'ValueSet\ValueSet::showByValueSetDef/$1');
$routes->post('/', 'ValueSet\ValueSet::create');
$routes->patch('/', 'ValueSet\ValueSet::update');
$routes->delete('/', 'ValueSet\ValueSet::delete');
});
$routes->group('valuesetdef', function ($routes) {
$routes->get('/', 'ValueSet\ValueSetDef::index');
$routes->get('(:segment)', 'ValueSet\ValueSetDef::show/$1');
$routes->post('/', 'ValueSet\ValueSetDef::create');
$routes->patch('/', 'ValueSet\ValueSetDef::update');
$routes->delete('/', 'ValueSet\ValueSetDef::delete');
});
// Counter
$routes->group('counter', function ($routes) {
$routes->get('/', 'Counter::index');
$routes->get('(:num)', 'Counter::show/$1');
$routes->post('/', 'Counter::create');
$routes->patch('/', 'Counter::update');
$routes->delete('/', 'Counter::delete');
});
// AreaGeo
$routes->group('areageo', function ($routes) {
$routes->get('/', 'AreaGeo::index');
$routes->get('provinces', 'AreaGeo::getProvinces');
$routes->get('cities', 'AreaGeo::getCities');
});
// Organization
$routes->group('organization', function ($routes) {
// Account
$routes->group('account', function ($routes) {
$routes->get('/', 'Organization\Account::index');
$routes->get('(:num)', 'Organization\Account::show/$1');
$routes->post('/', 'Organization\Account::create');
$routes->patch('/', 'Organization\Account::update');
$routes->delete('/', 'Organization\Account::delete');
});
// Site
$routes->group('site', function ($routes) {
$routes->get('/', 'Organization\Site::index');
$routes->get('(:num)', 'Organization\Site::show/$1');
$routes->post('/', 'Organization\Site::create');
$routes->patch('/', 'Organization\Site::update');
$routes->delete('/', 'Organization\Site::delete');
});
// Discipline
$routes->group('discipline', function ($routes) {
$routes->get('/', 'Organization\Discipline::index');
$routes->get('(:num)', 'Organization\Discipline::show/$1');
$routes->post('/', 'Organization\Discipline::create');
$routes->patch('/', 'Organization\Discipline::update');
$routes->delete('/', 'Organization\Discipline::delete');
});
// Department
$routes->group('department', function ($routes) {
$routes->get('/', 'Organization\Department::index');
$routes->get('(:num)', 'Organization\Department::show/$1');
$routes->post('/', 'Organization\Department::create');
$routes->patch('/', 'Organization\Department::update');
$routes->delete('/', 'Organization\Department::delete');
});
// Workstation
$routes->group('workstation', function ($routes) {
$routes->get('/', 'Organization\Workstation::index');
$routes->get('(:num)', 'Organization\Workstation::show/$1');
$routes->post('/', 'Organization\Workstation::create');
$routes->patch('/', 'Organization\Workstation::update');
$routes->delete('/', 'Organization\Workstation::delete');
});
});
// Specimen
$routes->group('specimen', function ($routes) {
$routes->group('containerdef', function ($routes) {
$routes->get('/', 'Specimen\ContainerDef::index');
$routes->get('(:num)', 'Specimen\ContainerDef::show/$1');
$routes->post('/', 'Specimen\ContainerDef::create');
$routes->patch('/', 'Specimen\ContainerDef::update');
});
$routes->group('prep', function ($routes) {
$routes->get('/', 'Specimen\Prep::index');
$routes->get('(:num)', 'Specimen\Prep::show/$1');
$routes->post('/', 'Specimen\Prep::create');
$routes->patch('/', 'Specimen\Prep::update');
});
$routes->group('status', function ($routes) {
$routes->get('/', 'Specimen\Status::index');
$routes->get('(:num)', 'Specimen\Status::show/$1');
$routes->post('/', 'Specimen\Status::create');
$routes->patch('/', 'Specimen\Status::update');
});
$routes->group('collection', function ($routes) {
$routes->get('/', 'Specimen\Collection::index');
$routes->get('(:num)', 'Specimen\Collection::show/$1');
$routes->post('/', 'Specimen\Collection::create');
$routes->patch('/', 'Specimen\Collection::update');
});
$routes->get('/', 'Specimen\Specimen::index');
$routes->get('(:num)', 'Specimen\Specimen::show/$1');
$routes->post('/', 'Specimen\Specimen::create');
$routes->patch('/', 'Specimen\Specimen::update');
});
// Tests
$routes->group('tests', function ($routes) {
$routes->get('/', 'Tests::index');
$routes->get('(:any)', 'Tests::show/$1');
$routes->post('/', 'Tests::create');
$routes->patch('/', 'Tests::update');
});
// Edge API - Integration with tiny-edge
$routes->group('edge', function ($routes) {
$routes->post('results', 'Edge::results');
$routes->get('orders', 'Edge::orders');
$routes->post('orders/(:num)/ack', 'Edge::ack/$1');
$routes->post('status', 'Edge::status');
});
});
// Khusus
/*
$routes->get('/api/zones', 'Zones::index');
$routes->get('/api/zones/synchronize', 'Zones::synchronize');
$routes->get('/api/zones/provinces', 'Zones::getProvinces');
$routes->get('/api/zones/cities', 'Zones::getCities');
*/