Skip to content

Commit beac1f9

Browse files
committed
Merge branch 'linas' into dev
2 parents 3f86616 + 2238c5f commit beac1f9

47 files changed

Lines changed: 5607 additions & 74 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api-gateway/src/app.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ import healthRoutes from './routes/health';
44
import { patientAuthProxy } from './proxy/patient.auth.proxy';
55
import { patientDataProxy } from './proxy/patient.data.proxy';
66
import { staffAuthProxy } from './proxy/staff.auth.proxy';
7-
import { staffDataProxy } from './proxy/staff.data.proxy';
7+
// import { staffDataProxy } from './proxy/staff.data.proxy';
8+
import staffDataRouter from './routes/staff.data.router';
89
import { authenticate } from './middlewares/auth.middleware';
910
import { requirePatientSelf } from './middlewares/patient.guard';
1011

1112
const app = express();
12-
13-
app.use(cors());
13+
app.use(
14+
cors({
15+
origin: 'http://localhost:3000',
16+
credentials: true,
17+
})
18+
);
1419

1520
// health
1621
app.use('/health', healthRoutes);
@@ -21,6 +26,6 @@ app.use('/patients/public', patientAuthProxy);
2126
app.use('/patients', authenticate, requirePatientSelf, patientDataProxy);
2227

2328
app.use('/staff/public', staffAuthProxy);
24-
app.use('/staff', authenticate, staffDataProxy);
29+
app.use('/staff', authenticate, staffDataRouter);
2530

2631
export default app;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Response, NextFunction } from 'express';
2+
import { AuthenticatedRequest } from './auth.middleware';
3+
4+
// what actions exist in the system
5+
export type Permission = 'CREATE_STAFF' | 'UPDATE_STAFF' | 'DEACTIVATE_STAFF';
6+
7+
// staff role → permissions
8+
const STAFF_ROLE_PERMISSIONS: Record<string, Permission[]> = {
9+
DOCTOR: [],
10+
NURSE: [],
11+
};
12+
13+
export function requirePermission(permission: Permission) {
14+
return (req: AuthenticatedRequest, res: Response, next: NextFunction) => {
15+
const user = req.user;
16+
17+
if (!user) {
18+
return res.status(401).json({ error: 'Unauthorized' });
19+
}
20+
21+
// ✅ ADMIN can do everything
22+
if (user.type === 'ADMIN') {
23+
return next();
24+
}
25+
26+
// ❌ STAFF cannot do admin actions
27+
return res.status(403).json({ error: 'Forbidden' });
28+
};
29+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import express from 'express';
2+
import { requirePermission } from '../middlewares/rbac.middleware';
3+
import { staffDataProxy } from '../proxy/staff.data.proxy';
4+
5+
const router = express.Router();
6+
7+
// 🔒 ADMIN ONLY: create staff
8+
router.post('/', requirePermission('CREATE_STAFF'), staffDataProxy);
9+
10+
// everything else just passes through
11+
router.use(staffDataProxy);
12+
13+
export default router;

frontend/.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts

frontend/.gitkeep

Whitespace-only changes.

frontend/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22+
23+
## Learn More
24+
25+
To learn more about Next.js, take a look at the following resources:
26+
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31+
32+
## Deploy on Vercel
33+
34+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35+
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

frontend/eslint.config.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { defineConfig, globalIgnores } from "eslint/config";
2+
import nextVitals from "eslint-config-next/core-web-vitals";
3+
import nextTs from "eslint-config-next/typescript";
4+
5+
const eslintConfig = defineConfig([
6+
...nextVitals,
7+
...nextTs,
8+
// Override default ignores of eslint-config-next.
9+
globalIgnores([
10+
// Default ignores of eslint-config-next:
11+
".next/**",
12+
"out/**",
13+
"build/**",
14+
"next-env.d.ts",
15+
]),
16+
]);
17+
18+
export default eslintConfig;

frontend/next.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { NextConfig } from 'next';
2+
3+
const nextConfig: NextConfig = {
4+
/* config options here */
5+
};
6+
7+
export default nextConfig;

frontend/package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "frontend",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "next start",
9+
"lint": "eslint"
10+
},
11+
"dependencies": {
12+
"axios": "^1.13.5",
13+
"next": "16.1.6",
14+
"react": "19.2.3",
15+
"react-dom": "19.2.3",
16+
"zod": "^4.3.6"
17+
},
18+
"devDependencies": {
19+
"@tailwindcss/postcss": "^4",
20+
"@types/node": "^20",
21+
"@types/react": "^19",
22+
"@types/react-dom": "^19",
23+
"eslint": "^9",
24+
"eslint-config-next": "16.1.6",
25+
"tailwindcss": "^4",
26+
"typescript": "^5"
27+
}
28+
}

0 commit comments

Comments
 (0)