A clean and modular Express.js backend application for RSUD (Rumah Sakit Umum Daerah), designed using the principles of Clean Architecture.
- Node.js with Express.js (
express) — lightweight web framework - Prisma ORM (
prisma,@prisma/client) — modern ORM for database access - JWT (
jsonwebtoken) — secure authentication - PostgreSQL / Supabase — relational database
- bcrypt (
bcrypt) — password hashing - Session Management (
express-session) — manage user sessions - Cookie Handling (
cookie-parser,cookie-signature) — handle and sign cookies - CORS (
cors) — enable cross-origin resource sharing - Environment Configuration (
dotenv) — manage environment variables - File Upload (
multer) — handle multipart/form-data - Image Processing (
sharp) — resize and optimize images - Email Sending (
nodemailer) — send emails via SMTP - Task Scheduling (
node-cron) — schedule automated tasks - Google OAuth (
passport,passport-google-oauth20) — Google login authentication - Auto Reload During Development (
nodemon) — auto-reload server during development - API Documentation (
swagger-jsdoc,swagger-ui-express,swagger-ui-dist) — auto-generate API docs - HTTP Requests (
request,request-promise) — make HTTP requests (deprecated) - Timezone Handling (
moment-timezone) — manage and convert timezones
📦 Capstone-RSUD/
├── 📁 node_modules/ # Folder dependensi npm (auto-generated)
│
├── 📂 src/ # Source code utama
│ ├── 🛠️ configs/ # Konfigurasi global (DB, CORS, dll)
│ ├── 🧠 controllers/ # Logic untuk handle HTTP request
│ ├── 🧩 services/ # Business logic (dipanggil controller)
│ ├── 🚦 routes/ # Definisi endpoint / rute aplikasi
│ ├── 🔧 prisma/ # File schema & konfigurasi Prisma ORM
│ ├── 🛡️ middlewares/ # Middleware Express (auth, error handler, dll)
│ └── 🧰 utils/ # Fungsi bantu (validator, helper, dll)
│
├── 🧪 test/ # Folder untuk integration / unit testing
│
├── 🖼️ uploads/ # Tempat penyimpanan file upload
│ └── 📏 resized/ # Hasil resize gambar (via sharp)
│
├── 📄 .env # Variabel lingkungan (PORT, DB_URL, dll)
├── 📄 .gitignore # File & folder yang tidak di-push ke Git
├── 🚀 app.js # Entry point Express.js
└── 📜 package.json # Info project & daftar dependensiBefore installing, ensure you have the following prerequisites installed on your system:
- Node.js: The project requires Node.js to run. You can download it from Node.js official website.
- npm: npm (Node Package Manager) is used to manage the dependencies and should come installed with Node.js.
To set up the project for development on your local machine, please follow the steps below:
- First, clone this repository to your local machine using Git commands. For example:
git clone https://github.com/AnNur25/BE-RSUD.git
cd capstone-rsud-
Run the following command in the root directory of the project to install all necessary dependencies:
npm install
Once the installation is complete, you can start the application using one of the following methods:
-
npm
Automatically start using nodemon (if you have installed all the required dependencies and configured the value of "start" under the "scripts" to "nodemon app.js" in
package.jsonfile).npm start -
Directly using Node.js or nodemon
node index.jsornodemon index.js
Buat file .env di root project dan isi dengan variabel-variabel berikut:
# 🌐 === ENVIRONMENT VARIABLES ===
# 📦 Database
DATABASE_URL="" # Connection string ke database (PostgreSQL)
# 🚀 Server
PORT=3000 # Port server berjalan
# 🔐 Authentication
JWT_SECRET="" # Secret utama untuk JWT
REFRESH_SECRET_KEY="" # Secret untuk refresh token
COOKIE_SECRET="" # Secret untuk cookie signing
# 📧 Email (Nodemailer)
EMAIL_USER="" # Alamat email pengirim
EMAIL_PASS="" # App password SMTP
# 🌍 Frontend URL
FRONTEND_URL="" # Untuk redirect OAuth / CORS
# 🔐 Google OAuth2
GOOGLE_CLIENT_ID=""
GOOGLE_CLIENT_SECRET=""
GOOGLE_CALLBACK_URL="" # Contoh: http://localhost:3000/auth/google/callback
# 🧪 Deployment
VERCEL_ENV="" # Digunakan untuk environment check (dev/prod)
- Run
npx prisma migrate devin the capstone-rsud/src/ directory. - Wait for the database migration to be completed.
- Voila, your database is ready!
- After that, Run
npm run seedin the capstone-rsud directory. - Ta-da, you have some data in your database!
Ahmad Farid Zainudin