pearlgw 1 hónap óta
szülő
commit
780b273ea4
100 módosított fájl, 5604 hozzáadás és 2655 törlés
  1. 0 6
      config/config.js
  2. 15 0
      config/config.ts
  3. 0 10
      config/keycloak.js
  4. 21 0
      config/keycloak.ts
  5. 0 53
      index.js
  6. 80 0
      index.ts
  7. 391 8
      package-lock.json
  8. 20 4
      package.json
  9. 0 98
      prisma/seeders/DatabaseSeeder.js
  10. 101 0
      prisma/seeders/DatabaseSeeder.ts
  11. 0 134
      prisma/seeders/HospitalSeeder.js
  12. 260 0
      prisma/seeders/HospitalSeeder.ts
  13. 8 8
      prisma/seeders/ProvinceSeeder.js
  14. 0 41
      prisma/seeders/UserAreaSeeder.js
  15. 82 0
      prisma/seeders/UserAreaSeeder.ts
  16. 0 148
      prisma/seeders/UserSeeder.js
  17. 306 0
      prisma/seeders/UserSeeder.ts
  18. 0 57
      prisma/seeders/VendorSeeder.js
  19. 121 0
      prisma/seeders/VendorSeeder.ts
  20. 0 62
      prisma/seeders/city/AcehCitySeeder.js
  21. 124 0
      prisma/seeders/city/AcehCitySeeder.ts
  22. 0 48
      prisma/seeders/city/BaliCitySeeder.js
  23. 96 0
      prisma/seeders/city/BaliCitySeeder.ts
  24. 0 47
      prisma/seeders/city/BantenCitySeeder.js
  25. 93 0
      prisma/seeders/city/BantenCitySeeder.ts
  26. 0 47
      prisma/seeders/city/BengkuluCitySeeder.js
  27. 96 0
      prisma/seeders/city/BengkuluCitySeeder.ts
  28. 0 42
      prisma/seeders/city/DIYogyakartaCitySeeder.js
  29. 83 0
      prisma/seeders/city/DIYogyakartaCitySeeder.ts
  30. 0 45
      prisma/seeders/city/DKIJakartaCitySeeder.js
  31. 90 0
      prisma/seeders/city/DKIJakartaCitySeeder.ts
  32. 0 45
      prisma/seeders/city/GorontaloCitySeeder.js
  33. 89 0
      prisma/seeders/city/GorontaloCitySeeder.ts
  34. 0 50
      prisma/seeders/city/JambiCitySeeder.js
  35. 100 0
      prisma/seeders/city/JambiCitySeeder.ts
  36. 0 66
      prisma/seeders/city/JawaBaratCitySeeder.js
  37. 131 0
      prisma/seeders/city/JawaBaratCitySeeder.ts
  38. 0 74
      prisma/seeders/city/JawaTengahCitySeeder.js
  39. 147 0
      prisma/seeders/city/JawaTengahCitySeeder.ts
  40. 0 77
      prisma/seeders/city/JawaTimurCitySeeder.js
  41. 153 0
      prisma/seeders/city/JawaTimurCitySeeder.ts
  42. 0 53
      prisma/seeders/city/KalimantanBaratCitySeeder.js
  43. 105 0
      prisma/seeders/city/KalimantanBaratCitySeeder.ts
  44. 0 52
      prisma/seeders/city/KalimantanSelatanCitySeeder.js
  45. 103 0
      prisma/seeders/city/KalimantanSelatanCitySeeder.ts
  46. 0 53
      prisma/seeders/city/KalimantanTengahCitySeeder.js
  47. 105 0
      prisma/seeders/city/KalimantanTengahCitySeeder.ts
  48. 0 49
      prisma/seeders/city/KalimantanTimurCitySeeder.js
  49. 98 0
      prisma/seeders/city/KalimantanTimurCitySeeder.ts
  50. 0 44
      prisma/seeders/city/KalimantanUtaraCitySeeder.js
  51. 87 0
      prisma/seeders/city/KalimantanUtaraCitySeeder.ts
  52. 0 46
      prisma/seeders/city/KepulauanBangkaBelitungCitySeeder.js
  53. 91 0
      prisma/seeders/city/KepulauanBangkaBelitungCitySeeder.ts
  54. 0 46
      prisma/seeders/city/KepulauanRiauCitySeeder.js
  55. 91 0
      prisma/seeders/city/KepulauanRiauCitySeeder.ts
  56. 0 54
      prisma/seeders/city/LampungCitySeeder.js
  57. 107 0
      prisma/seeders/city/LampungCitySeeder.ts
  58. 0 50
      prisma/seeders/city/MalukuCitySeeder.js
  59. 99 0
      prisma/seeders/city/MalukuCitySeeder.ts
  60. 0 49
      prisma/seeders/city/MalukuUtaraCitySeeder.js
  61. 97 0
      prisma/seeders/city/MalukuUtaraCitySeeder.ts
  62. 0 49
      prisma/seeders/city/NusaTenggaraBaratCitySeeder.js
  63. 97 0
      prisma/seeders/city/NusaTenggaraBaratCitySeeder.ts
  64. 0 61
      prisma/seeders/city/NusaTenggaraTimurCitySeeder.js
  65. 121 0
      prisma/seeders/city/NusaTenggaraTimurCitySeeder.ts
  66. 0 46
      prisma/seeders/city/PapuaBaratCitySeeder.js
  67. 92 0
      prisma/seeders/city/PapuaBaratCitySeeder.ts
  68. 0 45
      prisma/seeders/city/PapuaBaratDayaCitySeeder.js
  69. 90 0
      prisma/seeders/city/PapuaBaratDayaCitySeeder.ts
  70. 0 46
      prisma/seeders/city/PapuaCitySeeder.js
  71. 93 0
      prisma/seeders/city/PapuaCitySeeder.ts
  72. 0 45
      prisma/seeders/city/PapuaPegununganCitySeeder.js
  73. 92 0
      prisma/seeders/city/PapuaPegununganCitySeeder.ts
  74. 0 41
      prisma/seeders/city/PapuaSelatanCitySeeder.js
  75. 84 0
      prisma/seeders/city/PapuaSelatanCitySeeder.ts
  76. 0 45
      prisma/seeders/city/PapuaTengahCitySeeder.js
  77. 92 0
      prisma/seeders/city/PapuaTengahCitySeeder.ts
  78. 0 49
      prisma/seeders/city/RiauCitySeeder.js
  79. 100 0
      prisma/seeders/city/RiauCitySeeder.ts
  80. 0 43
      prisma/seeders/city/SulawesiBaratCitySeeder.js
  81. 88 0
      prisma/seeders/city/SulawesiBaratCitySeeder.ts
  82. 0 61
      prisma/seeders/city/SulawesiSelatanCitySeeder.js
  83. 124 0
      prisma/seeders/city/SulawesiSelatanCitySeeder.ts
  84. 0 50
      prisma/seeders/city/SulawesiTengahCitySeeder.js
  85. 102 0
      prisma/seeders/city/SulawesiTengahCitySeeder.ts
  86. 0 54
      prisma/seeders/city/SulawesiTenggaraCitySeeder.js
  87. 110 0
      prisma/seeders/city/SulawesiTenggaraCitySeeder.ts
  88. 0 52
      prisma/seeders/city/SulawesiUtaraCitySeeder.js
  89. 105 0
      prisma/seeders/city/SulawesiUtaraCitySeeder.ts
  90. 0 56
      prisma/seeders/city/SumateraBaratCitySeeder.js
  91. 113 0
      prisma/seeders/city/SumateraBaratCitySeeder.ts
  92. 0 54
      prisma/seeders/city/SumateraSelatanCitySeeder.js
  93. 110 0
      prisma/seeders/city/SumateraSelatanCitySeeder.ts
  94. 0 70
      prisma/seeders/city/SumateraUtaraCitySeeder.js
  95. 142 0
      prisma/seeders/city/SumateraUtaraCitySeeder.ts
  96. 0 61
      src/controllers/admin/CityController.js
  97. 134 0
      src/controllers/admin/CityController.ts
  98. 0 61
      src/controllers/admin/ProvinceController.js
  99. 125 0
      src/controllers/admin/ProvinceController.ts
  100. 0 0
      src/middleware/CheckRole.js

+ 0 - 6
config/config.js

@@ -1,6 +0,0 @@
1
-require('dotenv').config();
2
-
3
-module.exports = {
4
-  port: process.env.PORT || 3000,
5
-  BASE_URL: process.env.BASE_URL || 'http://localhost:3200'
6
-};

+ 15 - 0
config/config.ts

@@ -0,0 +1,15 @@
1
+import dotenv from 'dotenv';
2
+
3
+dotenv.config();
4
+
5
+export const config = {
6
+  port: process.env.PORT ? parseInt(process.env.PORT) : 3000,
7
+  BASE_URL: process.env.BASE_URL || 'http://localhost:3200',
8
+};
9
+
10
+// require('dotenv').config();
11
+
12
+// module.exports = {
13
+//   port: process.env.PORT || 3000,
14
+//   BASE_URL: process.env.BASE_URL || 'http://localhost:3200'
15
+// };

+ 0 - 10
config/keycloak.js

@@ -1,10 +0,0 @@
1
-require('dotenv').config();
2
-
3
-module.exports = {
4
-    KEYCLOAK_TOKEN_URL: process.env.KEYCLOAK_TOKEN_URL,
5
-    CLIENT_ID: process.env.CLIENT_ID,
6
-    CLIENT_SECRET: process.env.CLIENT_SECRET,
7
-    JWT_SECRET: process.env.JWT_SECRET,
8
-    KEYCLOAK_ADMIN_URL: process.env.KEYCLOAK_ADMIN_URL,
9
-    KEYCLOAK_REALM: process.env.KEYCLOAK_REALM,
10
-};

+ 21 - 0
config/keycloak.ts

@@ -0,0 +1,21 @@
1
+import dotenv from 'dotenv';
2
+
3
+dotenv.config();
4
+
5
+export const KEYCLOAK_TOKEN_URL = process.env.KEYCLOAK_TOKEN_URL as string;
6
+export const CLIENT_ID = process.env.CLIENT_ID as string;
7
+export const CLIENT_SECRET = process.env.CLIENT_SECRET as string;
8
+export const JWT_SECRET = process.env.JWT_SECRET as string;
9
+export const KEYCLOAK_ADMIN_URL = process.env.KEYCLOAK_ADMIN_URL as string;
10
+export const KEYCLOAK_REALM = process.env.KEYCLOAK_REALM as string;
11
+
12
+// require('dotenv').config();
13
+
14
+// module.exports = {
15
+//     KEYCLOAK_TOKEN_URL: process.env.KEYCLOAK_TOKEN_URL,
16
+//     CLIENT_ID: process.env.CLIENT_ID,
17
+//     CLIENT_SECRET: process.env.CLIENT_SECRET,
18
+//     JWT_SECRET: process.env.JWT_SECRET,
19
+//     KEYCLOAK_ADMIN_URL: process.env.KEYCLOAK_ADMIN_URL,
20
+//     KEYCLOAK_REALM: process.env.KEYCLOAK_REALM,
21
+// };

+ 0 - 53
index.js

@@ -1,53 +0,0 @@
1
-const express = require('express')
2
-const cors = require('cors')
3
-const errorHandler = require('./src/middleware/ErrorHandler.js')
4
-const app = express()
5
-const path = require('path');
6
-// const hospitalRoutes = require('./src/routes/HospitalRoute.js')
7
-const provinceRoutes = require('./src/routes/admin/ProvinceRoute.js')
8
-const authRoutes = require('./src/routes/auth/AuthRoute.js')
9
-// const userRoutes = require('./src/routes/UserRoute.js')
10
-const cityRoutes = require('./src/routes/admin/CityRoute.js')
11
-const salesRoutes = require('./src/routes/admin/SalesRoute.js')
12
-const adminRoutes = require('./src/routes/superadmin/AdminRoute.js')
13
-const hospitalRoutes = require('./src/routes/admin/HospitalRoute.js')
14
-const salesHospitalRoutes = require('./src/routes/sales/HospitalRoute.js')
15
-const vendorRoutes = require('./src/routes/admin/VendorRoute.js')
16
-const logRoutes = require('./src/routes/superadmin/LogRoute.js')
17
-const areaRoutes = require('./src/routes/sales/AreaRoute.js')
18
-const vendorSalesRoutes = require('./src/routes/sales/VendorRoute.js')
19
-const { port } = require('./config/config.js')
20
-const keycloak = require('./src/middleware/Keycloak.js');
21
-require("./src/utils/Scheduler.js")
22
-
23
-app.use(cors())
24
-app.use(keycloak.middleware());
25
-app.use(express.json())
26
-app.use('/storage/', express.static(path.join(__dirname, 'storage/')));
27
-
28
-const apiV1 = express.Router();
29
-
30
-// apiV1.use('/hospitals', hospitalRoutes);
31
-apiV1.use('/province', provinceRoutes);
32
-apiV1.use('/auth', authRoutes);
33
-// apiV1.use('/user', userRoutes);
34
-apiV1.use('/city', cityRoutes);
35
-apiV1.use('/sales', salesRoutes);
36
-apiV1.use('/admin', adminRoutes);
37
-apiV1.use('/hospital', hospitalRoutes);
38
-apiV1.use('/hospital-area', salesHospitalRoutes);
39
-apiV1.use('/vendor', vendorRoutes);
40
-apiV1.use('/logs', logRoutes);
41
-apiV1.use('/area', areaRoutes);
42
-apiV1.use('/vendor-sales', vendorSalesRoutes);
43
-
44
-app.get('/', (req, res) => {
45
-    res.send('Selamat Datang di API Radar Farmagitechs');
46
-});
47
-
48
-app.use('/v1/api', apiV1);
49
-app.use(errorHandler);
50
-
51
-app.listen(port, () => {
52
-    console.log(`Server started on port ${port}`);
53
-})

+ 80 - 0
index.ts

@@ -0,0 +1,80 @@
1
+import express, { Application } from 'express';
2
+import cors from 'cors';
3
+import path from 'path';
4
+import bodyParser from 'body-parser';
5
+
6
+import { errorHandler } from './src/middleware/ErrorHandler';
7
+import keycloak from './src/middleware/Keycloak';
8
+import { config } from './config/config';
9
+
10
+import provinceRoutes from './src/routes/admin/ProvinceRoute';
11
+// import authRoutes from './src/routes/auth/AuthRoute.js';
12
+import cityRoutes from './src/routes/admin/CityRoute';
13
+// import salesRoutes from './src/routes/admin/SalesRoute.js';
14
+// import adminRoutes from './src/routes/superadmin/AdminRoute.js';
15
+// import hospitalRoutes from './src/routes/admin/HospitalRoute.js';
16
+// import salesHospitalRoutes from './src/routes/sales/HospitalRoute.js';
17
+// import vendorRoutes from './src/routes/admin/VendorRoute.js';
18
+// import logRoutes from './src/routes/superadmin/LogRoute.js';
19
+// import areaRoutes from './src/routes/sales/AreaRoute.js';
20
+// import vendorSalesRoutes from './src/routes/sales/VendorRoute.js';
21
+
22
+import './src/utils/Scheduler'; // dijalankan di awal
23
+
24
+// const express = require('express')
25
+// const cors = require('cors')
26
+// const errorHandler = require('./src/middleware/ErrorHandler.js')
27
+// const app = express()
28
+// const path = require('path');
29
+// // const hospitalRoutes = require('./src/routes/HospitalRoute.js')
30
+// const provinceRoutes = require('./src/routes/admin/ProvinceRoute.js')
31
+// const authRoutes = require('./src/routes/auth/AuthRoute.js')
32
+// // const userRoutes = require('./src/routes/UserRoute.js')
33
+// const cityRoutes = require('./src/routes/admin/CityRoute.js')
34
+// const salesRoutes = require('./src/routes/admin/SalesRoute.js')
35
+// const adminRoutes = require('./src/routes/superadmin/AdminRoute.js')
36
+// const hospitalRoutes = require('./src/routes/admin/HospitalRoute.js')
37
+// const salesHospitalRoutes = require('./src/routes/sales/HospitalRoute.js')
38
+// const vendorRoutes = require('./src/routes/admin/VendorRoute.js')
39
+// const logRoutes = require('./src/routes/superadmin/LogRoute.js')
40
+// const areaRoutes = require('./src/routes/sales/AreaRoute.js')
41
+// const vendorSalesRoutes = require('./src/routes/sales/VendorRoute.js')
42
+// const { port } = require('./config/config.js')
43
+// const keycloak = require('./src/middleware/Keycloak.js');
44
+// import bodyParser from 'body-parser';
45
+// require("./src/utils/Scheduler.js")
46
+
47
+const app: Application = express();
48
+
49
+app.use(cors());
50
+app.use(bodyParser.json());
51
+app.use(keycloak.middleware());
52
+app.use(express.json())
53
+app.use('/storage/', express.static(path.join(__dirname, 'storage/')));
54
+
55
+const apiV1 = express.Router();
56
+
57
+// apiV1.use('/hospitals', hospitalRoutes);
58
+apiV1.use('/province', provinceRoutes);
59
+// apiV1.use('/auth', authRoutes);
60
+// apiV1.use('/user', userRoutes);
61
+apiV1.use('/city', cityRoutes);
62
+// apiV1.use('/sales', salesRoutes);
63
+// apiV1.use('/admin', adminRoutes);
64
+// apiV1.use('/hospital', hospitalRoutes);
65
+// apiV1.use('/hospital-area', salesHospitalRoutes);
66
+// apiV1.use('/vendor', vendorRoutes);
67
+// apiV1.use('/logs', logRoutes);
68
+// apiV1.use('/area', areaRoutes);
69
+// apiV1.use('/vendor-sales', vendorSalesRoutes);
70
+
71
+app.get('/', (req, res) => {
72
+    res.send('Selamat Datang di API Radar Farmagitechs');
73
+});
74
+
75
+app.use('/v1/api', apiV1);
76
+app.use(errorHandler);
77
+
78
+app.listen(config.port, () => {
79
+    console.log(`Server started on port ${config.port}`);
80
+})

+ 391 - 8
package-lock.json

@@ -13,6 +13,7 @@
13 13
         "@prisma/client": "^6.10.1",
14 14
         "axios": "^1.10.0",
15 15
         "bcrypt": "^6.0.0",
16
+        "body-parser": "^2.2.0",
16 17
         "cors": "^2.8.5",
17 18
         "date-fns": "^4.1.0",
18 19
         "date-fns-tz": "^3.2.0",
@@ -20,15 +21,39 @@
20 21
         "dayjs-plugin-utc": "^0.1.2",
21 22
         "dotenv": "^16.5.0",
22 23
         "express": "^5.1.0",
24
+        "http-status-codes": "^2.3.0",
23 25
         "jsonwebtoken": "^9.0.2",
24 26
         "keycloak-connect": "^26.1.1",
25 27
         "multer": "^2.0.1",
26 28
         "node-cron": "^4.2.1",
27 29
         "pg": "^8.16.2",
28
-        "qs": "^6.14.0"
30
+        "qs": "^6.14.0",
31
+        "zod": "^4.0.5"
29 32
       },
30 33
       "devDependencies": {
31
-        "prisma": "^6.10.1"
34
+        "@types/bcrypt": "^5.0.2",
35
+        "@types/cors": "^2.8.19",
36
+        "@types/express": "^5.0.3",
37
+        "@types/jsonwebtoken": "^9.0.10",
38
+        "@types/keycloak-connect": "^4.5.4",
39
+        "@types/multer": "^2.0.0",
40
+        "@types/node": "^24.0.14",
41
+        "prisma": "^6.10.1",
42
+        "ts-node": "^10.9.2",
43
+        "typescript": "^5.8.3"
44
+      }
45
+    },
46
+    "node_modules/@cspotcode/source-map-support": {
47
+      "version": "0.8.1",
48
+      "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
49
+      "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
50
+      "dev": true,
51
+      "license": "MIT",
52
+      "dependencies": {
53
+        "@jridgewell/trace-mapping": "0.3.9"
54
+      },
55
+      "engines": {
56
+        "node": ">=12"
32 57
       }
33 58
     },
34 59
     "node_modules/@faker-js/faker": {
@@ -47,6 +72,34 @@
47 72
         "npm": ">=9.0.0"
48 73
       }
49 74
     },
75
+    "node_modules/@jridgewell/resolve-uri": {
76
+      "version": "3.1.2",
77
+      "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
78
+      "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
79
+      "dev": true,
80
+      "license": "MIT",
81
+      "engines": {
82
+        "node": ">=6.0.0"
83
+      }
84
+    },
85
+    "node_modules/@jridgewell/sourcemap-codec": {
86
+      "version": "1.5.4",
87
+      "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.4.tgz",
88
+      "integrity": "sha512-VT2+G1VQs/9oz078bLrYbecdZKs912zQlkelYpuf+SXF+QvZDYJlbx/LSx+meSAwdDFnF8FVXW92AVjjkVmgFw==",
89
+      "dev": true,
90
+      "license": "MIT"
91
+    },
92
+    "node_modules/@jridgewell/trace-mapping": {
93
+      "version": "0.3.9",
94
+      "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
95
+      "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
96
+      "dev": true,
97
+      "license": "MIT",
98
+      "dependencies": {
99
+        "@jridgewell/resolve-uri": "^3.0.3",
100
+        "@jridgewell/sourcemap-codec": "^1.4.10"
101
+      }
102
+    },
50 103
     "node_modules/@prisma/client": {
51 104
       "version": "6.10.1",
52 105
       "resolved": "https://registry.npmjs.org/@prisma/client/-/client-6.10.1.tgz",
@@ -143,16 +196,199 @@
143 196
       "license": "MIT",
144 197
       "optional": true
145 198
     },
199
+    "node_modules/@tsconfig/node10": {
200
+      "version": "1.0.11",
201
+      "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz",
202
+      "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==",
203
+      "dev": true,
204
+      "license": "MIT"
205
+    },
206
+    "node_modules/@tsconfig/node12": {
207
+      "version": "1.0.11",
208
+      "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz",
209
+      "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==",
210
+      "dev": true,
211
+      "license": "MIT"
212
+    },
213
+    "node_modules/@tsconfig/node14": {
214
+      "version": "1.0.3",
215
+      "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz",
216
+      "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==",
217
+      "dev": true,
218
+      "license": "MIT"
219
+    },
220
+    "node_modules/@tsconfig/node16": {
221
+      "version": "1.0.4",
222
+      "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz",
223
+      "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==",
224
+      "dev": true,
225
+      "license": "MIT"
226
+    },
227
+    "node_modules/@types/bcrypt": {
228
+      "version": "5.0.2",
229
+      "resolved": "https://registry.npmjs.org/@types/bcrypt/-/bcrypt-5.0.2.tgz",
230
+      "integrity": "sha512-6atioO8Y75fNcbmj0G7UjI9lXN2pQ/IGJ2FWT4a/btd0Lk9lQalHLKhkgKVZ3r+spnmWUKfbMi1GEe9wyHQfNQ==",
231
+      "dev": true,
232
+      "license": "MIT",
233
+      "dependencies": {
234
+        "@types/node": "*"
235
+      }
236
+    },
237
+    "node_modules/@types/body-parser": {
238
+      "version": "1.19.6",
239
+      "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.6.tgz",
240
+      "integrity": "sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g==",
241
+      "dev": true,
242
+      "license": "MIT",
243
+      "dependencies": {
244
+        "@types/connect": "*",
245
+        "@types/node": "*"
246
+      }
247
+    },
248
+    "node_modules/@types/connect": {
249
+      "version": "3.4.38",
250
+      "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz",
251
+      "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==",
252
+      "dev": true,
253
+      "license": "MIT",
254
+      "dependencies": {
255
+        "@types/node": "*"
256
+      }
257
+    },
258
+    "node_modules/@types/cors": {
259
+      "version": "2.8.19",
260
+      "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.19.tgz",
261
+      "integrity": "sha512-mFNylyeyqN93lfe/9CSxOGREz8cpzAhH+E93xJ4xWQf62V8sQ/24reV2nyzUWM6H6Xji+GGHpkbLe7pVoUEskg==",
262
+      "dev": true,
263
+      "license": "MIT",
264
+      "dependencies": {
265
+        "@types/node": "*"
266
+      }
267
+    },
268
+    "node_modules/@types/express": {
269
+      "version": "5.0.3",
270
+      "resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.3.tgz",
271
+      "integrity": "sha512-wGA0NX93b19/dZC1J18tKWVIYWyyF2ZjT9vin/NRu0qzzvfVzWjs04iq2rQ3H65vCTQYlRqs3YHfY7zjdV+9Kw==",
272
+      "dev": true,
273
+      "license": "MIT",
274
+      "dependencies": {
275
+        "@types/body-parser": "*",
276
+        "@types/express-serve-static-core": "^5.0.0",
277
+        "@types/serve-static": "*"
278
+      }
279
+    },
280
+    "node_modules/@types/express-serve-static-core": {
281
+      "version": "5.0.7",
282
+      "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-5.0.7.tgz",
283
+      "integrity": "sha512-R+33OsgWw7rOhD1emjU7dzCDHucJrgJXMA5PYCzJxVil0dsyx5iBEPHqpPfiKNJQb7lZ1vxwoLR4Z87bBUpeGQ==",
284
+      "dev": true,
285
+      "license": "MIT",
286
+      "dependencies": {
287
+        "@types/node": "*",
288
+        "@types/qs": "*",
289
+        "@types/range-parser": "*",
290
+        "@types/send": "*"
291
+      }
292
+    },
293
+    "node_modules/@types/http-errors": {
294
+      "version": "2.0.5",
295
+      "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.5.tgz",
296
+      "integrity": "sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg==",
297
+      "dev": true,
298
+      "license": "MIT"
299
+    },
300
+    "node_modules/@types/jsonwebtoken": {
301
+      "version": "9.0.10",
302
+      "resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-9.0.10.tgz",
303
+      "integrity": "sha512-asx5hIG9Qmf/1oStypjanR7iKTv0gXQ1Ov/jfrX6kS/EO0OFni8orbmGCn0672NHR3kXHwpAwR+B368ZGN/2rA==",
304
+      "dev": true,
305
+      "license": "MIT",
306
+      "dependencies": {
307
+        "@types/ms": "*",
308
+        "@types/node": "*"
309
+      }
310
+    },
311
+    "node_modules/@types/keycloak-connect": {
312
+      "version": "4.5.4",
313
+      "resolved": "https://registry.npmjs.org/@types/keycloak-connect/-/keycloak-connect-4.5.4.tgz",
314
+      "integrity": "sha512-U1N17qpu9vfZj2jW4StXJkEOZ+26mAhKxMtxSo8mUIviSB1BvXNjul98hJXz0UHQqod6RkEb0xxfLaYuXHEsiw==",
315
+      "dev": true,
316
+      "license": "MIT",
317
+      "dependencies": {
318
+        "@types/express": "*"
319
+      }
320
+    },
321
+    "node_modules/@types/mime": {
322
+      "version": "1.3.5",
323
+      "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz",
324
+      "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==",
325
+      "dev": true,
326
+      "license": "MIT"
327
+    },
328
+    "node_modules/@types/ms": {
329
+      "version": "2.1.0",
330
+      "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz",
331
+      "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==",
332
+      "dev": true,
333
+      "license": "MIT"
334
+    },
335
+    "node_modules/@types/multer": {
336
+      "version": "2.0.0",
337
+      "resolved": "https://registry.npmjs.org/@types/multer/-/multer-2.0.0.tgz",
338
+      "integrity": "sha512-C3Z9v9Evij2yST3RSBktxP9STm6OdMc5uR1xF1SGr98uv8dUlAL2hqwrZ3GVB3uyMyiegnscEK6PGtYvNrjTjw==",
339
+      "dev": true,
340
+      "license": "MIT",
341
+      "dependencies": {
342
+        "@types/express": "*"
343
+      }
344
+    },
146 345
     "node_modules/@types/node": {
147
-      "version": "24.0.10",
148
-      "resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.10.tgz",
149
-      "integrity": "sha512-ENHwaH+JIRTDIEEbDK6QSQntAYGtbvdDXnMXnZaZ6k13Du1dPMmprkEHIL7ok2Wl2aZevetwTAb5S+7yIF+enA==",
346
+      "version": "24.0.14",
347
+      "resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.14.tgz",
348
+      "integrity": "sha512-4zXMWD91vBLGRtHK3YbIoFMia+1nqEz72coM42C5ETjnNCa/heoj7NT1G67iAfOqMmcfhuCZ4uNpyz8EjlAejw==",
349
+      "devOptional": true,
150 350
       "license": "MIT",
151
-      "optional": true,
152 351
       "dependencies": {
153 352
         "undici-types": "~7.8.0"
154 353
       }
155 354
     },
355
+    "node_modules/@types/qs": {
356
+      "version": "6.14.0",
357
+      "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.14.0.tgz",
358
+      "integrity": "sha512-eOunJqu0K1923aExK6y8p6fsihYEn/BYuQ4g0CxAAgFc4b/ZLN4CrsRZ55srTdqoiLzU2B2evC+apEIxprEzkQ==",
359
+      "dev": true,
360
+      "license": "MIT"
361
+    },
362
+    "node_modules/@types/range-parser": {
363
+      "version": "1.2.7",
364
+      "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz",
365
+      "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==",
366
+      "dev": true,
367
+      "license": "MIT"
368
+    },
369
+    "node_modules/@types/send": {
370
+      "version": "0.17.5",
371
+      "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.5.tgz",
372
+      "integrity": "sha512-z6F2D3cOStZvuk2SaP6YrwkNO65iTZcwA2ZkSABegdkAh/lf+Aa/YQndZVfmEXT5vgAp6zv06VQ3ejSVjAny4w==",
373
+      "dev": true,
374
+      "license": "MIT",
375
+      "dependencies": {
376
+        "@types/mime": "^1",
377
+        "@types/node": "*"
378
+      }
379
+    },
380
+    "node_modules/@types/serve-static": {
381
+      "version": "1.15.8",
382
+      "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.8.tgz",
383
+      "integrity": "sha512-roei0UY3LhpOJvjbIP6ZZFngyLKl5dskOtDhxY5THRSpO+ZI+nzJ+m5yUMzGrp89YRa7lvknKkMYjqQFGwA7Sg==",
384
+      "dev": true,
385
+      "license": "MIT",
386
+      "dependencies": {
387
+        "@types/http-errors": "*",
388
+        "@types/node": "*",
389
+        "@types/send": "*"
390
+      }
391
+    },
156 392
     "node_modules/@types/yauzl": {
157 393
       "version": "2.10.3",
158 394
       "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.3.tgz",
@@ -176,6 +412,32 @@
176 412
         "node": ">= 0.6"
177 413
       }
178 414
     },
415
+    "node_modules/acorn": {
416
+      "version": "8.15.0",
417
+      "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",
418
+      "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
419
+      "dev": true,
420
+      "license": "MIT",
421
+      "bin": {
422
+        "acorn": "bin/acorn"
423
+      },
424
+      "engines": {
425
+        "node": ">=0.4.0"
426
+      }
427
+    },
428
+    "node_modules/acorn-walk": {
429
+      "version": "8.3.4",
430
+      "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz",
431
+      "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==",
432
+      "dev": true,
433
+      "license": "MIT",
434
+      "dependencies": {
435
+        "acorn": "^8.11.0"
436
+      },
437
+      "engines": {
438
+        "node": ">=0.4.0"
439
+      }
440
+    },
179 441
     "node_modules/agent-base": {
180 442
       "version": "7.1.3",
181 443
       "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz",
@@ -192,6 +454,13 @@
192 454
       "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==",
193 455
       "license": "MIT"
194 456
     },
457
+    "node_modules/arg": {
458
+      "version": "4.1.3",
459
+      "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
460
+      "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==",
461
+      "dev": true,
462
+      "license": "MIT"
463
+    },
195 464
     "node_modules/asn1.js": {
196 465
       "version": "5.4.1",
197 466
       "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz",
@@ -470,6 +739,13 @@
470 739
         "node": ">= 0.10"
471 740
       }
472 741
     },
742
+    "node_modules/create-require": {
743
+      "version": "1.1.1",
744
+      "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
745
+      "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
746
+      "dev": true,
747
+      "license": "MIT"
748
+    },
473 749
     "node_modules/data-uri-to-buffer": {
474 750
       "version": "6.0.2",
475 751
       "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz",
@@ -568,6 +844,16 @@
568 844
         "node": ">= 0.8"
569 845
       }
570 846
     },
847
+    "node_modules/diff": {
848
+      "version": "4.0.2",
849
+      "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
850
+      "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
851
+      "dev": true,
852
+      "license": "BSD-3-Clause",
853
+      "engines": {
854
+        "node": ">=0.3.1"
855
+      }
856
+    },
571 857
     "node_modules/dotenv": {
572 858
       "version": "16.5.0",
573 859
       "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.5.0.tgz",
@@ -1112,6 +1398,12 @@
1112 1398
         "node": ">= 14"
1113 1399
       }
1114 1400
     },
1401
+    "node_modules/http-status-codes": {
1402
+      "version": "2.3.0",
1403
+      "resolved": "https://registry.npmjs.org/http-status-codes/-/http-status-codes-2.3.0.tgz",
1404
+      "integrity": "sha512-RJ8XvFvpPM/Dmc5SV+dC4y5PCeOhT3x1Hq0NU3rjGeg5a/CqlhZ7uudknPwZFz4aeAXDcbAyaeP7GAo9lvngtA==",
1405
+      "license": "MIT"
1406
+    },
1115 1407
     "node_modules/https-proxy-agent": {
1116 1408
       "version": "7.0.6",
1117 1409
       "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
@@ -1343,6 +1635,13 @@
1343 1635
         "node": ">=12"
1344 1636
       }
1345 1637
     },
1638
+    "node_modules/make-error": {
1639
+      "version": "1.3.6",
1640
+      "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
1641
+      "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
1642
+      "dev": true,
1643
+      "license": "ISC"
1644
+    },
1346 1645
     "node_modules/math-intrinsics": {
1347 1646
       "version": "1.1.0",
1348 1647
       "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
@@ -2207,6 +2506,50 @@
2207 2506
         "node": ">=0.6"
2208 2507
       }
2209 2508
     },
2509
+    "node_modules/ts-node": {
2510
+      "version": "10.9.2",
2511
+      "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz",
2512
+      "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==",
2513
+      "dev": true,
2514
+      "license": "MIT",
2515
+      "dependencies": {
2516
+        "@cspotcode/source-map-support": "^0.8.0",
2517
+        "@tsconfig/node10": "^1.0.7",
2518
+        "@tsconfig/node12": "^1.0.7",
2519
+        "@tsconfig/node14": "^1.0.0",
2520
+        "@tsconfig/node16": "^1.0.2",
2521
+        "acorn": "^8.4.1",
2522
+        "acorn-walk": "^8.1.1",
2523
+        "arg": "^4.1.0",
2524
+        "create-require": "^1.1.0",
2525
+        "diff": "^4.0.1",
2526
+        "make-error": "^1.1.1",
2527
+        "v8-compile-cache-lib": "^3.0.1",
2528
+        "yn": "3.1.1"
2529
+      },
2530
+      "bin": {
2531
+        "ts-node": "dist/bin.js",
2532
+        "ts-node-cwd": "dist/bin-cwd.js",
2533
+        "ts-node-esm": "dist/bin-esm.js",
2534
+        "ts-node-script": "dist/bin-script.js",
2535
+        "ts-node-transpile-only": "dist/bin-transpile.js",
2536
+        "ts-script": "dist/bin-script-deprecated.js"
2537
+      },
2538
+      "peerDependencies": {
2539
+        "@swc/core": ">=1.2.50",
2540
+        "@swc/wasm": ">=1.2.50",
2541
+        "@types/node": "*",
2542
+        "typescript": ">=2.7"
2543
+      },
2544
+      "peerDependenciesMeta": {
2545
+        "@swc/core": {
2546
+          "optional": true
2547
+        },
2548
+        "@swc/wasm": {
2549
+          "optional": true
2550
+        }
2551
+      }
2552
+    },
2210 2553
     "node_modules/tslib": {
2211 2554
       "version": "2.8.1",
2212 2555
       "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
@@ -2234,12 +2577,26 @@
2234 2577
       "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==",
2235 2578
       "license": "MIT"
2236 2579
     },
2580
+    "node_modules/typescript": {
2581
+      "version": "5.8.3",
2582
+      "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
2583
+      "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
2584
+      "devOptional": true,
2585
+      "license": "Apache-2.0",
2586
+      "bin": {
2587
+        "tsc": "bin/tsc",
2588
+        "tsserver": "bin/tsserver"
2589
+      },
2590
+      "engines": {
2591
+        "node": ">=14.17"
2592
+      }
2593
+    },
2237 2594
     "node_modules/undici-types": {
2238 2595
       "version": "7.8.0",
2239 2596
       "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz",
2240 2597
       "integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==",
2241
-      "license": "MIT",
2242
-      "optional": true
2598
+      "devOptional": true,
2599
+      "license": "MIT"
2243 2600
     },
2244 2601
     "node_modules/unpipe": {
2245 2602
       "version": "1.0.0",
@@ -2256,6 +2613,13 @@
2256 2613
       "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
2257 2614
       "license": "MIT"
2258 2615
     },
2616
+    "node_modules/v8-compile-cache-lib": {
2617
+      "version": "3.0.1",
2618
+      "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
2619
+      "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==",
2620
+      "dev": true,
2621
+      "license": "MIT"
2622
+    },
2259 2623
     "node_modules/vary": {
2260 2624
       "version": "1.1.2",
2261 2625
       "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
@@ -2290,6 +2654,25 @@
2290 2654
         "buffer-crc32": "~0.2.3",
2291 2655
         "fd-slicer": "~1.1.0"
2292 2656
       }
2657
+    },
2658
+    "node_modules/yn": {
2659
+      "version": "3.1.1",
2660
+      "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",
2661
+      "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",
2662
+      "dev": true,
2663
+      "license": "MIT",
2664
+      "engines": {
2665
+        "node": ">=6"
2666
+      }
2667
+    },
2668
+    "node_modules/zod": {
2669
+      "version": "4.0.5",
2670
+      "resolved": "https://registry.npmjs.org/zod/-/zod-4.0.5.tgz",
2671
+      "integrity": "sha512-/5UuuRPStvHXu7RS+gmvRf4NXrNxpSllGwDnCBcJZtQsKrviYXm54yDGV2KYNLT5kq0lHGcl7lqWJLgSaG+tgA==",
2672
+      "license": "MIT",
2673
+      "funding": {
2674
+        "url": "https://github.com/sponsors/colinhacks"
2675
+      }
2293 2676
     }
2294 2677
   }
2295 2678
 }

+ 20 - 4
package.json

@@ -2,11 +2,15 @@
2 2
   "name": "proyek_radar_farmagitechs",
3 3
   "version": "1.0.0",
4 4
   "main": "index.js",
5
+  "type": "commonjs",
5 6
   "scripts": {
6
-    "test": "echo \"Error: no test specified\" && exit 1"
7
+    "test": "echo \"Error: no test specified\" && exit 1",
8
+    "dev": "ts-node index.ts",
9
+    "build": "tsc",
10
+    "start": "node dist/index.js"
7 11
   },
8 12
   "prisma": {
9
-    "seed": "node prisma/seeders/DatabaseSeeder.js"
13
+    "seed": "ts-node prisma/seeders/DatabaseSeeder.ts"
10 14
   },
11 15
   "keywords": [],
12 16
   "author": "",
@@ -17,6 +21,7 @@
17 21
     "@prisma/client": "^6.10.1",
18 22
     "axios": "^1.10.0",
19 23
     "bcrypt": "^6.0.0",
24
+    "body-parser": "^2.2.0",
20 25
     "cors": "^2.8.5",
21 26
     "date-fns": "^4.1.0",
22 27
     "date-fns-tz": "^3.2.0",
@@ -24,14 +29,25 @@
24 29
     "dayjs-plugin-utc": "^0.1.2",
25 30
     "dotenv": "^16.5.0",
26 31
     "express": "^5.1.0",
32
+    "http-status-codes": "^2.3.0",
27 33
     "jsonwebtoken": "^9.0.2",
28 34
     "keycloak-connect": "^26.1.1",
29 35
     "multer": "^2.0.1",
30 36
     "node-cron": "^4.2.1",
31 37
     "pg": "^8.16.2",
32
-    "qs": "^6.14.0"
38
+    "qs": "^6.14.0",
39
+    "zod": "^4.0.5"
33 40
   },
34 41
   "devDependencies": {
35
-    "prisma": "^6.10.1"
42
+    "@types/bcrypt": "^5.0.2",
43
+    "@types/cors": "^2.8.19",
44
+    "@types/express": "^5.0.3",
45
+    "@types/jsonwebtoken": "^9.0.10",
46
+    "@types/keycloak-connect": "^4.5.4",
47
+    "@types/multer": "^2.0.0",
48
+    "@types/node": "^24.0.14",
49
+    "prisma": "^6.10.1",
50
+    "ts-node": "^10.9.2",
51
+    "typescript": "^5.8.3"
36 52
   }
37 53
 }

+ 0 - 98
prisma/seeders/DatabaseSeeder.js

@@ -1,98 +0,0 @@
1
-const prisma = require('../../src/prisma/PrismaClient.js');
2
-
3
-const { seedProvinces } = require('./ProvinceSeeder');
4
-const { seedAcehCities } = require('./city/AcehCitySeeder');
5
-const { seedBaliCities } = require('./city/BaliCitySeeder');
6
-const { seedBantenCities } = require('./city/BantenCitySeeder');
7
-const { seedBengkuluCities } = require('./city/BengkuluCitySeeder');
8
-const { seedDIYogyakartaCities } = require('./city/DIYogyakartaCitySeeder');
9
-const { seedDKIJakartaCities } = require('./city/DKIJakartaCitySeeder');
10
-const { seedGorontaloCities } = require('./city/GorontaloCitySeeder');
11
-const { seedJambiCities } = require('./city/JambiCitySeeder');
12
-const { seedJawaBaratCities } = require('./city/JawaBaratCitySeeder');
13
-const { seedJawaTengahCities } = require('./city/JawaTengahCitySeeder');
14
-const { seedJawaTimurCities } = require('./city/JawaTimurCitySeeder');
15
-const { seedKalimantanBaratCities } = require('./city/KalimantanBaratCitySeeder');
16
-const { seedKalimantanSelatanCities } = require('./city/KalimantanSelatanCitySeeder');
17
-const { seedKalimantanTengahCities } = require('./city/KalimantanTengahCitySeeder');
18
-const { seedKalimantanTimurCities } = require('./city/KalimantanTimurCitySeeder');
19
-const { seedKalimantanUtaraCities } = require('./city/KalimantanUtaraCitySeeder');
20
-const { seedKepulauanBangkaBelitungCities } = require('./city/KepulauanBangkaBelitungCitySeeder');
21
-const { seedKepulauanRiauCities } = require('./city/KepulauanRiauCitySeeder');
22
-const { seedLampungCities } = require('./city/LampungCitySeeder');
23
-const { seedMalukuCities } = require('./city/MalukuCitySeeder');
24
-const { seedMalukuUtaraCities } = require('./city/MalukuUtaraCitySeeder');
25
-const { seedNusaTenggaraBaratCities } = require('./city/NusaTenggaraBaratCitySeeder');
26
-const { seedNusaTenggaraTimurCities } = require('./city/NusaTenggaraTimurCitySeeder');
27
-const { seedPapuaCities } = require('./city/PapuaCitySeeder');
28
-const { seedPapuaBaratCities } = require('./city/PapuaBaratCitySeeder');
29
-const { seedPapuaBaratDayaCities } = require('./city/PapuaBaratDayaCitySeeder');
30
-const { seedPapuaPegununganCities } = require('./city/PapuaPegununganCitySeeder');
31
-const { seedPapuaTengahCities } = require('./city/PapuaTengahCitySeeder');
32
-const { seedRiauCities } = require('./city/RiauCitySeeder');
33
-const { seedSulawesiBaratCities } = require('./city/SulawesiBaratCitySeeder');
34
-const { seedSulawesiSelatanCities } = require('./city/SulawesiSelatanCitySeeder');
35
-const { seedSulawesiTengahCities } = require('./city/SulawesiTengahCitySeeder');
36
-const { seedSulawesiTenggaraCities } = require('./city/SulawesiTenggaraCitySeeder');
37
-const { seedSulawesiUtaraCities } = require('./city/SulawesiUtaraCitySeeder');
38
-const { seedSumateraBaratCities } = require('./city/SumateraBaratCitySeeder');
39
-const { seedSumateraSelatanCities } = require('./city/SumateraSelatanCitySeeder');
40
-const { seedSumateraUtaraCities } = require('./city/SumateraUtaraCitySeeder');
41
-const { seedUsers } = require('./UserSeeder.js');
42
-const { seedVendors } = require('./VendorSeeder.js');
43
-const seedUserAreas = require('./UserAreaSeeder.js');
44
-const { seedHospitals } = require('./HospitalSeeder.js');
45
-
46
-async function main() {
47
-    await seedProvinces();
48
-    await seedAcehCities();
49
-    await seedBaliCities();
50
-    await seedBantenCities();
51
-    await seedBengkuluCities();
52
-    await seedDIYogyakartaCities();
53
-    await seedDKIJakartaCities();
54
-    await seedGorontaloCities();
55
-    await seedJambiCities();
56
-    await seedJawaBaratCities();
57
-    await seedJawaTengahCities();
58
-    await seedJawaTimurCities();
59
-    await seedKalimantanBaratCities();
60
-    await seedKalimantanSelatanCities();
61
-    await seedKalimantanTengahCities();
62
-    await seedKalimantanTimurCities();
63
-    await seedKalimantanUtaraCities();
64
-    await seedKepulauanBangkaBelitungCities();
65
-    await seedKepulauanRiauCities();
66
-    await seedLampungCities();
67
-    await seedMalukuCities();
68
-    await seedMalukuUtaraCities();
69
-    await seedNusaTenggaraBaratCities();
70
-    await seedNusaTenggaraTimurCities();
71
-    await seedPapuaCities();
72
-    await seedPapuaBaratCities();
73
-    await seedPapuaBaratDayaCities();
74
-    await seedPapuaPegununganCities();
75
-    await seedPapuaTengahCities();
76
-    await seedRiauCities();
77
-    await seedSulawesiBaratCities();
78
-    await seedSulawesiSelatanCities();
79
-    await seedSulawesiTengahCities();
80
-    await seedSulawesiTenggaraCities();
81
-    await seedSulawesiUtaraCities();
82
-    await seedSumateraBaratCities();
83
-    await seedSumateraSelatanCities();
84
-    await seedSumateraUtaraCities();
85
-    await seedUsers();
86
-    await seedVendors();
87
-    await seedUserAreas();
88
-    await seedHospitals();
89
-    await seedVendors();
90
-}
91
-
92
-main().then(() => {
93
-    console.log('✅ Seeding completed');
94
-    return prisma.$disconnect();
95
-}).catch((e) => {
96
-    console.error('❌ Seeding error:', e);
97
-    return prisma.$disconnect().then(() => process.exit(1));
98
-});

+ 101 - 0
prisma/seeders/DatabaseSeeder.ts

@@ -0,0 +1,101 @@
1
+import prisma from '../../src/prisma/PrismaClient';
2
+import { seedProvinces } from './ProvinceSeeder';
3
+import { seedAcehCities } from './city/AcehCitySeeder';
4
+import { seedBaliCities } from './city/BaliCitySeeder';
5
+import { seedBantenCities } from './city/BantenCitySeeder';
6
+import { seedBengkuluCities } from './city/BengkuluCitySeeder';
7
+import { seedDIYogyakartaCities } from './city/DIYogyakartaCitySeeder';
8
+import { seedDKIJakartaCities } from './city/DKIJakartaCitySeeder';
9
+import { seedGorontaloCities } from './city/GorontaloCitySeeder';
10
+import { seedJambiCities } from './city/JambiCitySeeder';
11
+import { seedJawaBaratCities } from './city/JawaBaratCitySeeder';
12
+import { seedJawaTengahCities } from './city/JawaTengahCitySeeder';
13
+import { seedJawaTimurCities } from './city/JawaTimurCitySeeder';
14
+import { seedKalimantanBaratCities } from './city/KalimantanBaratCitySeeder';
15
+import { seedKalimantanSelatanCities } from './city/KalimantanSelatanCitySeeder';
16
+import { seedKalimantanTengahCities } from './city/KalimantanTengahCitySeeder';
17
+import { seedKalimantanTimurCities } from './city/KalimantanTimurCitySeeder';
18
+import { seedKalimantanUtaraCities } from './city/KalimantanUtaraCitySeeder';
19
+import { seedKepulauanBangkaBelitungCities } from './city/KepulauanBangkaBelitungCitySeeder';
20
+import { seedKepulauanRiauCities } from './city/KepulauanRiauCitySeeder';
21
+import { seedLampungCities } from './city/LampungCitySeeder';
22
+import { seedMalukuCities } from './city/MalukuCitySeeder';
23
+import { seedMalukuUtaraCities } from './city/MalukuUtaraCitySeeder';
24
+import { seedNusaTenggaraBaratCities } from './city/NusaTenggaraBaratCitySeeder';
25
+import { seedNusaTenggaraTimurCities } from './city/NusaTenggaraTimurCitySeeder';
26
+import { seedPapuaCities } from './city/PapuaCitySeeder';
27
+import { seedPapuaBaratCities } from './city/PapuaBaratCitySeeder';
28
+import { seedPapuaBaratDayaCities } from './city/PapuaBaratDayaCitySeeder';
29
+import { seedPapuaPegununganCities } from './city/PapuaPegununganCitySeeder';
30
+import { seedPapuaTengahCities } from './city/PapuaTengahCitySeeder';
31
+import { seedRiauCities } from './city/RiauCitySeeder';
32
+import { seedSulawesiBaratCities } from './city/SulawesiBaratCitySeeder';
33
+import { seedSulawesiSelatanCities } from './city/SulawesiSelatanCitySeeder';
34
+import { seedSulawesiTengahCities } from './city/SulawesiTengahCitySeeder';
35
+import { seedSulawesiTenggaraCities } from './city/SulawesiTenggaraCitySeeder';
36
+import { seedSulawesiUtaraCities } from './city/SulawesiUtaraCitySeeder';
37
+import { seedSumateraBaratCities } from './city/SumateraBaratCitySeeder';
38
+import { seedSumateraSelatanCities } from './city/SumateraSelatanCitySeeder';
39
+import { seedSumateraUtaraCities } from './city/SumateraUtaraCitySeeder';
40
+import { seedPapuaSelatanCities } from './city/PapuaSelatanCitySeeder';
41
+import { seedUsers } from './UserSeeder';
42
+import { seedVendors } from './VendorSeeder';
43
+import { seedUserAreas } from './UserAreaSeeder';
44
+import { seedHospitals } from './HospitalSeeder';
45
+
46
+async function main(): Promise<void> {
47
+    await seedProvinces();
48
+    await seedAcehCities();
49
+    await seedBaliCities();
50
+    await seedBantenCities();
51
+    await seedBengkuluCities();
52
+    await seedDIYogyakartaCities();
53
+    await seedDKIJakartaCities();
54
+    await seedGorontaloCities();
55
+    await seedJambiCities();
56
+    await seedJawaBaratCities();
57
+    await seedJawaTengahCities();
58
+    await seedJawaTimurCities();
59
+    await seedKalimantanBaratCities();
60
+    await seedKalimantanSelatanCities();
61
+    await seedKalimantanTengahCities();
62
+    await seedKalimantanTimurCities();
63
+    await seedKalimantanUtaraCities();
64
+    await seedKepulauanBangkaBelitungCities();
65
+    await seedKepulauanRiauCities();
66
+    await seedLampungCities();
67
+    await seedMalukuCities();
68
+    await seedMalukuUtaraCities();
69
+    await seedNusaTenggaraBaratCities();
70
+    await seedNusaTenggaraTimurCities();
71
+    await seedPapuaCities();
72
+    await seedPapuaBaratCities();
73
+    await seedPapuaBaratDayaCities();
74
+    await seedPapuaPegununganCities();
75
+    await seedPapuaTengahCities();
76
+    await seedRiauCities();
77
+    await seedSulawesiBaratCities();
78
+    await seedSulawesiSelatanCities();
79
+    await seedSulawesiTengahCities();
80
+    await seedSulawesiTenggaraCities();
81
+    await seedSulawesiUtaraCities();
82
+    await seedSumateraBaratCities();
83
+    await seedSumateraSelatanCities();
84
+    await seedSumateraUtaraCities();
85
+    await seedPapuaSelatanCities();
86
+    await seedUsers();
87
+    await seedVendors();
88
+    await seedUserAreas();
89
+    await seedHospitals();
90
+}
91
+
92
+main()
93
+    .then(async () => {
94
+        console.log('✅ Seeding completed');
95
+        await prisma.$disconnect();
96
+    })
97
+    .catch(async (e: unknown) => {
98
+        console.error('❌ Seeding error:', e);
99
+        await prisma.$disconnect();
100
+        process.exit(1);
101
+    });

+ 0 - 134
prisma/seeders/HospitalSeeder.js

@@ -1,134 +0,0 @@
1
-const { PrismaClient } = require('@prisma/client');
2
-const prisma = new PrismaClient();
3
-
4
-async function seedHospitals() {
5
-    try {
6
-        const sales1 = await prisma.user.findFirst({ where: { username: 'sales1' } });
7
-        const sales2 = await prisma.user.findFirst({ where: { username: 'sales2' } });
8
-
9
-        if (!sales1 || !sales2) {
10
-            throw new Error('User sales1 or sales2 not found');
11
-        }
12
-
13
-        // Ambil province_id dari user_areas
14
-        const sales1Area = await prisma.userArea.findFirst({ where: { user_id: sales1.id } });
15
-        const sales2Area = await prisma.userArea.findFirst({ where: { user_id: sales2.id } });
16
-
17
-        if (!sales1Area || !sales2Area) {
18
-            throw new Error('UserArea for sales1 or sales2 not found');
19
-        }
20
-
21
-        // Ambil city yang berada di province_id tersebut
22
-        const city1 = await prisma.city.findFirst({ where: { province_id: sales1Area.province_id } });
23
-        const city2 = await prisma.city.findFirst({ where: { province_id: sales2Area.province_id } });
24
-
25
-        if (!city1 || !city2) {
26
-            throw new Error('City not found for one of province id');
27
-        }
28
-
29
-        // Data rumah sakit
30
-        const hospitals = [
31
-            {
32
-                name: 'RS Sehat Selalu',
33
-                hospital_code: 'RSS001',
34
-                type: 'Tipe B',
35
-                ownership: 'Swasta',
36
-                address: 'Jl. Kesehatan No. 1',
37
-                // simrs_type: 'MediSoft',
38
-                contact: '021-123456',
39
-                image: null,
40
-                progress_status: 'cari_data',
41
-                note: 'Calon potensial',
42
-                province_id: sales1Area.province_id,
43
-                city_id: city1.id,
44
-                created_by: sales1.id,
45
-            },
46
-            {
47
-                name: 'RS Harapan Bangsa',
48
-                hospital_code: 'RSB002',
49
-                type: 'Tipe C',
50
-                ownership: 'Pemerintah',
51
-                address: 'Jl. Harapan No. 2',
52
-                // simrs_type: 'Hospicare',
53
-                contact: '021-654321',
54
-                image: null,
55
-                progress_status: 'cari_data',
56
-                note: null,
57
-                province_id: sales1Area.province_id,
58
-                city_id: city1.id,
59
-                created_by: sales1.id,
60
-            },
61
-            {
62
-                name: 'RS Mitra Medika',
63
-                hospital_code: 'RSM003',
64
-                type: 'Tipe D',
65
-                ownership: 'Swasta',
66
-                address: 'Jl. Mitra No. 3',
67
-                // simrs_type: 'SimRS Platinum',
68
-                contact: '021-999999',
69
-                image: null,
70
-                progress_status: 'cari_data',
71
-                note: 'Baru dihubungi',
72
-                province_id: sales1Area.province_id,
73
-                city_id: city1.id,
74
-                created_by: sales1.id,
75
-            },
76
-            {
77
-                name: 'RS Sembuh Bersama',
78
-                hospital_code: 'RSB004',
79
-                type: 'Tipe B',
80
-                ownership: 'Swasta',
81
-                address: 'Jl. Bersama No. 4',
82
-                // simrs_type: 'MediSoft',
83
-                contact: '0274-111111',
84
-                image: null,
85
-                progress_status: 'cari_data',
86
-                note: null,
87
-                province_id: sales2Area.province_id,
88
-                city_id: city2.id,
89
-                created_by: sales2.id,
90
-            },
91
-            {
92
-                name: 'RS Kasih Ibu',
93
-                hospital_code: 'RSK005',
94
-                type: 'Tipe C',
95
-                ownership: 'Yayasan',
96
-                address: 'Jl. Kasih No. 5',
97
-                // simrs_type: 'Hospicare',
98
-                contact: '0274-222222',
99
-                image: null,
100
-                progress_status: 'cari_data',
101
-                note: 'Perlu follow up',
102
-                province_id: sales2Area.province_id,
103
-                city_id: city2.id,
104
-                created_by: sales2.id,
105
-            },
106
-            {
107
-                name: 'RS Bhakti Sehat',
108
-                hospital_code: 'RSB006',
109
-                type: 'Tipe D',
110
-                ownership: 'Swasta',
111
-                address: 'Jl. Bhakti No. 6',
112
-                // simrs_type: 'SimRS Platinum',
113
-                contact: '0274-333333',
114
-                image: null,
115
-                progress_status: 'cari_data',
116
-                note: null,
117
-                province_id: sales2Area.province_id,
118
-                city_id: city2.id,
119
-                created_by: sales2.id,
120
-            },
121
-        ];
122
-
123
-        // Masukkan ke DB
124
-        for (const hospital of hospitals) {
125
-            await prisma.hospital.create({ data: hospital });
126
-        }
127
-
128
-        console.log('✅ Hospital seeded!');
129
-    } catch (err) {
130
-        console.error('❌ Error seeding hospital:', err.message);
131
-    }
132
-}
133
-
134
-module.exports = { seedHospitals };

+ 260 - 0
prisma/seeders/HospitalSeeder.ts

@@ -0,0 +1,260 @@
1
+import { PrismaClient } from '@prisma/client';
2
+import { ProgressStatus } from '@prisma/client';
3
+
4
+const prisma = new PrismaClient();
5
+
6
+export async function seedHospitals(): Promise<void> {
7
+    try {
8
+        const sales1 = await prisma.user.findFirst({ where: { username: 'sales1' } });
9
+        const sales2 = await prisma.user.findFirst({ where: { username: 'sales2' } });
10
+
11
+        if (!sales1 || !sales2) {
12
+            throw new Error('User sales1 or sales2 not found');
13
+        }
14
+
15
+        const sales1Area = await prisma.userArea.findFirst({ where: { user_id: sales1.id } });
16
+        const sales2Area = await prisma.userArea.findFirst({ where: { user_id: sales2.id } });
17
+
18
+        if (!sales1Area || !sales2Area) {
19
+            throw new Error('UserArea for sales1 or sales2 not found');
20
+        }
21
+
22
+        const city1 = await prisma.city.findFirst({ where: { province_id: sales1Area.province_id } });
23
+        const city2 = await prisma.city.findFirst({ where: { province_id: sales2Area.province_id } });
24
+
25
+        if (!city1 || !city2) {
26
+            throw new Error('City not found for one of province id');
27
+        }
28
+
29
+        const hospitals = [
30
+            {
31
+                name: 'RS Sehat Selalu',
32
+                hospital_code: 'RSS001',
33
+                type: 'Tipe B',
34
+                ownership: 'Swasta',
35
+                address: 'Jl. Kesehatan No. 1',
36
+                contact: '021-123456',
37
+                image: null,
38
+                progress_status: ProgressStatus.cari_data,
39
+                note: 'Calon potensial',
40
+                province_id: sales1Area.province_id,
41
+                city_id: city1.id,
42
+                created_by: sales1.id,
43
+            },
44
+            {
45
+                name: 'RS Harapan Bangsa',
46
+                hospital_code: 'RSB002',
47
+                type: 'Tipe C',
48
+                ownership: 'Pemerintah',
49
+                address: 'Jl. Harapan No. 2',
50
+                contact: '021-654321',
51
+                image: null,
52
+                progress_status: ProgressStatus.cari_data,
53
+                note: null,
54
+                province_id: sales1Area.province_id,
55
+                city_id: city1.id,
56
+                created_by: sales1.id,
57
+            },
58
+            {
59
+                name: 'RS Mitra Medika',
60
+                hospital_code: 'RSM003',
61
+                type: 'Tipe D',
62
+                ownership: 'Swasta',
63
+                address: 'Jl. Mitra No. 3',
64
+                contact: '021-999999',
65
+                image: null,
66
+                progress_status: ProgressStatus.cari_data,
67
+                note: 'Baru dihubungi',
68
+                province_id: sales1Area.province_id,
69
+                city_id: city1.id,
70
+                created_by: sales1.id,
71
+            },
72
+            {
73
+                name: 'RS Sembuh Bersama',
74
+                hospital_code: 'RSB004',
75
+                type: 'Tipe B',
76
+                ownership: 'Swasta',
77
+                address: 'Jl. Bersama No. 4',
78
+                contact: '0274-111111',
79
+                image: null,
80
+                progress_status: ProgressStatus.cari_data,
81
+                note: null,
82
+                province_id: sales2Area.province_id,
83
+                city_id: city2.id,
84
+                created_by: sales2.id,
85
+            },
86
+            {
87
+                name: 'RS Kasih Ibu',
88
+                hospital_code: 'RSK005',
89
+                type: 'Tipe C',
90
+                ownership: 'Yayasan',
91
+                address: 'Jl. Kasih No. 5',
92
+                contact: '0274-222222',
93
+                image: null,
94
+                progress_status: ProgressStatus.cari_data,
95
+                note: 'Perlu follow up',
96
+                province_id: sales2Area.province_id,
97
+                city_id: city2.id,
98
+                created_by: sales2.id,
99
+            },
100
+            {
101
+                name: 'RS Bhakti Sehat',
102
+                hospital_code: 'RSB006',
103
+                type: 'Tipe D',
104
+                ownership: 'Swasta',
105
+                address: 'Jl. Bhakti No. 6',
106
+                contact: '0274-333333',
107
+                image: null,
108
+                progress_status: ProgressStatus.cari_data,
109
+                note: null,
110
+                province_id: sales2Area.province_id,
111
+                city_id: city2.id,
112
+                created_by: sales2.id,
113
+            },
114
+        ];
115
+
116
+        for (const hospital of hospitals) {
117
+            await prisma.hospital.create({ data: hospital });
118
+        }
119
+
120
+        console.log('✅ Hospital seeded!');
121
+    } catch (err: any) {
122
+        console.error('❌ Error seeding hospital:', err.message);
123
+    }
124
+}
125
+
126
+
127
+// const { PrismaClient } = require('@prisma/client');
128
+// const prisma = new PrismaClient();
129
+
130
+// async function seedHospitals() {
131
+//     try {
132
+//         const sales1 = await prisma.user.findFirst({ where: { username: 'sales1' } });
133
+//         const sales2 = await prisma.user.findFirst({ where: { username: 'sales2' } });
134
+
135
+//         if (!sales1 || !sales2) {
136
+//             throw new Error('User sales1 or sales2 not found');
137
+//         }
138
+
139
+//         // Ambil province_id dari user_areas
140
+//         const sales1Area = await prisma.userArea.findFirst({ where: { user_id: sales1.id } });
141
+//         const sales2Area = await prisma.userArea.findFirst({ where: { user_id: sales2.id } });
142
+
143
+//         if (!sales1Area || !sales2Area) {
144
+//             throw new Error('UserArea for sales1 or sales2 not found');
145
+//         }
146
+
147
+//         // Ambil city yang berada di province_id tersebut
148
+//         const city1 = await prisma.city.findFirst({ where: { province_id: sales1Area.province_id } });
149
+//         const city2 = await prisma.city.findFirst({ where: { province_id: sales2Area.province_id } });
150
+
151
+//         if (!city1 || !city2) {
152
+//             throw new Error('City not found for one of province id');
153
+//         }
154
+
155
+//         // Data rumah sakit
156
+//         const hospitals = [
157
+//             {
158
+//                 name: 'RS Sehat Selalu',
159
+//                 hospital_code: 'RSS001',
160
+//                 type: 'Tipe B',
161
+//                 ownership: 'Swasta',
162
+//                 address: 'Jl. Kesehatan No. 1',
163
+//                 // simrs_type: 'MediSoft',
164
+//                 contact: '021-123456',
165
+//                 image: null,
166
+//                 progress_status: 'cari_data',
167
+//                 note: 'Calon potensial',
168
+//                 province_id: sales1Area.province_id,
169
+//                 city_id: city1.id,
170
+//                 created_by: sales1.id,
171
+//             },
172
+//             {
173
+//                 name: 'RS Harapan Bangsa',
174
+//                 hospital_code: 'RSB002',
175
+//                 type: 'Tipe C',
176
+//                 ownership: 'Pemerintah',
177
+//                 address: 'Jl. Harapan No. 2',
178
+//                 // simrs_type: 'Hospicare',
179
+//                 contact: '021-654321',
180
+//                 image: null,
181
+//                 progress_status: 'cari_data',
182
+//                 note: null,
183
+//                 province_id: sales1Area.province_id,
184
+//                 city_id: city1.id,
185
+//                 created_by: sales1.id,
186
+//             },
187
+//             {
188
+//                 name: 'RS Mitra Medika',
189
+//                 hospital_code: 'RSM003',
190
+//                 type: 'Tipe D',
191
+//                 ownership: 'Swasta',
192
+//                 address: 'Jl. Mitra No. 3',
193
+//                 // simrs_type: 'SimRS Platinum',
194
+//                 contact: '021-999999',
195
+//                 image: null,
196
+//                 progress_status: 'cari_data',
197
+//                 note: 'Baru dihubungi',
198
+//                 province_id: sales1Area.province_id,
199
+//                 city_id: city1.id,
200
+//                 created_by: sales1.id,
201
+//             },
202
+//             {
203
+//                 name: 'RS Sembuh Bersama',
204
+//                 hospital_code: 'RSB004',
205
+//                 type: 'Tipe B',
206
+//                 ownership: 'Swasta',
207
+//                 address: 'Jl. Bersama No. 4',
208
+//                 // simrs_type: 'MediSoft',
209
+//                 contact: '0274-111111',
210
+//                 image: null,
211
+//                 progress_status: 'cari_data',
212
+//                 note: null,
213
+//                 province_id: sales2Area.province_id,
214
+//                 city_id: city2.id,
215
+//                 created_by: sales2.id,
216
+//             },
217
+//             {
218
+//                 name: 'RS Kasih Ibu',
219
+//                 hospital_code: 'RSK005',
220
+//                 type: 'Tipe C',
221
+//                 ownership: 'Yayasan',
222
+//                 address: 'Jl. Kasih No. 5',
223
+//                 // simrs_type: 'Hospicare',
224
+//                 contact: '0274-222222',
225
+//                 image: null,
226
+//                 progress_status: 'cari_data',
227
+//                 note: 'Perlu follow up',
228
+//                 province_id: sales2Area.province_id,
229
+//                 city_id: city2.id,
230
+//                 created_by: sales2.id,
231
+//             },
232
+//             {
233
+//                 name: 'RS Bhakti Sehat',
234
+//                 hospital_code: 'RSB006',
235
+//                 type: 'Tipe D',
236
+//                 ownership: 'Swasta',
237
+//                 address: 'Jl. Bhakti No. 6',
238
+//                 // simrs_type: 'SimRS Platinum',
239
+//                 contact: '0274-333333',
240
+//                 image: null,
241
+//                 progress_status: 'cari_data',
242
+//                 note: null,
243
+//                 province_id: sales2Area.province_id,
244
+//                 city_id: city2.id,
245
+//                 created_by: sales2.id,
246
+//             },
247
+//         ];
248
+
249
+//         // Masukkan ke DB
250
+//         for (const hospital of hospitals) {
251
+//             await prisma.hospital.create({ data: hospital });
252
+//         }
253
+
254
+//         console.log('✅ Hospital seeded!');
255
+//     } catch (err) {
256
+//         console.error('❌ Error seeding hospital:', err.message);
257
+//     }
258
+// }
259
+
260
+// module.exports = { seedHospitals };

+ 8 - 8
prisma/seeders/ProvinceSeeder.js

@@ -1,7 +1,7 @@
1
-const prisma = require('../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../src/utils/TimeLocal.js')
1
+import prisma from '../../src/prisma/PrismaClient';
2
+import { now } from '../../src/utils/TimeLocal';
3 3
 
4
-const provinces = [
4
+const provinces: string[] = [
5 5
     "Aceh", "Bali", "Banten", "Bengkulu", "DI Yogyakarta", "DKI Jakarta", "Gorontalo",
6 6
     "Jambi", "Jawa Barat", "Jawa Tengah", "Jawa Timur", "Kalimantan Barat",
7 7
     "Kalimantan Selatan", "Kalimantan Tengah", "Kalimantan Timur", "Kalimantan Utara",
@@ -12,19 +12,19 @@ const provinces = [
12 12
     "Sulawesi Tenggara", "Sulawesi Utara", "Sumatera Barat", "Sumatera Selatan", "Sumatera Utara"
13 13
 ];
14 14
 
15
-exports.seedProvinces = async () => {
15
+export async function seedProvinces(): Promise<void> {
16 16
     for (const name of provinces.sort()) {
17 17
         await prisma.province.upsert({
18
-            where: { name },
18
+            where: { name }, // 'name' harus @unique di schema.prisma
19 19
             create: {
20 20
                 name,
21
-                createdAt: timeLocal.now().toDate(),
21
+                createdAt: now().toDate(),
22 22
             },
23 23
             update: {
24
-                updatedAt: timeLocal.now().toDate()
24
+                updatedAt: now().toDate()
25 25
             }
26 26
         });
27 27
     }
28 28
 
29 29
     console.log('✅ Provinces seeded!');
30
-};
30
+}

+ 0 - 41
prisma/seeders/UserAreaSeeder.js

@@ -1,41 +0,0 @@
1
-const prisma = require('../../src/prisma/PrismaClient.js');
2
-
3
-async function seedUserAreas() {
4
-    try {
5
-        // Ambil user dengan role 'sales1' dan 'sales2'
6
-        const sales1 = await prisma.user.findFirst({ where: { username: 'sales1' } });
7
-        const sales2 = await prisma.user.findFirst({ where: { username: 'sales2' } });
8
-
9
-        if (!sales1 || !sales2) {
10
-            throw new Error('User sales1 or sales2 not found');
11
-        }
12
-
13
-        // Ambil provinsi
14
-        const jawaTengah = await prisma.province.findFirst({ where: { name: 'Jawa Tengah' } });
15
-        const diy = await prisma.province.findFirst({ where: { name: 'DI Yogyakarta' } });
16
-
17
-        if (!jawaTengah || !diy) {
18
-            throw new Error('Province Jawa Tengah or DI Yogyakarta not found');
19
-        }
20
-
21
-        // Buat user_areas
22
-        await prisma.userArea.createMany({
23
-            data: [
24
-                {
25
-                    user_id: sales1.id,
26
-                    province_id: jawaTengah.id,
27
-                },
28
-                {
29
-                    user_id: sales2.id,
30
-                    province_id: diy.id,
31
-                },
32
-            ],
33
-        });
34
-
35
-        console.log('✅ User area seeded');
36
-    } catch (error) {
37
-        console.error('❌ Error seeding user area:', error);
38
-    }
39
-}
40
-
41
-module.exports = seedUserAreas;

+ 82 - 0
prisma/seeders/UserAreaSeeder.ts

@@ -0,0 +1,82 @@
1
+import prisma from '../../src/prisma/PrismaClient';
2
+
3
+export async function seedUserAreas(): Promise<void> {
4
+    try {
5
+        // Ambil user dengan username 'sales1' dan 'sales2'
6
+        const sales1 = await prisma.user.findFirst({ where: { username: 'sales1' } });
7
+        const sales2 = await prisma.user.findFirst({ where: { username: 'sales2' } });
8
+
9
+        if (!sales1 || !sales2) {
10
+            throw new Error('User sales1 or sales2 not found');
11
+        }
12
+
13
+        // Ambil provinsi
14
+        const jawaTengah = await prisma.province.findFirst({ where: { name: 'Jawa Tengah' } });
15
+        const diy = await prisma.province.findFirst({ where: { name: 'DI Yogyakarta' } });
16
+
17
+        if (!jawaTengah || !diy) {
18
+            throw new Error('Province Jawa Tengah or DI Yogyakarta not found');
19
+        }
20
+
21
+        // Buat data user_area
22
+        await prisma.userArea.createMany({
23
+            data: [
24
+                {
25
+                    user_id: sales1.id,
26
+                    province_id: jawaTengah.id,
27
+                },
28
+                {
29
+                    user_id: sales2.id,
30
+                    province_id: diy.id,
31
+                },
32
+            ],
33
+        });
34
+
35
+        console.log('✅ User area seeded');
36
+    } catch (error: any) {
37
+        console.error('❌ Error seeding user area:', error.message);
38
+    }
39
+}
40
+
41
+
42
+// const prisma = require('../../src/prisma/PrismaClient.js');
43
+
44
+// async function seedUserAreas() {
45
+//     try {
46
+//         // Ambil user dengan role 'sales1' dan 'sales2'
47
+//         const sales1 = await prisma.user.findFirst({ where: { username: 'sales1' } });
48
+//         const sales2 = await prisma.user.findFirst({ where: { username: 'sales2' } });
49
+
50
+//         if (!sales1 || !sales2) {
51
+//             throw new Error('User sales1 or sales2 not found');
52
+//         }
53
+
54
+//         // Ambil provinsi
55
+//         const jawaTengah = await prisma.province.findFirst({ where: { name: 'Jawa Tengah' } });
56
+//         const diy = await prisma.province.findFirst({ where: { name: 'DI Yogyakarta' } });
57
+
58
+//         if (!jawaTengah || !diy) {
59
+//             throw new Error('Province Jawa Tengah or DI Yogyakarta not found');
60
+//         }
61
+
62
+//         // Buat user_areas
63
+//         await prisma.userArea.createMany({
64
+//             data: [
65
+//                 {
66
+//                     user_id: sales1.id,
67
+//                     province_id: jawaTengah.id,
68
+//                 },
69
+//                 {
70
+//                     user_id: sales2.id,
71
+//                     province_id: diy.id,
72
+//                 },
73
+//             ],
74
+//         });
75
+
76
+//         console.log('✅ User area seeded');
77
+//     } catch (error) {
78
+//         console.error('❌ Error seeding user area:', error);
79
+//     }
80
+// }
81
+
82
+// module.exports = seedUserAreas;

+ 0 - 148
prisma/seeders/UserSeeder.js

@@ -1,148 +0,0 @@
1
-const axios = require('axios');
2
-const qs = require('qs');
3
-const bcrypt = require('bcrypt');
4
-const prisma = require('../../src/prisma/PrismaClient.js');
5
-const {
6
-    KEYCLOAK_TOKEN_URL,
7
-    KEYCLOAK_ADMIN_URL,
8
-    KEYCLOAK_REALM,
9
-    CLIENT_ID,
10
-    CLIENT_SECRET,
11
-} = require('../../config/keycloak.js');
12
-
13
-// Ambil token admin Keycloak
14
-const getAdminToken = async () => {
15
-    const tokenParams = qs.stringify({
16
-        grant_type: 'client_credentials',
17
-        client_id: CLIENT_ID,
18
-        client_secret: CLIENT_SECRET,
19
-    });
20
-
21
-    const { data } = await axios.post(KEYCLOAK_TOKEN_URL, tokenParams, {
22
-        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
23
-    });
24
-
25
-    return data.access_token;
26
-};
27
-
28
-// Buat user di Keycloak
29
-const createUserInKeycloak = async (user, token) => {
30
-    const checkUser = await axios.get(
31
-        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users?username=${user.username}`,
32
-        { headers: { Authorization: `Bearer ${token}` } }
33
-    );
34
-
35
-    if (checkUser.data.length > 0) {
36
-        console.log(`⚠️  User ${user.username} found in Keycloak`);
37
-        return checkUser.data[0].id;
38
-    }
39
-
40
-    await axios.post(
41
-        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users`,
42
-        {
43
-            username: user.username,
44
-            email: user.email,
45
-            firstName: user.firstname,
46
-            lastName: user.lastname,
47
-            enabled: true,
48
-            credentials: [
49
-                {
50
-                    type: 'password',
51
-                    value: user.password,
52
-                    temporary: false,
53
-                },
54
-            ],
55
-        },
56
-        {
57
-            headers: { Authorization: `Bearer ${token}` },
58
-        }
59
-    );
60
-
61
-    const { data } = await axios.get(
62
-        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users?username=${user.username}`,
63
-        {
64
-            headers: { Authorization: `Bearer ${token}` },
65
-        }
66
-    );
67
-
68
-    return data[0].id;
69
-};
70
-
71
-// Assign role ke user di Keycloak
72
-const assignRole = async (userId, roleName, token) => {
73
-    const { data: roles } = await axios.get(
74
-        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/roles`,
75
-        {
76
-            headers: { Authorization: `Bearer ${token}` },
77
-        }
78
-    );
79
-
80
-    const role = roles.find((r) => r.name === roleName);
81
-    if (!role) throw new Error(`Role "${roleName}" not found in Keycloak`);
82
-
83
-    await axios.post(
84
-        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users/${userId}/role-mappings/realm`,
85
-        [role],
86
-        {
87
-            headers: { Authorization: `Bearer ${token}` },
88
-        }
89
-    );
90
-};
91
-
92
-// Data user yang ingin dibuat
93
-const users = [
94
-    {
95
-        username: 'admin1',
96
-        email: 'admin1@gmail.com',
97
-        password: 'password123',
98
-        firstname: 'Admin',
99
-        lastname: 'Satu',
100
-        role: 'admin',
101
-    },
102
-    {
103
-        username: 'sales1',
104
-        email: 'sales1@gmail.com',
105
-        password: 'password123',
106
-        firstname: 'Sales',
107
-        lastname: 'Satu',
108
-        role: 'sales',
109
-    },
110
-    {
111
-        username: 'sales2',
112
-        email: 'sales2@gmail.com',
113
-        password: 'password123',
114
-        firstname: 'Sales',
115
-        lastname: 'Dua',
116
-        role: 'sales',
117
-    },
118
-];
119
-
120
-// Fungsi utama yang bisa dipanggil dari seeder utama
121
-const seedUsers = async () => {
122
-    const token = await getAdminToken();
123
-
124
-    for (const user of users) {
125
-        const userId = await createUserInKeycloak(user, token);
126
-        await assignRole(userId, user.role, token);
127
-
128
-        const hashedPassword = await bcrypt.hash(user.password, 10);
129
-
130
-        await prisma.user.upsert({
131
-            where: { id: userId },
132
-            update: {},
133
-            create: {
134
-                id: userId,
135
-                username: user.username,
136
-                email: user.email,
137
-                firstname: user.firstname,
138
-                lastname: user.lastname,
139
-                password: hashedPassword,
140
-                role: user.role,
141
-            },
142
-        });
143
-
144
-        console.log(`✅ Success seed user ${user.role}: ${user.username}`);
145
-    }
146
-};
147
-
148
-module.exports = { seedUsers };

+ 306 - 0
prisma/seeders/UserSeeder.ts

@@ -0,0 +1,306 @@
1
+import axios from 'axios';
2
+import qs from 'qs';
3
+import bcrypt from 'bcrypt';
4
+import prisma from '../../src/prisma/PrismaClient';
5
+import {
6
+    KEYCLOAK_TOKEN_URL,
7
+    KEYCLOAK_ADMIN_URL,
8
+    KEYCLOAK_REALM,
9
+    CLIENT_ID,
10
+    CLIENT_SECRET,
11
+} from '../../config/keycloak';
12
+
13
+// Tipe untuk data user lokal
14
+interface SeedUser {
15
+    username: string;
16
+    email: string;
17
+    password: string;
18
+    firstname: string;
19
+    lastname: string;
20
+    role: string;
21
+}
22
+
23
+// Ambil token admin dari Keycloak
24
+const getAdminToken = async (): Promise<string> => {
25
+    const tokenParams = qs.stringify({
26
+        grant_type: 'client_credentials',
27
+        client_id: CLIENT_ID,
28
+        client_secret: CLIENT_SECRET,
29
+    });
30
+
31
+    const { data } = await axios.post(KEYCLOAK_TOKEN_URL, tokenParams, {
32
+        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
33
+    });
34
+
35
+    return data.access_token;
36
+};
37
+
38
+// Membuat user di Keycloak
39
+const createUserInKeycloak = async (user: SeedUser, token: string): Promise<string> => {
40
+    const checkUser = await axios.get(
41
+        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users?username=${user.username}`,
42
+        { headers: { Authorization: `Bearer ${token}` } }
43
+    );
44
+
45
+    if (checkUser.data.length > 0) {
46
+        console.log(`⚠️  User ${user.username} already exists in Keycloak`);
47
+        return checkUser.data[0].id;
48
+    }
49
+
50
+    await axios.post(
51
+        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users`,
52
+        {
53
+            username: user.username,
54
+            email: user.email,
55
+            firstName: user.firstname,
56
+            lastName: user.lastname,
57
+            enabled: true,
58
+            credentials: [
59
+                {
60
+                    type: 'password',
61
+                    value: user.password,
62
+                    temporary: false,
63
+                },
64
+            ],
65
+        },
66
+        {
67
+            headers: { Authorization: `Bearer ${token}` },
68
+        }
69
+    );
70
+
71
+    const { data } = await axios.get(
72
+        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users?username=${user.username}`,
73
+        {
74
+            headers: { Authorization: `Bearer ${token}` },
75
+        }
76
+    );
77
+
78
+    return data[0].id;
79
+};
80
+
81
+// Assign role ke user
82
+const assignRole = async (userId: string, roleName: string, token: string): Promise<void> => {
83
+    const { data: roles } = await axios.get(
84
+        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/roles`,
85
+        {
86
+            headers: { Authorization: `Bearer ${token}` },
87
+        }
88
+    );
89
+
90
+    const role = roles.find((r: any) => r.name === roleName);
91
+    if (!role) throw new Error(`Role "${roleName}" not found in Keycloak`);
92
+
93
+    await axios.post(
94
+        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users/${userId}/role-mappings/realm`,
95
+        [role],
96
+        {
97
+            headers: { Authorization: `Bearer ${token}` },
98
+        }
99
+    );
100
+};
101
+
102
+// Data user yang ingin di-seed
103
+const users: SeedUser[] = [
104
+    {
105
+        username: 'admin1',
106
+        email: 'admin1@gmail.com',
107
+        password: 'password123',
108
+        firstname: 'Admin',
109
+        lastname: 'Satu',
110
+        role: 'admin',
111
+    },
112
+    {
113
+        username: 'sales1',
114
+        email: 'sales1@gmail.com',
115
+        password: 'password123',
116
+        firstname: 'Sales',
117
+        lastname: 'Satu',
118
+        role: 'sales',
119
+    },
120
+    {
121
+        username: 'sales2',
122
+        email: 'sales2@gmail.com',
123
+        password: 'password123',
124
+        firstname: 'Sales',
125
+        lastname: 'Dua',
126
+        role: 'sales',
127
+    },
128
+];
129
+
130
+// Fungsi utama untuk seeding user
131
+export const seedUsers = async (): Promise<void> => {
132
+    const token = await getAdminToken();
133
+
134
+    for (const user of users) {
135
+        const userId = await createUserInKeycloak(user, token);
136
+        await assignRole(userId, user.role, token);
137
+
138
+        const hashedPassword = await bcrypt.hash(user.password, 10);
139
+
140
+        await prisma.user.upsert({
141
+            where: { id: userId },
142
+            update: {},
143
+            create: {
144
+                id: userId,
145
+                username: user.username,
146
+                email: user.email,
147
+                firstname: user.firstname,
148
+                lastname: user.lastname,
149
+                password: hashedPassword,
150
+                role: user.role,
151
+            },
152
+        });
153
+
154
+        console.log(`✅ Success seed user ${user.role}: ${user.username}`);
155
+    }
156
+};
157
+
158
+
159
+// const axios = require('axios');
160
+// const qs = require('qs');
161
+// const bcrypt = require('bcrypt');
162
+// const prisma = require('../../src/prisma/PrismaClient.js');
163
+// const {
164
+//     KEYCLOAK_TOKEN_URL,
165
+//     KEYCLOAK_ADMIN_URL,
166
+//     KEYCLOAK_REALM,
167
+//     CLIENT_ID,
168
+//     CLIENT_SECRET,
169
+// } = require('../../config/keycloak.js');
170
+
171
+// // Ambil token admin Keycloak
172
+// const getAdminToken = async () => {
173
+//     const tokenParams = qs.stringify({
174
+//         grant_type: 'client_credentials',
175
+//         client_id: CLIENT_ID,
176
+//         client_secret: CLIENT_SECRET,
177
+//     });
178
+
179
+//     const { data } = await axios.post(KEYCLOAK_TOKEN_URL, tokenParams, {
180
+//         headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
181
+//     });
182
+
183
+//     return data.access_token;
184
+// };
185
+
186
+// // Buat user di Keycloak
187
+// const createUserInKeycloak = async (user, token) => {
188
+//     const checkUser = await axios.get(
189
+//         `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users?username=${user.username}`,
190
+//         { headers: { Authorization: `Bearer ${token}` } }
191
+//     );
192
+
193
+//     if (checkUser.data.length > 0) {
194
+//         console.log(`⚠️  User ${user.username} found in Keycloak`);
195
+//         return checkUser.data[0].id;
196
+//     }
197
+
198
+//     await axios.post(
199
+//         `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users`,
200
+//         {
201
+//             username: user.username,
202
+//             email: user.email,
203
+//             firstName: user.firstname,
204
+//             lastName: user.lastname,
205
+//             enabled: true,
206
+//             credentials: [
207
+//                 {
208
+//                     type: 'password',
209
+//                     value: user.password,
210
+//                     temporary: false,
211
+//                 },
212
+//             ],
213
+//         },
214
+//         {
215
+//             headers: { Authorization: `Bearer ${token}` },
216
+//         }
217
+//     );
218
+
219
+//     const { data } = await axios.get(
220
+//         `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users?username=${user.username}`,
221
+//         {
222
+//             headers: { Authorization: `Bearer ${token}` },
223
+//         }
224
+//     );
225
+
226
+//     return data[0].id;
227
+// };
228
+
229
+// // Assign role ke user di Keycloak
230
+// const assignRole = async (userId, roleName, token) => {
231
+//     const { data: roles } = await axios.get(
232
+//         `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/roles`,
233
+//         {
234
+//             headers: { Authorization: `Bearer ${token}` },
235
+//         }
236
+//     );
237
+
238
+//     const role = roles.find((r) => r.name === roleName);
239
+//     if (!role) throw new Error(`Role "${roleName}" not found in Keycloak`);
240
+
241
+//     await axios.post(
242
+//         `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users/${userId}/role-mappings/realm`,
243
+//         [role],
244
+//         {
245
+//             headers: { Authorization: `Bearer ${token}` },
246
+//         }
247
+//     );
248
+// };
249
+
250
+// // Data user yang ingin dibuat
251
+// const users = [
252
+//     {
253
+//         username: 'admin1',
254
+//         email: 'admin1@gmail.com',
255
+//         password: 'password123',
256
+//         firstname: 'Admin',
257
+//         lastname: 'Satu',
258
+//         role: 'admin',
259
+//     },
260
+//     {
261
+//         username: 'sales1',
262
+//         email: 'sales1@gmail.com',
263
+//         password: 'password123',
264
+//         firstname: 'Sales',
265
+//         lastname: 'Satu',
266
+//         role: 'sales',
267
+//     },
268
+//     {
269
+//         username: 'sales2',
270
+//         email: 'sales2@gmail.com',
271
+//         password: 'password123',
272
+//         firstname: 'Sales',
273
+//         lastname: 'Dua',
274
+//         role: 'sales',
275
+//     },
276
+// ];
277
+
278
+// // Fungsi utama yang bisa dipanggil dari seeder utama
279
+// const seedUsers = async () => {
280
+//     const token = await getAdminToken();
281
+
282
+//     for (const user of users) {
283
+//         const userId = await createUserInKeycloak(user, token);
284
+//         await assignRole(userId, user.role, token);
285
+
286
+//         const hashedPassword = await bcrypt.hash(user.password, 10);
287
+
288
+//         await prisma.user.upsert({
289
+//             where: { id: userId },
290
+//             update: {},
291
+//             create: {
292
+//                 id: userId,
293
+//                 username: user.username,
294
+//                 email: user.email,
295
+//                 firstname: user.firstname,
296
+//                 lastname: user.lastname,
297
+//                 password: hashedPassword,
298
+//                 role: user.role,
299
+//             },
300
+//         });
301
+
302
+//         console.log(`✅ Success seed user ${user.role}: ${user.username}`);
303
+//     }
304
+// };
305
+
306
+// module.exports = { seedUsers };

+ 0 - 57
prisma/seeders/VendorSeeder.js

@@ -1,57 +0,0 @@
1
-const prisma = require('../../src/prisma/PrismaClient.js');
2
-
3
-async function seedVendors() {
4
-    try {
5
-        // cari user role admin
6
-        const adminUser = await prisma.user.findFirst({
7
-            where: {
8
-                username: 'admin1',
9
-            },
10
-        });
11
-
12
-        if (!adminUser) {
13
-            throw new Error('User with role admin not exists');
14
-        }
15
-
16
-        // Data vendor yang akan dimasukkan
17
-        const vendors = [
18
-            {
19
-                name: 'MediSoft SIMRS',
20
-                name_pt: 'PT Medisoft Technology',
21
-                strengths: 'Antarmuka user-friendly, support lengkap untuk modul RS',
22
-                weaknesses: 'Harga relatif tinggi',
23
-                website: 'https://medisoft.co.id',
24
-            },
25
-            {
26
-                name: 'SimRS Platinum',
27
-                name_pt: 'PT Platinum Healthtech',
28
-                strengths: 'Integrasi BPJS dan telemedicine',
29
-                weaknesses: 'Customisasi sulit',
30
-                website: 'https://simrsplatinum.id',
31
-            },
32
-            {
33
-                name: 'Hospicare System',
34
-                name_pt: 'PT Hospicare Nusantara',
35
-                strengths: 'Stabil dan dokumentasi lengkap',
36
-                weaknesses: 'Kurang inovatif',
37
-                website: 'https://hospicare.co.id',
38
-            },
39
-        ];
40
-
41
-        // Insert vendor dengan created_by dari adminUser.id
42
-        for (const vendor of vendors) {
43
-            await prisma.vendor.create({
44
-                data: {
45
-                    ...vendor,
46
-                    created_by: adminUser.id,
47
-                },
48
-            });
49
-        }
50
-
51
-        console.log('✅ Vendor seeded!');
52
-    } catch (error) {
53
-        console.error('❌ Error seeding vendor:', error);
54
-    }
55
-}
56
-
57
-module.exports = { seedVendors };

+ 121 - 0
prisma/seeders/VendorSeeder.ts

@@ -0,0 +1,121 @@
1
+import prisma from '../../src/prisma/PrismaClient';
2
+
3
+interface VendorInput {
4
+    name: string;
5
+    name_pt: string;
6
+    strengths: string;
7
+    weaknesses: string;
8
+    website: string;
9
+}
10
+
11
+export async function seedVendors(): Promise<void> {
12
+    try {
13
+        // Cari user dengan username admin1
14
+        const adminUser = await prisma.user.findFirst({
15
+            where: {
16
+                username: 'admin1',
17
+            },
18
+        });
19
+
20
+        if (!adminUser) {
21
+            throw new Error('User with username admin1 not found');
22
+        }
23
+
24
+        // Daftar vendor
25
+        const vendors: VendorInput[] = [
26
+            {
27
+                name: 'MediSoft SIMRS',
28
+                name_pt: 'PT Medisoft Technology',
29
+                strengths: 'Antarmuka user-friendly, support lengkap untuk modul RS',
30
+                weaknesses: 'Harga relatif tinggi',
31
+                website: 'https://medisoft.co.id',
32
+            },
33
+            {
34
+                name: 'SimRS Platinum',
35
+                name_pt: 'PT Platinum Healthtech',
36
+                strengths: 'Integrasi BPJS dan telemedicine',
37
+                weaknesses: 'Customisasi sulit',
38
+                website: 'https://simrsplatinum.id',
39
+            },
40
+            {
41
+                name: 'Hospicare System',
42
+                name_pt: 'PT Hospicare Nusantara',
43
+                strengths: 'Stabil dan dokumentasi lengkap',
44
+                weaknesses: 'Kurang inovatif',
45
+                website: 'https://hospicare.co.id',
46
+            },
47
+        ];
48
+
49
+        // Insert ke database
50
+        for (const vendor of vendors) {
51
+            await prisma.vendor.create({
52
+                data: {
53
+                    ...vendor,
54
+                    created_by: adminUser.id,
55
+                },
56
+            });
57
+        }
58
+
59
+        console.log('✅ Vendor seeded!');
60
+    } catch (error: any) {
61
+        console.error('❌ Error seeding vendor:', error.message);
62
+    }
63
+}
64
+
65
+// const prisma = require('../../src/prisma/PrismaClient.js');
66
+
67
+// async function seedVendors() {
68
+//     try {
69
+//         // cari user role admin
70
+//         const adminUser = await prisma.user.findFirst({
71
+//             where: {
72
+//                 username: 'admin1',
73
+//             },
74
+//         });
75
+
76
+//         if (!adminUser) {
77
+//             throw new Error('User with role admin not exists');
78
+//         }
79
+
80
+//         // Data vendor yang akan dimasukkan
81
+//         const vendors = [
82
+//             {
83
+//                 name: 'MediSoft SIMRS',
84
+//                 name_pt: 'PT Medisoft Technology',
85
+//                 strengths: 'Antarmuka user-friendly, support lengkap untuk modul RS',
86
+//                 weaknesses: 'Harga relatif tinggi',
87
+//                 website: 'https://medisoft.co.id',
88
+//             },
89
+//             {
90
+//                 name: 'SimRS Platinum',
91
+//                 name_pt: 'PT Platinum Healthtech',
92
+//                 strengths: 'Integrasi BPJS dan telemedicine',
93
+//                 weaknesses: 'Customisasi sulit',
94
+//                 website: 'https://simrsplatinum.id',
95
+//             },
96
+//             {
97
+//                 name: 'Hospicare System',
98
+//                 name_pt: 'PT Hospicare Nusantara',
99
+//                 strengths: 'Stabil dan dokumentasi lengkap',
100
+//                 weaknesses: 'Kurang inovatif',
101
+//                 website: 'https://hospicare.co.id',
102
+//             },
103
+//         ];
104
+
105
+//         // Insert vendor dengan created_by dari adminUser.id
106
+//         for (const vendor of vendors) {
107
+//             await prisma.vendor.create({
108
+//                 data: {
109
+//                     ...vendor,
110
+//                     created_by: adminUser.id,
111
+//                 },
112
+//             });
113
+//         }
114
+
115
+//         console.log('✅ Vendor seeded!');
116
+//     } catch (error) {
117
+//         console.error('❌ Error seeding vendor:', error);
118
+//     }
119
+// }
120
+
121
+// module.exports = { seedVendors };

+ 0 - 62
prisma/seeders/city/AcehCitySeeder.js

@@ -1,62 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Aceh Barat',
6
-    'Kabupaten Aceh Barat Daya',
7
-    'Kabupaten Aceh Besar',
8
-    'Kabupaten Aceh Jaya',
9
-    'Kabupaten Aceh Selatan',
10
-    'Kabupaten Aceh Singkil',
11
-    'Kabupaten Aceh Tamiang',
12
-    'Kabupaten Aceh Tengah',
13
-    'Kabupaten Aceh Tenggara',
14
-    'Kabupaten Aceh Timur',
15
-    'Kabupaten Aceh Utara',
16
-    'Kabupaten Bener Meriah',
17
-    'Kabupaten Bireuen',
18
-    'Kabupaten Gayo Lues',
19
-    'Kabupaten Nagan Raya',
20
-    'Kabupaten Pidie',
21
-    'Kabupaten Pidie Jaya',
22
-    'Kabupaten Simeulue',
23
-    'Kota Banda Aceh',
24
-    'Kota Langsa',
25
-    'Kota Lhokseumawe',
26
-    'Kota Sabang',
27
-    'Kota Subulussalam'
28
-
29
-    // 23
30
-];
31
-
32
-exports.seedAcehCities = async () => {
33
-    const province = await prisma.province.findFirst({
34
-        where: { name: 'Aceh' },
35
-    });
36
-
37
-    if (!province) {
38
-        console.error('❌ Province Aceh not found. Seed it first.');
39
-        return;
40
-    }
41
-
42
-    for (const name of cityNames) {
43
-        await prisma.city.upsert({
44
-            where: {
45
-                name_province_id: {
46
-                    name,
47
-                    province_id: province.id,
48
-                },
49
-            },
50
-            create: {
51
-                name,
52
-                province_id: province.id,
53
-                updatedAt: timeLocal.now().toDate()
54
-            },
55
-            update: {
56
-                updatedAt: timeLocal.now().toDate()
57
-            }
58
-        });
59
-    }
60
-
61
-    console.log('✅ Aceh City seeded!.');
62
-};

+ 124 - 0
prisma/seeders/city/AcehCitySeeder.ts

@@ -0,0 +1,124 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Aceh Barat',
6
+    'Kabupaten Aceh Barat Daya',
7
+    'Kabupaten Aceh Besar',
8
+    'Kabupaten Aceh Jaya',
9
+    'Kabupaten Aceh Selatan',
10
+    'Kabupaten Aceh Singkil',
11
+    'Kabupaten Aceh Tamiang',
12
+    'Kabupaten Aceh Tengah',
13
+    'Kabupaten Aceh Tenggara',
14
+    'Kabupaten Aceh Timur',
15
+    'Kabupaten Aceh Utara',
16
+    'Kabupaten Bener Meriah',
17
+    'Kabupaten Bireuen',
18
+    'Kabupaten Gayo Lues',
19
+    'Kabupaten Nagan Raya',
20
+    'Kabupaten Pidie',
21
+    'Kabupaten Pidie Jaya',
22
+    'Kabupaten Simeulue',
23
+    'Kota Banda Aceh',
24
+    'Kota Langsa',
25
+    'Kota Lhokseumawe',
26
+    'Kota Sabang',
27
+    'Kota Subulussalam'
28
+];
29
+
30
+export async function seedAcehCities(): Promise<void> {
31
+    const province = await prisma.province.findFirst({
32
+        where: { name: 'Aceh' },
33
+    });
34
+
35
+    if (!province) {
36
+        console.error('❌ Province Aceh not found. Seed it first.');
37
+        return;
38
+    }
39
+
40
+    for (const name of cityNames) {
41
+        await prisma.city.upsert({
42
+            where: {
43
+                name_province_id: {
44
+                    name,
45
+                    province_id: province.id,
46
+                },
47
+            },
48
+            create: {
49
+                name,
50
+                province_id: province.id,
51
+                updatedAt: now().toDate(),
52
+            },
53
+            update: {
54
+                updatedAt: now().toDate(),
55
+            },
56
+        });
57
+    }
58
+
59
+    console.log('✅ Aceh City seeded!');
60
+}
61
+
62
+
63
+// const prisma = require('../../../src/prisma/PrismaClient.js');
64
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
65
+
66
+// const cityNames = [
67
+//     'Kabupaten Aceh Barat',
68
+//     'Kabupaten Aceh Barat Daya',
69
+//     'Kabupaten Aceh Besar',
70
+//     'Kabupaten Aceh Jaya',
71
+//     'Kabupaten Aceh Selatan',
72
+//     'Kabupaten Aceh Singkil',
73
+//     'Kabupaten Aceh Tamiang',
74
+//     'Kabupaten Aceh Tengah',
75
+//     'Kabupaten Aceh Tenggara',
76
+//     'Kabupaten Aceh Timur',
77
+//     'Kabupaten Aceh Utara',
78
+//     'Kabupaten Bener Meriah',
79
+//     'Kabupaten Bireuen',
80
+//     'Kabupaten Gayo Lues',
81
+//     'Kabupaten Nagan Raya',
82
+//     'Kabupaten Pidie',
83
+//     'Kabupaten Pidie Jaya',
84
+//     'Kabupaten Simeulue',
85
+//     'Kota Banda Aceh',
86
+//     'Kota Langsa',
87
+//     'Kota Lhokseumawe',
88
+//     'Kota Sabang',
89
+//     'Kota Subulussalam'
90
+
91
+//     // 23
92
+// ];
93
+
94
+// exports.seedAcehCities = async () => {
95
+//     const province = await prisma.province.findFirst({
96
+//         where: { name: 'Aceh' },
97
+//     });
98
+
99
+//     if (!province) {
100
+//         console.error('❌ Province Aceh not found. Seed it first.');
101
+//         return;
102
+//     }
103
+
104
+//     for (const name of cityNames) {
105
+//         await prisma.city.upsert({
106
+//             where: {
107
+//                 name_province_id: {
108
+//                     name,
109
+//                     province_id: province.id,
110
+//                 },
111
+//             },
112
+//             create: {
113
+//                 name,
114
+//                 province_id: province.id,
115
+//                 updatedAt: timeLocal.now().toDate()
116
+//             },
117
+//             update: {
118
+//                 updatedAt: timeLocal.now().toDate()
119
+//             }
120
+//         });
121
+//     }
122
+
123
+//     console.log('✅ Aceh City seeded!.');
124
+// };

+ 0 - 48
prisma/seeders/city/BaliCitySeeder.js

@@ -1,48 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Badung',
6
-    'Kabupaten Bangli',
7
-    'Kabupaten Buleleng',
8
-    'Kabupaten Gianyar',
9
-    'Kabupaten Jembrana',
10
-    'Kabupaten Karangasem',
11
-    'Kabupaten Klungkung',
12
-    'Kabupaten Tabanan',
13
-    'Kota Denpasar'
14
-
15
-    // 9
16
-];
17
-
18
-exports.seedBaliCities = async () => {
19
-    const province = await prisma.province.findFirst({
20
-        where: { name: 'Bali' },
21
-    });
22
-
23
-    if (!province) {
24
-        console.error('❌ Province Bali not found. Seed it first.');
25
-        return;
26
-    }
27
-
28
-    for (const name of cityNames) {
29
-        await prisma.city.upsert({
30
-            where: {
31
-                name_province_id: {
32
-                    name,
33
-                    province_id: province.id,
34
-                },
35
-            },
36
-            update: {
37
-                updatedAt: timeLocal.now().toDate()
38
-            },
39
-            create: {
40
-                name,
41
-                province_id: province.id,
42
-                createdAt: timeLocal.now().toDate()
43
-            },
44
-        });
45
-    }
46
-
47
-    console.log('✅ Bali City seeded!.');
48
-};

+ 96 - 0
prisma/seeders/city/BaliCitySeeder.ts

@@ -0,0 +1,96 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Badung',
6
+    'Kabupaten Bangli',
7
+    'Kabupaten Buleleng',
8
+    'Kabupaten Gianyar',
9
+    'Kabupaten Jembrana',
10
+    'Kabupaten Karangasem',
11
+    'Kabupaten Klungkung',
12
+    'Kabupaten Tabanan',
13
+    'Kota Denpasar'
14
+];
15
+
16
+export async function seedBaliCities(): Promise<void> {
17
+    const province = await prisma.province.findFirst({
18
+        where: { name: 'Bali' },
19
+    });
20
+
21
+    if (!province) {
22
+        console.error('❌ Province Bali not found. Seed it first.');
23
+        return;
24
+    }
25
+
26
+    for (const name of cityNames) {
27
+        await prisma.city.upsert({
28
+            where: {
29
+                name_province_id: {
30
+                    name,
31
+                    province_id: province.id,
32
+                },
33
+            },
34
+            update: {
35
+                updatedAt: now().toDate(),
36
+            },
37
+            create: {
38
+                name,
39
+                province_id: province.id,
40
+                createdAt: now().toDate(),
41
+            },
42
+        });
43
+    }
44
+
45
+    console.log('✅ Bali City seeded!');
46
+}
47
+
48
+
49
+// const prisma = require('../../../src/prisma/PrismaClient.js');
50
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
51
+
52
+// const cityNames = [
53
+//     'Kabupaten Badung',
54
+//     'Kabupaten Bangli',
55
+//     'Kabupaten Buleleng',
56
+//     'Kabupaten Gianyar',
57
+//     'Kabupaten Jembrana',
58
+//     'Kabupaten Karangasem',
59
+//     'Kabupaten Klungkung',
60
+//     'Kabupaten Tabanan',
61
+//     'Kota Denpasar'
62
+
63
+//     // 9
64
+// ];
65
+
66
+// exports.seedBaliCities = async () => {
67
+//     const province = await prisma.province.findFirst({
68
+//         where: { name: 'Bali' },
69
+//     });
70
+
71
+//     if (!province) {
72
+//         console.error('❌ Province Bali not found. Seed it first.');
73
+//         return;
74
+//     }
75
+
76
+//     for (const name of cityNames) {
77
+//         await prisma.city.upsert({
78
+//             where: {
79
+//                 name_province_id: {
80
+//                     name,
81
+//                     province_id: province.id,
82
+//                 },
83
+//             },
84
+//             update: {
85
+//                 updatedAt: timeLocal.now().toDate()
86
+//             },
87
+//             create: {
88
+//                 name,
89
+//                 province_id: province.id,
90
+//                 createdAt: timeLocal.now().toDate()
91
+//             },
92
+//         });
93
+//     }
94
+
95
+//     console.log('✅ Bali City seeded!.');
96
+// };

+ 0 - 47
prisma/seeders/city/BantenCitySeeder.js

@@ -1,47 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Lebak',
6
-    'Kabupaten Pandeglang',
7
-    'Kabupaten Serang',
8
-    'Kabupaten Tangerang',
9
-    'Kota Cilegon',
10
-    'Kota Serang',
11
-    'Kota Tangerang',
12
-    'Kota Tangerang Selatan'
13
-
14
-    // 8
15
-];
16
-
17
-exports.seedBantenCities = async () => {
18
-    const province = await prisma.province.findFirst({
19
-        where: { name: 'Banten' },
20
-    });
21
-
22
-    if (!province) {
23
-        console.error('❌ Province Banten not found. Seed it first.');
24
-        return;
25
-    }
26
-
27
-    for (const name of cityNames) {
28
-        await prisma.city.upsert({
29
-            where: {
30
-                name_province_id: {
31
-                    name,
32
-                    province_id: province.id,
33
-                },
34
-            },
35
-            update: {
36
-                updatedAt: timeLocal.now().toDate()
37
-            },
38
-            create: {
39
-                name,
40
-                province_id: province.id,
41
-                createdAt: timeLocal.now().toDate()
42
-            },
43
-        });
44
-    }
45
-
46
-    console.log('✅ Banten City seeded!.');
47
-};

+ 93 - 0
prisma/seeders/city/BantenCitySeeder.ts

@@ -0,0 +1,93 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Lebak',
6
+    'Kabupaten Pandeglang',
7
+    'Kabupaten Serang',
8
+    'Kabupaten Tangerang',
9
+    'Kota Cilegon',
10
+    'Kota Serang',
11
+    'Kota Tangerang',
12
+    'Kota Tangerang Selatan'
13
+];
14
+
15
+export async function seedBantenCities(): Promise<void> {
16
+    const province = await prisma.province.findFirst({
17
+        where: { name: 'Banten' },
18
+    });
19
+
20
+    if (!province) {
21
+        console.error('❌ Province Banten not found. Seed it first.');
22
+        return;
23
+    }
24
+
25
+    for (const name of cityNames) {
26
+        await prisma.city.upsert({
27
+            where: {
28
+                name_province_id: {
29
+                    name,
30
+                    province_id: province.id,
31
+                },
32
+            },
33
+            update: {
34
+                updatedAt: now().toDate(),
35
+            },
36
+            create: {
37
+                name,
38
+                province_id: province.id,
39
+                createdAt: now().toDate(),
40
+            },
41
+        });
42
+    }
43
+
44
+    console.log('✅ Banten City seeded!');
45
+}
46
+
47
+// const prisma = require('../../../src/prisma/PrismaClient.js');
48
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
49
+
50
+// const cityNames = [
51
+//     'Kabupaten Lebak',
52
+//     'Kabupaten Pandeglang',
53
+//     'Kabupaten Serang',
54
+//     'Kabupaten Tangerang',
55
+//     'Kota Cilegon',
56
+//     'Kota Serang',
57
+//     'Kota Tangerang',
58
+//     'Kota Tangerang Selatan'
59
+
60
+//     // 8
61
+// ];
62
+
63
+// exports.seedBantenCities = async () => {
64
+//     const province = await prisma.province.findFirst({
65
+//         where: { name: 'Banten' },
66
+//     });
67
+
68
+//     if (!province) {
69
+//         console.error('❌ Province Banten not found. Seed it first.');
70
+//         return;
71
+//     }
72
+
73
+//     for (const name of cityNames) {
74
+//         await prisma.city.upsert({
75
+//             where: {
76
+//                 name_province_id: {
77
+//                     name,
78
+//                     province_id: province.id,
79
+//                 },
80
+//             },
81
+//             update: {
82
+//                 updatedAt: timeLocal.now().toDate()
83
+//             },
84
+//             create: {
85
+//                 name,
86
+//                 province_id: province.id,
87
+//                 createdAt: timeLocal.now().toDate()
88
+//             },
89
+//         });
90
+//     }
91
+
92
+//     console.log('✅ Banten City seeded!.');
93
+// };

+ 0 - 47
prisma/seeders/city/BengkuluCitySeeder.js

@@ -1,47 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bengkulu Selatan',
6
-    'Kabupaten Bengkulu Tengah',
7
-    'Kabupaten Bengkulu Utara',
8
-    'Kabupaten Kaur',
9
-    'Kabupaten Kepahiang',
10
-    'Kabupaten Lebong',
11
-    'Kabupaten Muko Muko',
12
-    'Kabupaten Rejang Lebong',
13
-    'Kabupaten Seluma',
14
-    'Kota Bengkulu'
15
-
16
-    // 10
17
-];
18
-
19
-exports.seedBengkuluCities = async () => {
20
-    const province = await prisma.province.findFirst({
21
-        where: { name: 'Bengkulu' },
22
-    });
23
-
24
-    if (!province) {
25
-        console.error('❌ Province Bengkulu not found. Seed it first.');
26
-        return;
27
-    }
28
-
29
-    for (const name of cityNames) {
30
-        await prisma.city.upsert({
31
-            where: {
32
-                name_province_id: {
33
-                    name,
34
-                    province_id: province.id,
35
-                },
36
-            },
37
-            update: { updatedAt: timeLocal.now().toDate() },
38
-            create: {
39
-                name,
40
-                province_id: province.id,
41
-                createdAt: timeLocal.now().toDate()
42
-            },
43
-        });
44
-    }
45
-
46
-    console.log('✅ Bengkulu City seeded!.');
47
-};

+ 96 - 0
prisma/seeders/city/BengkuluCitySeeder.ts

@@ -0,0 +1,96 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bengkulu Selatan',
6
+    'Kabupaten Bengkulu Tengah',
7
+    'Kabupaten Bengkulu Utara',
8
+    'Kabupaten Kaur',
9
+    'Kabupaten Kepahiang',
10
+    'Kabupaten Lebong',
11
+    'Kabupaten Muko Muko',
12
+    'Kabupaten Rejang Lebong',
13
+    'Kabupaten Seluma',
14
+    'Kota Bengkulu'
15
+];
16
+
17
+export async function seedBengkuluCities(): Promise<void> {
18
+    const province = await prisma.province.findFirst({
19
+        where: { name: 'Bengkulu' },
20
+    });
21
+
22
+    if (!province) {
23
+        console.error('❌ Province Bengkulu not found. Seed it first.');
24
+        return;
25
+    }
26
+
27
+    for (const name of cityNames) {
28
+        await prisma.city.upsert({
29
+            where: {
30
+                name_province_id: {
31
+                    name,
32
+                    province_id: province.id,
33
+                },
34
+            },
35
+            update: {
36
+                updatedAt: now().toDate(),
37
+            },
38
+            create: {
39
+                name,
40
+                province_id: province.id,
41
+                createdAt: now().toDate(),
42
+            },
43
+        });
44
+    }
45
+
46
+    console.log('✅ Bengkulu City seeded!');
47
+}
48
+
49
+
50
+// const prisma = require('../../../src/prisma/PrismaClient.js');
51
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
52
+
53
+// const cityNames = [
54
+//     'Kabupaten Bengkulu Selatan',
55
+//     'Kabupaten Bengkulu Tengah',
56
+//     'Kabupaten Bengkulu Utara',
57
+//     'Kabupaten Kaur',
58
+//     'Kabupaten Kepahiang',
59
+//     'Kabupaten Lebong',
60
+//     'Kabupaten Muko Muko',
61
+//     'Kabupaten Rejang Lebong',
62
+//     'Kabupaten Seluma',
63
+//     'Kota Bengkulu'
64
+
65
+//     // 10
66
+// ];
67
+
68
+// exports.seedBengkuluCities = async () => {
69
+//     const province = await prisma.province.findFirst({
70
+//         where: { name: 'Bengkulu' },
71
+//     });
72
+
73
+//     if (!province) {
74
+//         console.error('❌ Province Bengkulu not found. Seed it first.');
75
+//         return;
76
+//     }
77
+
78
+//     for (const name of cityNames) {
79
+//         await prisma.city.upsert({
80
+//             where: {
81
+//                 name_province_id: {
82
+//                     name,
83
+//                     province_id: province.id,
84
+//                 },
85
+//             },
86
+//             update: { updatedAt: timeLocal.now().toDate() },
87
+//             create: {
88
+//                 name,
89
+//                 province_id: province.id,
90
+//                 createdAt: timeLocal.now().toDate()
91
+//             },
92
+//         });
93
+//     }
94
+
95
+//     console.log('✅ Bengkulu City seeded!.');
96
+// };

+ 0 - 42
prisma/seeders/city/DIYogyakartaCitySeeder.js

@@ -1,42 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bantul',
6
-    'Kabupaten Gunungkidul',
7
-    'Kabupaten Kulon Progo',
8
-    'Kabupaten Sleman',
9
-    'Kota Yogyakarta'
10
-
11
-    // 5
12
-];
13
-
14
-exports.seedDIYogyakartaCities = async () => {
15
-    const province = await prisma.province.findFirst({
16
-        where: { name: 'DI Yogyakarta' },
17
-    });
18
-
19
-    if (!province) {
20
-        console.error('❌ Province DI Yogyakarta not found. Seed it first.');
21
-        return;
22
-    }
23
-
24
-    for (const name of cityNames) {
25
-        await prisma.city.upsert({
26
-            where: {
27
-                name_province_id: {
28
-                    name,
29
-                    province_id: province.id,
30
-                },
31
-            },
32
-            update: { updatedAt: timeLocal.now().toDate() },
33
-            create: {
34
-                name,
35
-                province_id: province.id,
36
-                createdAt: timeLocal.now().toDate()
37
-            },
38
-        });
39
-    }
40
-
41
-    console.log('✅ DI Yogyakarta City seeded!.');
42
-};

+ 83 - 0
prisma/seeders/city/DIYogyakartaCitySeeder.ts

@@ -0,0 +1,83 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bantul',
6
+    'Kabupaten Gunungkidul',
7
+    'Kabupaten Kulon Progo',
8
+    'Kabupaten Sleman',
9
+    'Kota Yogyakarta'
10
+];
11
+
12
+export async function seedDIYogyakartaCities(): Promise<void> {
13
+    const province = await prisma.province.findFirst({
14
+        where: { name: 'DI Yogyakarta' },
15
+    });
16
+
17
+    if (!province) {
18
+        console.error('❌ Province DI Yogyakarta not found. Seed it first.');
19
+        return;
20
+    }
21
+
22
+    for (const name of cityNames) {
23
+        await prisma.city.upsert({
24
+            where: {
25
+                name_province_id: {
26
+                    name,
27
+                    province_id: province.id,
28
+                },
29
+            },
30
+            update: { updatedAt: now().toDate() },
31
+            create: {
32
+                name,
33
+                province_id: province.id,
34
+                createdAt: now().toDate(),
35
+            },
36
+        });
37
+    }
38
+
39
+    console.log('✅ DI Yogyakarta City seeded!');
40
+}
41
+
42
+// const prisma = require('../../../src/prisma/PrismaClient.js');
43
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
44
+
45
+// const cityNames = [
46
+//     'Kabupaten Bantul',
47
+//     'Kabupaten Gunungkidul',
48
+//     'Kabupaten Kulon Progo',
49
+//     'Kabupaten Sleman',
50
+//     'Kota Yogyakarta'
51
+
52
+//     // 5
53
+// ];
54
+
55
+// exports.seedDIYogyakartaCities = async () => {
56
+//     const province = await prisma.province.findFirst({
57
+//         where: { name: 'DI Yogyakarta' },
58
+//     });
59
+
60
+//     if (!province) {
61
+//         console.error('❌ Province DI Yogyakarta not found. Seed it first.');
62
+//         return;
63
+//     }
64
+
65
+//     for (const name of cityNames) {
66
+//         await prisma.city.upsert({
67
+//             where: {
68
+//                 name_province_id: {
69
+//                     name,
70
+//                     province_id: province.id,
71
+//                 },
72
+//             },
73
+//             update: { updatedAt: timeLocal.now().toDate() },
74
+//             create: {
75
+//                 name,
76
+//                 province_id: province.id,
77
+//                 createdAt: timeLocal.now().toDate()
78
+//             },
79
+//         });
80
+//     }
81
+
82
+//     console.log('✅ DI Yogyakarta City seeded!.');
83
+// };

+ 0 - 45
prisma/seeders/city/DKIJakartaCitySeeder.js

@@ -1,45 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Kepulauan Seribu',
6
-    'Kota Jakarta Barat',
7
-    'Kota Jakarta Pusat',
8
-    'Kota Jakarta Selatan',
9
-    'Kota Jakarta Timur',
10
-    'Kota Jakarta Utara'
11
-
12
-    // 6
13
-];
14
-
15
-exports.seedDKIJakartaCities = async () => {
16
-    const province = await prisma.province.findFirst({
17
-        where: { name: 'DKI Jakarta' },
18
-    });
19
-
20
-    if (!province) {
21
-        console.error('❌ Province DKI Jakarta not found. Seed it first.');
22
-        return;
23
-    }
24
-
25
-    for (const name of cityNames) {
26
-        await prisma.city.upsert({
27
-            where: {
28
-                name_province_id: {
29
-                    name,
30
-                    province_id: province.id,
31
-                },
32
-            },
33
-            update: {
34
-                updatedAt: timeLocal.now().toDate()
35
-            },
36
-            create: {
37
-                name,
38
-                province_id: province.id,
39
-                createdAt: timeLocal.now().toDate()
40
-            },
41
-        });
42
-    }
43
-
44
-    console.log('✅ DKI Jakarta City seeded!.');
45
-};

+ 90 - 0
prisma/seeders/city/DKIJakartaCitySeeder.ts

@@ -0,0 +1,90 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Kepulauan Seribu',
6
+    'Kota Jakarta Barat',
7
+    'Kota Jakarta Pusat',
8
+    'Kota Jakarta Selatan',
9
+    'Kota Jakarta Timur',
10
+    'Kota Jakarta Utara'
11
+];
12
+
13
+export async function seedDKIJakartaCities(): Promise<void> {
14
+    const province = await prisma.province.findFirst({
15
+        where: { name: 'DKI Jakarta' },
16
+    });
17
+
18
+    if (!province) {
19
+        console.error('❌ Province DKI Jakarta not found. Seed it first.');
20
+        return;
21
+    }
22
+
23
+    for (const name of cityNames) {
24
+        await prisma.city.upsert({
25
+            where: {
26
+                name_province_id: {
27
+                    name,
28
+                    province_id: province.id,
29
+                },
30
+            },
31
+            update: {
32
+                updatedAt: now().toDate(),
33
+            },
34
+            create: {
35
+                name,
36
+                province_id: province.id,
37
+                createdAt: now().toDate(),
38
+            },
39
+        });
40
+    }
41
+
42
+    console.log('✅ DKI Jakarta City seeded!');
43
+}
44
+
45
+
46
+// const prisma = require('../../../src/prisma/PrismaClient.js');
47
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
48
+
49
+// const cityNames = [
50
+//     'Kabupaten Kepulauan Seribu',
51
+//     'Kota Jakarta Barat',
52
+//     'Kota Jakarta Pusat',
53
+//     'Kota Jakarta Selatan',
54
+//     'Kota Jakarta Timur',
55
+//     'Kota Jakarta Utara'
56
+
57
+//     // 6
58
+// ];
59
+
60
+// exports.seedDKIJakartaCities = async () => {
61
+//     const province = await prisma.province.findFirst({
62
+//         where: { name: 'DKI Jakarta' },
63
+//     });
64
+
65
+//     if (!province) {
66
+//         console.error('❌ Province DKI Jakarta not found. Seed it first.');
67
+//         return;
68
+//     }
69
+
70
+//     for (const name of cityNames) {
71
+//         await prisma.city.upsert({
72
+//             where: {
73
+//                 name_province_id: {
74
+//                     name,
75
+//                     province_id: province.id,
76
+//                 },
77
+//             },
78
+//             update: {
79
+//                 updatedAt: timeLocal.now().toDate()
80
+//             },
81
+//             create: {
82
+//                 name,
83
+//                 province_id: province.id,
84
+//                 createdAt: timeLocal.now().toDate()
85
+//             },
86
+//         });
87
+//     }
88
+
89
+//     console.log('✅ DKI Jakarta City seeded!.');
90
+// };

+ 0 - 45
prisma/seeders/city/GorontaloCitySeeder.js

@@ -1,45 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Boalemo',
6
-    'Kabupaten Bone Bolango',
7
-    'Kabupaten Gorontalo',
8
-    'Kabupaten Gorontalo Utara',
9
-    'Kabupaten Pohuwato',
10
-    'Kota Gorontalo'
11
-
12
-    // 6
13
-];
14
-
15
-exports.seedGorontaloCities = async () => {
16
-    const province = await prisma.province.findFirst({
17
-        where: { name: 'Gorontalo' },
18
-    });
19
-
20
-    if (!province) {
21
-        console.error('❌ Province Gorontalo not found. Seed it first.');
22
-        return;
23
-    }
24
-
25
-    for (const name of cityNames) {
26
-        await prisma.city.upsert({
27
-            where: {
28
-                name_province_id: {
29
-                    name,
30
-                    province_id: province.id,
31
-                },
32
-            },
33
-            update: {
34
-                updatedAt: timeLocal.now().toDate()
35
-            },
36
-            create: {
37
-                name,
38
-                province_id: province.id,
39
-                createdAt: timeLocal.now().toDate()
40
-            },
41
-        });
42
-    }
43
-
44
-    console.log('✅ Gorontalo City seeded!.');
45
-};

+ 89 - 0
prisma/seeders/city/GorontaloCitySeeder.ts

@@ -0,0 +1,89 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Boalemo',
6
+    'Kabupaten Bone Bolango',
7
+    'Kabupaten Gorontalo',
8
+    'Kabupaten Gorontalo Utara',
9
+    'Kabupaten Pohuwato',
10
+    'Kota Gorontalo'
11
+];
12
+
13
+export async function seedGorontaloCities(): Promise<void> {
14
+    const province = await prisma.province.findFirst({
15
+        where: { name: 'Gorontalo' },
16
+    });
17
+
18
+    if (!province) {
19
+        console.error('❌ Province Gorontalo not found. Seed it first.');
20
+        return;
21
+    }
22
+
23
+    for (const name of cityNames) {
24
+        await prisma.city.upsert({
25
+            where: {
26
+                name_province_id: {
27
+                    name,
28
+                    province_id: province.id,
29
+                },
30
+            },
31
+            update: {
32
+                updatedAt: now().toDate(),
33
+            },
34
+            create: {
35
+                name,
36
+                province_id: province.id,
37
+                createdAt: now().toDate(),
38
+            },
39
+        });
40
+    }
41
+
42
+    console.log('✅ Gorontalo City seeded!');
43
+}
44
+
45
+// const prisma = require('../../../src/prisma/PrismaClient.js');
46
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
47
+
48
+// const cityNames = [
49
+//     'Kabupaten Boalemo',
50
+//     'Kabupaten Bone Bolango',
51
+//     'Kabupaten Gorontalo',
52
+//     'Kabupaten Gorontalo Utara',
53
+//     'Kabupaten Pohuwato',
54
+//     'Kota Gorontalo'
55
+
56
+//     // 6
57
+// ];
58
+
59
+// exports.seedGorontaloCities = async () => {
60
+//     const province = await prisma.province.findFirst({
61
+//         where: { name: 'Gorontalo' },
62
+//     });
63
+
64
+//     if (!province) {
65
+//         console.error('❌ Province Gorontalo not found. Seed it first.');
66
+//         return;
67
+//     }
68
+
69
+//     for (const name of cityNames) {
70
+//         await prisma.city.upsert({
71
+//             where: {
72
+//                 name_province_id: {
73
+//                     name,
74
+//                     province_id: province.id,
75
+//                 },
76
+//             },
77
+//             update: {
78
+//                 updatedAt: timeLocal.now().toDate()
79
+//             },
80
+//             create: {
81
+//                 name,
82
+//                 province_id: province.id,
83
+//                 createdAt: timeLocal.now().toDate()
84
+//             },
85
+//         });
86
+//     }
87
+
88
+//     console.log('✅ Gorontalo City seeded!.');
89
+// };

+ 0 - 50
prisma/seeders/city/JambiCitySeeder.js

@@ -1,50 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Batang Hari',
6
-    'Kabupaten Bungo',
7
-    'Kabupaten Kerinci',
8
-    'Kabupaten Merangin',
9
-    'Kabupaten Muaro Jambi',
10
-    'Kabupaten Sarolangun',
11
-    'Kabupaten Tanjung Jabung Barat',
12
-    'Kabupaten Tanjung Jabung Timur',
13
-    'Kabupaten Tebo',
14
-    'Kota Jambi',
15
-    'Kota Sungai Penuh'
16
-
17
-    // 11
18
-];
19
-
20
-exports.seedJambiCities = async () => {
21
-    const province = await prisma.province.findFirst({
22
-        where: { name: 'Jambi' },
23
-    });
24
-
25
-    if (!province) {
26
-        console.error('❌ Province Jambi not found. Seed it first.');
27
-        return;
28
-    }
29
-
30
-    for (const name of cityNames) {
31
-        await prisma.city.upsert({
32
-            where: {
33
-                name_province_id: {
34
-                    name,
35
-                    province_id: province.id,
36
-                },
37
-            },
38
-            update: {
39
-                updatedAt: timeLocal.now().toDate()
40
-            },
41
-            create: {
42
-                name,
43
-                province_id: province.id,
44
-                createdAt: timeLocal.now().toDate()
45
-            },
46
-        });
47
-    }
48
-
49
-    console.log('✅ Jambi City seeded!.');
50
-};

+ 100 - 0
prisma/seeders/city/JambiCitySeeder.ts

@@ -0,0 +1,100 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Batang Hari',
6
+    'Kabupaten Bungo',
7
+    'Kabupaten Kerinci',
8
+    'Kabupaten Merangin',
9
+    'Kabupaten Muaro Jambi',
10
+    'Kabupaten Sarolangun',
11
+    'Kabupaten Tanjung Jabung Barat',
12
+    'Kabupaten Tanjung Jabung Timur',
13
+    'Kabupaten Tebo',
14
+    'Kota Jambi',
15
+    'Kota Sungai Penuh'
16
+];
17
+
18
+export async function seedJambiCities(): Promise<void> {
19
+    const province = await prisma.province.findFirst({
20
+        where: { name: 'Jambi' },
21
+    });
22
+
23
+    if (!province) {
24
+        console.error('❌ Province Jambi not found. Seed it first.');
25
+        return;
26
+    }
27
+
28
+    for (const name of cityNames) {
29
+        await prisma.city.upsert({
30
+            where: {
31
+                name_province_id: {
32
+                    name,
33
+                    province_id: province.id,
34
+                },
35
+            },
36
+            update: {
37
+                updatedAt: now().toDate(),
38
+            },
39
+            create: {
40
+                name,
41
+                province_id: province.id,
42
+                createdAt: now().toDate(),
43
+            },
44
+        });
45
+    }
46
+
47
+    console.log('✅ Jambi City seeded!');
48
+}
49
+
50
+
51
+// const prisma = require('../../../src/prisma/PrismaClient.js');
52
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
53
+
54
+// const cityNames = [
55
+//     'Kabupaten Batang Hari',
56
+//     'Kabupaten Bungo',
57
+//     'Kabupaten Kerinci',
58
+//     'Kabupaten Merangin',
59
+//     'Kabupaten Muaro Jambi',
60
+//     'Kabupaten Sarolangun',
61
+//     'Kabupaten Tanjung Jabung Barat',
62
+//     'Kabupaten Tanjung Jabung Timur',
63
+//     'Kabupaten Tebo',
64
+//     'Kota Jambi',
65
+//     'Kota Sungai Penuh'
66
+
67
+//     // 11
68
+// ];
69
+
70
+// exports.seedJambiCities = async () => {
71
+//     const province = await prisma.province.findFirst({
72
+//         where: { name: 'Jambi' },
73
+//     });
74
+
75
+//     if (!province) {
76
+//         console.error('❌ Province Jambi not found. Seed it first.');
77
+//         return;
78
+//     }
79
+
80
+//     for (const name of cityNames) {
81
+//         await prisma.city.upsert({
82
+//             where: {
83
+//                 name_province_id: {
84
+//                     name,
85
+//                     province_id: province.id,
86
+//                 },
87
+//             },
88
+//             update: {
89
+//                 updatedAt: timeLocal.now().toDate()
90
+//             },
91
+//             create: {
92
+//                 name,
93
+//                 province_id: province.id,
94
+//                 createdAt: timeLocal.now().toDate()
95
+//             },
96
+//         });
97
+//     }
98
+
99
+//     console.log('✅ Jambi City seeded!.');
100
+// };

+ 0 - 66
prisma/seeders/city/JawaBaratCitySeeder.js

@@ -1,66 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bandung',
6
-    'Kabupaten Bandung Barat',
7
-    'Kabupaten Bekasi',
8
-    'Kabupaten Bogor',
9
-    'Kabupaten Ciamis',
10
-    'Kabupaten Cianjur',
11
-    'Kabupaten Cirebon',
12
-    'Kabupaten Garut',
13
-    'Kabupaten Indramayu',
14
-    'Kabupaten Karawang',
15
-    'Kabupaten Kuningan',
16
-    'Kabupaten Majalengka',
17
-    'Kabupaten Pangandaran',
18
-    'Kabupaten Purwakarta',
19
-    'Kabupaten Subang',
20
-    'Kabupaten Sukabumi',
21
-    'Kabupaten Sumedang',
22
-    'Kabupaten Tasikmalaya',
23
-    'Kota Bandung',
24
-    'Kota Banjar',
25
-    'Kota Bekasi',
26
-    'Kota Bogor',
27
-    'Kota Cimahi',
28
-    'Kota Cirebon',
29
-    'Kota Depok',
30
-    'Kota Sukabumi',
31
-    'Kota Tasikmalaya'
32
-
33
-    // 27
34
-];
35
-
36
-exports.seedJawaBaratCities = async () => {
37
-    const province = await prisma.province.findFirst({
38
-        where: { name: 'Jawa Barat' },
39
-    });
40
-
41
-    if (!province) {
42
-        console.error('❌ Province Jawa Barat not found. Seed it first.');
43
-        return;
44
-    }
45
-
46
-    for (const name of cityNames) {
47
-        await prisma.city.upsert({
48
-            where: {
49
-                name_province_id: {
50
-                    name,
51
-                    province_id: province.id,
52
-                },
53
-            },
54
-            update: {
55
-                updatedAt: timeLocal.now().toDate()
56
-            },
57
-            create: {
58
-                name,
59
-                province_id: province.id,
60
-                createdAt: timeLocal.now().toDate()
61
-            },
62
-        });
63
-    }
64
-
65
-    console.log('✅ Jawa Barat City seeded!.');
66
-};

+ 131 - 0
prisma/seeders/city/JawaBaratCitySeeder.ts

@@ -0,0 +1,131 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bandung',
6
+    'Kabupaten Bandung Barat',
7
+    'Kabupaten Bekasi',
8
+    'Kabupaten Bogor',
9
+    'Kabupaten Ciamis',
10
+    'Kabupaten Cianjur',
11
+    'Kabupaten Cirebon',
12
+    'Kabupaten Garut',
13
+    'Kabupaten Indramayu',
14
+    'Kabupaten Karawang',
15
+    'Kabupaten Kuningan',
16
+    'Kabupaten Majalengka',
17
+    'Kabupaten Pangandaran',
18
+    'Kabupaten Purwakarta',
19
+    'Kabupaten Subang',
20
+    'Kabupaten Sukabumi',
21
+    'Kabupaten Sumedang',
22
+    'Kabupaten Tasikmalaya',
23
+    'Kota Bandung',
24
+    'Kota Banjar',
25
+    'Kota Bekasi',
26
+    'Kota Bogor',
27
+    'Kota Cimahi',
28
+    'Kota Cirebon',
29
+    'Kota Depok',
30
+    'Kota Sukabumi',
31
+    'Kota Tasikmalaya'
32
+];
33
+
34
+export async function seedJawaBaratCities(): Promise<void> {
35
+    const province = await prisma.province.findFirst({
36
+        where: { name: 'Jawa Barat' },
37
+    });
38
+
39
+    if (!province) {
40
+        console.error('❌ Province Jawa Barat not found. Seed it first.');
41
+        return;
42
+    }
43
+
44
+    for (const name of cityNames) {
45
+        await prisma.city.upsert({
46
+            where: {
47
+                name_province_id: {
48
+                    name,
49
+                    province_id: province.id,
50
+                },
51
+            },
52
+            update: {
53
+                updatedAt: now().toDate(),
54
+            },
55
+            create: {
56
+                name,
57
+                province_id: province.id,
58
+                createdAt: now().toDate(),
59
+            },
60
+        });
61
+    }
62
+
63
+    console.log('✅ Jawa Barat City seeded!');
64
+}
65
+
66
+// const prisma = require('../../../src/prisma/PrismaClient.js');
67
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
68
+
69
+// const cityNames = [
70
+//     'Kabupaten Bandung',
71
+//     'Kabupaten Bandung Barat',
72
+//     'Kabupaten Bekasi',
73
+//     'Kabupaten Bogor',
74
+//     'Kabupaten Ciamis',
75
+//     'Kabupaten Cianjur',
76
+//     'Kabupaten Cirebon',
77
+//     'Kabupaten Garut',
78
+//     'Kabupaten Indramayu',
79
+//     'Kabupaten Karawang',
80
+//     'Kabupaten Kuningan',
81
+//     'Kabupaten Majalengka',
82
+//     'Kabupaten Pangandaran',
83
+//     'Kabupaten Purwakarta',
84
+//     'Kabupaten Subang',
85
+//     'Kabupaten Sukabumi',
86
+//     'Kabupaten Sumedang',
87
+//     'Kabupaten Tasikmalaya',
88
+//     'Kota Bandung',
89
+//     'Kota Banjar',
90
+//     'Kota Bekasi',
91
+//     'Kota Bogor',
92
+//     'Kota Cimahi',
93
+//     'Kota Cirebon',
94
+//     'Kota Depok',
95
+//     'Kota Sukabumi',
96
+//     'Kota Tasikmalaya'
97
+
98
+//     // 27
99
+// ];
100
+
101
+// exports.seedJawaBaratCities = async () => {
102
+//     const province = await prisma.province.findFirst({
103
+//         where: { name: 'Jawa Barat' },
104
+//     });
105
+
106
+//     if (!province) {
107
+//         console.error('❌ Province Jawa Barat not found. Seed it first.');
108
+//         return;
109
+//     }
110
+
111
+//     for (const name of cityNames) {
112
+//         await prisma.city.upsert({
113
+//             where: {
114
+//                 name_province_id: {
115
+//                     name,
116
+//                     province_id: province.id,
117
+//                 },
118
+//             },
119
+//             update: {
120
+//                 updatedAt: timeLocal.now().toDate()
121
+//             },
122
+//             create: {
123
+//                 name,
124
+//                 province_id: province.id,
125
+//                 createdAt: timeLocal.now().toDate()
126
+//             },
127
+//         });
128
+//     }
129
+
130
+//     console.log('✅ Jawa Barat City seeded!.');
131
+// };

+ 0 - 74
prisma/seeders/city/JawaTengahCitySeeder.js

@@ -1,74 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Banjarnegara',
6
-    'Kabupaten Banyumas',
7
-    'Kabupaten Batang',
8
-    'Kabupaten Blora',
9
-    'Kabupaten Boyolali',
10
-    'Kabupaten Brebes',
11
-    'Kabupaten Cilacap',
12
-    'Kabupaten Demak',
13
-    'Kabupaten Grobogan',
14
-    'Kabupaten Jepara',
15
-    'Kabupaten Karanganyar',
16
-    'Kabupaten Kebumen',
17
-    'Kabupaten Kendal',
18
-    'Kabupaten Klaten',
19
-    'Kabupaten Kudus',
20
-    'Kabupaten Magelang',
21
-    'Kabupaten Pati',
22
-    'Kabupaten Pekalongan',
23
-    'Kabupaten Pemalang',
24
-    'Kabupaten Purbalingga',
25
-    'Kabupaten Purworejo',
26
-    'Kabupaten Rembang',
27
-    'Kabupaten Semarang',
28
-    'Kabupaten Sragen',
29
-    'Kabupaten Sukoharjo',
30
-    'Kabupaten Tegal',
31
-    'Kabupaten Temanggung',
32
-    'Kabupaten Wonogiri',
33
-    'Kabupaten Wonosobo',
34
-    'Kota Magelang',
35
-    'Kota Pekalongan',
36
-    'Kota Salatiga',
37
-    'Kota Semarang',
38
-    'Kota Surakarta',
39
-    'Kota Tegal'
40
-
41
-    // 35
42
-];
43
-
44
-exports.seedJawaTengahCities = async () => {
45
-    const province = await prisma.province.findFirst({
46
-        where: { name: 'Jawa Tengah' },
47
-    });
48
-
49
-    if (!province) {
50
-        console.error('❌ Province Jawa Tengah not found. Seed it first.');
51
-        return;
52
-    }
53
-
54
-    for (const name of cityNames) {
55
-        await prisma.city.upsert({
56
-            where: {
57
-                name_province_id: {
58
-                    name,
59
-                    province_id: province.id,
60
-                },
61
-            },
62
-            update: {
63
-                updatedAt: timeLocal.now().toDate()
64
-            },
65
-            create: {
66
-                name,
67
-                province_id: province.id,
68
-                createdAt: timeLocal.now().toDate()
69
-            },
70
-        });
71
-    }
72
-
73
-    console.log('✅ Jawa Tengah City seeded!.');
74
-};

+ 147 - 0
prisma/seeders/city/JawaTengahCitySeeder.ts

@@ -0,0 +1,147 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Banjarnegara',
6
+    'Kabupaten Banyumas',
7
+    'Kabupaten Batang',
8
+    'Kabupaten Blora',
9
+    'Kabupaten Boyolali',
10
+    'Kabupaten Brebes',
11
+    'Kabupaten Cilacap',
12
+    'Kabupaten Demak',
13
+    'Kabupaten Grobogan',
14
+    'Kabupaten Jepara',
15
+    'Kabupaten Karanganyar',
16
+    'Kabupaten Kebumen',
17
+    'Kabupaten Kendal',
18
+    'Kabupaten Klaten',
19
+    'Kabupaten Kudus',
20
+    'Kabupaten Magelang',
21
+    'Kabupaten Pati',
22
+    'Kabupaten Pekalongan',
23
+    'Kabupaten Pemalang',
24
+    'Kabupaten Purbalingga',
25
+    'Kabupaten Purworejo',
26
+    'Kabupaten Rembang',
27
+    'Kabupaten Semarang',
28
+    'Kabupaten Sragen',
29
+    'Kabupaten Sukoharjo',
30
+    'Kabupaten Tegal',
31
+    'Kabupaten Temanggung',
32
+    'Kabupaten Wonogiri',
33
+    'Kabupaten Wonosobo',
34
+    'Kota Magelang',
35
+    'Kota Pekalongan',
36
+    'Kota Salatiga',
37
+    'Kota Semarang',
38
+    'Kota Surakarta',
39
+    'Kota Tegal'
40
+];
41
+
42
+export async function seedJawaTengahCities(): Promise<void> {
43
+    const province = await prisma.province.findFirst({
44
+        where: { name: 'Jawa Tengah' },
45
+    });
46
+
47
+    if (!province) {
48
+        console.error('❌ Province Jawa Tengah not found. Seed it first.');
49
+        return;
50
+    }
51
+
52
+    for (const name of cityNames) {
53
+        await prisma.city.upsert({
54
+            where: {
55
+                name_province_id: {
56
+                    name,
57
+                    province_id: province.id,
58
+                },
59
+            },
60
+            update: {
61
+                updatedAt: now().toDate(),
62
+            },
63
+            create: {
64
+                name,
65
+                province_id: province.id,
66
+                createdAt: now().toDate(),
67
+            },
68
+        });
69
+    }
70
+
71
+    console.log('✅ Jawa Tengah City seeded!');
72
+}
73
+
74
+// const prisma = require('../../../src/prisma/PrismaClient.js');
75
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
76
+
77
+// const cityNames = [
78
+//     'Kabupaten Banjarnegara',
79
+//     'Kabupaten Banyumas',
80
+//     'Kabupaten Batang',
81
+//     'Kabupaten Blora',
82
+//     'Kabupaten Boyolali',
83
+//     'Kabupaten Brebes',
84
+//     'Kabupaten Cilacap',
85
+//     'Kabupaten Demak',
86
+//     'Kabupaten Grobogan',
87
+//     'Kabupaten Jepara',
88
+//     'Kabupaten Karanganyar',
89
+//     'Kabupaten Kebumen',
90
+//     'Kabupaten Kendal',
91
+//     'Kabupaten Klaten',
92
+//     'Kabupaten Kudus',
93
+//     'Kabupaten Magelang',
94
+//     'Kabupaten Pati',
95
+//     'Kabupaten Pekalongan',
96
+//     'Kabupaten Pemalang',
97
+//     'Kabupaten Purbalingga',
98
+//     'Kabupaten Purworejo',
99
+//     'Kabupaten Rembang',
100
+//     'Kabupaten Semarang',
101
+//     'Kabupaten Sragen',
102
+//     'Kabupaten Sukoharjo',
103
+//     'Kabupaten Tegal',
104
+//     'Kabupaten Temanggung',
105
+//     'Kabupaten Wonogiri',
106
+//     'Kabupaten Wonosobo',
107
+//     'Kota Magelang',
108
+//     'Kota Pekalongan',
109
+//     'Kota Salatiga',
110
+//     'Kota Semarang',
111
+//     'Kota Surakarta',
112
+//     'Kota Tegal'
113
+
114
+//     // 35
115
+// ];
116
+
117
+// exports.seedJawaTengahCities = async () => {
118
+//     const province = await prisma.province.findFirst({
119
+//         where: { name: 'Jawa Tengah' },
120
+//     });
121
+
122
+//     if (!province) {
123
+//         console.error('❌ Province Jawa Tengah not found. Seed it first.');
124
+//         return;
125
+//     }
126
+
127
+//     for (const name of cityNames) {
128
+//         await prisma.city.upsert({
129
+//             where: {
130
+//                 name_province_id: {
131
+//                     name,
132
+//                     province_id: province.id,
133
+//                 },
134
+//             },
135
+//             update: {
136
+//                 updatedAt: timeLocal.now().toDate()
137
+//             },
138
+//             create: {
139
+//                 name,
140
+//                 province_id: province.id,
141
+//                 createdAt: timeLocal.now().toDate()
142
+//             },
143
+//         });
144
+//     }
145
+
146
+//     console.log('✅ Jawa Tengah City seeded!.');
147
+// };

+ 0 - 77
prisma/seeders/city/JawaTimurCitySeeder.js

@@ -1,77 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bangkalan',
6
-    'Kabupaten Banyuwangi',
7
-    'Kabupaten Blitar',
8
-    'Kabupaten Bojonegoro',
9
-    'Kabupaten Bondowoso',
10
-    'Kabupaten Gresik',
11
-    'Kabupaten Jember',
12
-    'Kabupaten Jombang',
13
-    'Kabupaten Kediri',
14
-    'Kabupaten Lamongan',
15
-    'Kabupaten Lumajang',
16
-    'Kabupaten Madiun',
17
-    'Kabupaten Magetan',
18
-    'Kabupaten Malang',
19
-    'Kabupaten Mojokerto',
20
-    'Kabupaten Nganjuk',
21
-    'Kabupaten Ngawi',
22
-    'Kabupaten Pacitan',
23
-    'Kabupaten Pamekasan',
24
-    'Kabupaten Pasuruan',
25
-    'Kabupaten Ponorogo',
26
-    'Kabupaten Probolinggo',
27
-    'Kabupaten Sampang',
28
-    'Kabupaten Sidoarjo',
29
-    'Kabupaten Situbondo',
30
-    'Kabupaten Sumenep',
31
-    'Kabupaten Trenggalek',
32
-    'Kabupaten Tuban',
33
-    'Kabupaten Tulungagung',
34
-    'Kota Batu',
35
-    'Kota Blitar',
36
-    'Kota Kediri',
37
-    'Kota Madiun',
38
-    'Kota Malang',
39
-    'Kota Mojokerto',
40
-    'Kota Pasuruan',
41
-    'Kota Probolinggo',
42
-    'Kota Surabaya'
43
-
44
-    // 38
45
-];
46
-
47
-exports.seedJawaTimurCities = async () => {
48
-    const province = await prisma.province.findFirst({
49
-        where: { name: 'Jawa Timur' },
50
-    });
51
-
52
-    if (!province) {
53
-        console.error('❌ Province Jawa Timur not found. Seed it first.');
54
-        return;
55
-    }
56
-
57
-    for (const name of cityNames) {
58
-        await prisma.city.upsert({
59
-            where: {
60
-                name_province_id: {
61
-                    name,
62
-                    province_id: province.id,
63
-                },
64
-            },
65
-            update: {
66
-                updatedAt: timeLocal.now().toDate()
67
-            },
68
-            create: {
69
-                name,
70
-                province_id: province.id,
71
-                createdAt: timeLocal.now().toDate()
72
-            },
73
-        });
74
-    }
75
-
76
-    console.log('✅ Jawa Timur City seeded!.');
77
-};

+ 153 - 0
prisma/seeders/city/JawaTimurCitySeeder.ts

@@ -0,0 +1,153 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bangkalan',
6
+    'Kabupaten Banyuwangi',
7
+    'Kabupaten Blitar',
8
+    'Kabupaten Bojonegoro',
9
+    'Kabupaten Bondowoso',
10
+    'Kabupaten Gresik',
11
+    'Kabupaten Jember',
12
+    'Kabupaten Jombang',
13
+    'Kabupaten Kediri',
14
+    'Kabupaten Lamongan',
15
+    'Kabupaten Lumajang',
16
+    'Kabupaten Madiun',
17
+    'Kabupaten Magetan',
18
+    'Kabupaten Malang',
19
+    'Kabupaten Mojokerto',
20
+    'Kabupaten Nganjuk',
21
+    'Kabupaten Ngawi',
22
+    'Kabupaten Pacitan',
23
+    'Kabupaten Pamekasan',
24
+    'Kabupaten Pasuruan',
25
+    'Kabupaten Ponorogo',
26
+    'Kabupaten Probolinggo',
27
+    'Kabupaten Sampang',
28
+    'Kabupaten Sidoarjo',
29
+    'Kabupaten Situbondo',
30
+    'Kabupaten Sumenep',
31
+    'Kabupaten Trenggalek',
32
+    'Kabupaten Tuban',
33
+    'Kabupaten Tulungagung',
34
+    'Kota Batu',
35
+    'Kota Blitar',
36
+    'Kota Kediri',
37
+    'Kota Madiun',
38
+    'Kota Malang',
39
+    'Kota Mojokerto',
40
+    'Kota Pasuruan',
41
+    'Kota Probolinggo',
42
+    'Kota Surabaya'
43
+];
44
+
45
+export async function seedJawaTimurCities(): Promise<void> {
46
+    const province = await prisma.province.findFirst({
47
+        where: { name: 'Jawa Timur' },
48
+    });
49
+
50
+    if (!province) {
51
+        console.error('❌ Province Jawa Timur not found. Seed it first.');
52
+        return;
53
+    }
54
+
55
+    for (const name of cityNames) {
56
+        await prisma.city.upsert({
57
+            where: {
58
+                name_province_id: {
59
+                    name,
60
+                    province_id: province.id,
61
+                },
62
+            },
63
+            update: {
64
+                updatedAt: now().toDate(),
65
+            },
66
+            create: {
67
+                name,
68
+                province_id: province.id,
69
+                createdAt: now().toDate(),
70
+            },
71
+        });
72
+    }
73
+
74
+    console.log('✅ Jawa Timur City seeded!');
75
+}
76
+
77
+// const prisma = require('../../../src/prisma/PrismaClient.js');
78
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
79
+
80
+// const cityNames = [
81
+//     'Kabupaten Bangkalan',
82
+//     'Kabupaten Banyuwangi',
83
+//     'Kabupaten Blitar',
84
+//     'Kabupaten Bojonegoro',
85
+//     'Kabupaten Bondowoso',
86
+//     'Kabupaten Gresik',
87
+//     'Kabupaten Jember',
88
+//     'Kabupaten Jombang',
89
+//     'Kabupaten Kediri',
90
+//     'Kabupaten Lamongan',
91
+//     'Kabupaten Lumajang',
92
+//     'Kabupaten Madiun',
93
+//     'Kabupaten Magetan',
94
+//     'Kabupaten Malang',
95
+//     'Kabupaten Mojokerto',
96
+//     'Kabupaten Nganjuk',
97
+//     'Kabupaten Ngawi',
98
+//     'Kabupaten Pacitan',
99
+//     'Kabupaten Pamekasan',
100
+//     'Kabupaten Pasuruan',
101
+//     'Kabupaten Ponorogo',
102
+//     'Kabupaten Probolinggo',
103
+//     'Kabupaten Sampang',
104
+//     'Kabupaten Sidoarjo',
105
+//     'Kabupaten Situbondo',
106
+//     'Kabupaten Sumenep',
107
+//     'Kabupaten Trenggalek',
108
+//     'Kabupaten Tuban',
109
+//     'Kabupaten Tulungagung',
110
+//     'Kota Batu',
111
+//     'Kota Blitar',
112
+//     'Kota Kediri',
113
+//     'Kota Madiun',
114
+//     'Kota Malang',
115
+//     'Kota Mojokerto',
116
+//     'Kota Pasuruan',
117
+//     'Kota Probolinggo',
118
+//     'Kota Surabaya'
119
+
120
+//     // 38
121
+// ];
122
+
123
+// exports.seedJawaTimurCities = async () => {
124
+//     const province = await prisma.province.findFirst({
125
+//         where: { name: 'Jawa Timur' },
126
+//     });
127
+
128
+//     if (!province) {
129
+//         console.error('❌ Province Jawa Timur not found. Seed it first.');
130
+//         return;
131
+//     }
132
+
133
+//     for (const name of cityNames) {
134
+//         await prisma.city.upsert({
135
+//             where: {
136
+//                 name_province_id: {
137
+//                     name,
138
+//                     province_id: province.id,
139
+//                 },
140
+//             },
141
+//             update: {
142
+//                 updatedAt: timeLocal.now().toDate()
143
+//             },
144
+//             create: {
145
+//                 name,
146
+//                 province_id: province.id,
147
+//                 createdAt: timeLocal.now().toDate()
148
+//             },
149
+//         });
150
+//     }
151
+
152
+//     console.log('✅ Jawa Timur City seeded!.');
153
+// };

+ 0 - 53
prisma/seeders/city/KalimantanBaratCitySeeder.js

@@ -1,53 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bengkayang',
6
-    'Kabupaten Kapuas Hulu',
7
-    'Kabupaten Kayong Utara',
8
-    'Kabupaten Ketapang',
9
-    'Kabupaten Kubu Raya',
10
-    'Kabupaten Landak',
11
-    'Kabupaten Melawi',
12
-    'Kabupaten Mempawah',
13
-    'Kabupaten Sambas',
14
-    'Kabupaten Sanggau',
15
-    'Kabupaten Sekadau',
16
-    'Kabupaten Sintang',
17
-    'Kota Pontianak',
18
-    'Kota Singkawang'
19
-
20
-    // 14
21
-];
22
-
23
-exports.seedKalimantanBaratCities = async () => {
24
-    const province = await prisma.province.findFirst({
25
-        where: { name: 'Kalimantan Barat' },
26
-    });
27
-
28
-    if (!province) {
29
-        console.error('❌ Province Kalimantan Barat not found. Seed it first.');
30
-        return;
31
-    }
32
-
33
-    for (const name of cityNames) {
34
-        await prisma.city.upsert({
35
-            where: {
36
-                name_province_id: {
37
-                    name,
38
-                    province_id: province.id,
39
-                },
40
-            },
41
-            update: {
42
-                updatedAt: timeLocal.now().toDate()
43
-            },
44
-            create: {
45
-                name,
46
-                province_id: province.id,
47
-                createdAt: timeLocal.now().toDate()
48
-            },
49
-        });
50
-    }
51
-
52
-    console.log('✅ Kalimantan Barat City seeded!.');
53
-};

+ 105 - 0
prisma/seeders/city/KalimantanBaratCitySeeder.ts

@@ -0,0 +1,105 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bengkayang',
6
+    'Kabupaten Kapuas Hulu',
7
+    'Kabupaten Kayong Utara',
8
+    'Kabupaten Ketapang',
9
+    'Kabupaten Kubu Raya',
10
+    'Kabupaten Landak',
11
+    'Kabupaten Melawi',
12
+    'Kabupaten Mempawah',
13
+    'Kabupaten Sambas',
14
+    'Kabupaten Sanggau',
15
+    'Kabupaten Sekadau',
16
+    'Kabupaten Sintang',
17
+    'Kota Pontianak',
18
+    'Kota Singkawang'
19
+];
20
+
21
+export async function seedKalimantanBaratCities(): Promise<void> {
22
+    const province = await prisma.province.findFirst({
23
+        where: { name: 'Kalimantan Barat' },
24
+    });
25
+
26
+    if (!province) {
27
+        console.error('❌ Province Kalimantan Barat not found. Seed it first.');
28
+        return;
29
+    }
30
+
31
+    for (const name of cityNames) {
32
+        await prisma.city.upsert({
33
+            where: {
34
+                name_province_id: {
35
+                    name,
36
+                    province_id: province.id,
37
+                },
38
+            },
39
+            update: {
40
+                updatedAt: now().toDate(),
41
+            },
42
+            create: {
43
+                name,
44
+                province_id: province.id,
45
+                createdAt: now().toDate(),
46
+            },
47
+        });
48
+    }
49
+
50
+    console.log('✅ Kalimantan Barat City seeded!');
51
+}
52
+
53
+// const prisma = require('../../../src/prisma/PrismaClient.js');
54
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
55
+
56
+// const cityNames = [
57
+//     'Kabupaten Bengkayang',
58
+//     'Kabupaten Kapuas Hulu',
59
+//     'Kabupaten Kayong Utara',
60
+//     'Kabupaten Ketapang',
61
+//     'Kabupaten Kubu Raya',
62
+//     'Kabupaten Landak',
63
+//     'Kabupaten Melawi',
64
+//     'Kabupaten Mempawah',
65
+//     'Kabupaten Sambas',
66
+//     'Kabupaten Sanggau',
67
+//     'Kabupaten Sekadau',
68
+//     'Kabupaten Sintang',
69
+//     'Kota Pontianak',
70
+//     'Kota Singkawang'
71
+
72
+//     // 14
73
+// ];
74
+
75
+// exports.seedKalimantanBaratCities = async () => {
76
+//     const province = await prisma.province.findFirst({
77
+//         where: { name: 'Kalimantan Barat' },
78
+//     });
79
+
80
+//     if (!province) {
81
+//         console.error('❌ Province Kalimantan Barat not found. Seed it first.');
82
+//         return;
83
+//     }
84
+
85
+//     for (const name of cityNames) {
86
+//         await prisma.city.upsert({
87
+//             where: {
88
+//                 name_province_id: {
89
+//                     name,
90
+//                     province_id: province.id,
91
+//                 },
92
+//             },
93
+//             update: {
94
+//                 updatedAt: timeLocal.now().toDate()
95
+//             },
96
+//             create: {
97
+//                 name,
98
+//                 province_id: province.id,
99
+//                 createdAt: timeLocal.now().toDate()
100
+//             },
101
+//         });
102
+//     }
103
+
104
+//     console.log('✅ Kalimantan Barat City seeded!.');
105
+// };

+ 0 - 52
prisma/seeders/city/KalimantanSelatanCitySeeder.js

@@ -1,52 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Balangan',
6
-    'Kabupaten Banjar',
7
-    'Kabupaten Barito Kuala',
8
-    'Kabupaten Hulu Sungai Selatan',
9
-    'Kabupaten Hulu Sungai Tengah',
10
-    'Kabupaten Hulu Sungai Utara',
11
-    'Kabupaten Kotabaru',
12
-    'Kabupaten Tabalong',
13
-    'Kabupaten Tanah Bumbu',
14
-    'Kabupaten Tanah Laut',
15
-    'Kabupaten Tapin',
16
-    'Kota Banjarbaru',
17
-    'Kota Banjarmasin'
18
-
19
-    // 13
20
-];
21
-
22
-exports.seedKalimantanSelatanCities = async () => {
23
-    const province = await prisma.province.findFirst({
24
-        where: { name: 'Kalimantan Selatan' },
25
-    });
26
-
27
-    if (!province) {
28
-        console.error('❌ Province Kalimantan Selatan not found. Seed it first.');
29
-        return;
30
-    }
31
-
32
-    for (const name of cityNames) {
33
-        await prisma.city.upsert({
34
-            where: {
35
-                name_province_id: {
36
-                    name,
37
-                    province_id: province.id,
38
-                },
39
-            },
40
-            update: {
41
-                updatedAt: timeLocal.now().toDate()
42
-            },
43
-            create: {
44
-                name,
45
-                province_id: province.id,
46
-                createdAt: timeLocal.now().toDate()
47
-            },
48
-        });
49
-    }
50
-
51
-    console.log('✅ Kalimantan Selatan City seeded!.');
52
-};

+ 103 - 0
prisma/seeders/city/KalimantanSelatanCitySeeder.ts

@@ -0,0 +1,103 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Balangan',
6
+    'Kabupaten Banjar',
7
+    'Kabupaten Barito Kuala',
8
+    'Kabupaten Hulu Sungai Selatan',
9
+    'Kabupaten Hulu Sungai Tengah',
10
+    'Kabupaten Hulu Sungai Utara',
11
+    'Kabupaten Kotabaru',
12
+    'Kabupaten Tabalong',
13
+    'Kabupaten Tanah Bumbu',
14
+    'Kabupaten Tanah Laut',
15
+    'Kabupaten Tapin',
16
+    'Kota Banjarbaru',
17
+    'Kota Banjarmasin'
18
+];
19
+
20
+export async function seedKalimantanSelatanCities(): Promise<void> {
21
+    const province = await prisma.province.findFirst({
22
+        where: { name: 'Kalimantan Selatan' },
23
+    });
24
+
25
+    if (!province) {
26
+        console.error('❌ Province Kalimantan Selatan not found. Seed it first.');
27
+        return;
28
+    }
29
+
30
+    for (const name of cityNames) {
31
+        await prisma.city.upsert({
32
+            where: {
33
+                name_province_id: {
34
+                    name,
35
+                    province_id: province.id,
36
+                },
37
+            },
38
+            update: {
39
+                updatedAt: now().toDate(),
40
+            },
41
+            create: {
42
+                name,
43
+                province_id: province.id,
44
+                createdAt: now().toDate(),
45
+            },
46
+        });
47
+    }
48
+
49
+    console.log('✅ Kalimantan Selatan City seeded!');
50
+}
51
+
52
+// const prisma = require('../../../src/prisma/PrismaClient.js');
53
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
54
+
55
+// const cityNames = [
56
+//     'Kabupaten Balangan',
57
+//     'Kabupaten Banjar',
58
+//     'Kabupaten Barito Kuala',
59
+//     'Kabupaten Hulu Sungai Selatan',
60
+//     'Kabupaten Hulu Sungai Tengah',
61
+//     'Kabupaten Hulu Sungai Utara',
62
+//     'Kabupaten Kotabaru',
63
+//     'Kabupaten Tabalong',
64
+//     'Kabupaten Tanah Bumbu',
65
+//     'Kabupaten Tanah Laut',
66
+//     'Kabupaten Tapin',
67
+//     'Kota Banjarbaru',
68
+//     'Kota Banjarmasin'
69
+
70
+//     // 13
71
+// ];
72
+
73
+// exports.seedKalimantanSelatanCities = async () => {
74
+//     const province = await prisma.province.findFirst({
75
+//         where: { name: 'Kalimantan Selatan' },
76
+//     });
77
+
78
+//     if (!province) {
79
+//         console.error('❌ Province Kalimantan Selatan not found. Seed it first.');
80
+//         return;
81
+//     }
82
+
83
+//     for (const name of cityNames) {
84
+//         await prisma.city.upsert({
85
+//             where: {
86
+//                 name_province_id: {
87
+//                     name,
88
+//                     province_id: province.id,
89
+//                 },
90
+//             },
91
+//             update: {
92
+//                 updatedAt: timeLocal.now().toDate()
93
+//             },
94
+//             create: {
95
+//                 name,
96
+//                 province_id: province.id,
97
+//                 createdAt: timeLocal.now().toDate()
98
+//             },
99
+//         });
100
+//     }
101
+
102
+//     console.log('✅ Kalimantan Selatan City seeded!.');
103
+// };

+ 0 - 53
prisma/seeders/city/KalimantanTengahCitySeeder.js

@@ -1,53 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Barito Selatan',
6
-    'Kabupaten Barito Timur',
7
-    'Kabupaten Barito Utara',
8
-    'Kabupaten Gunung Mas',
9
-    'Kabupaten Kapuas',
10
-    'Kabupaten Katingan',
11
-    'Kabupaten Kotawaringin Barat',
12
-    'Kabupaten Kotawaringin Timur',
13
-    'Kabupaten Lamandau',
14
-    'Kabupaten Murung Raya',
15
-    'Kabupaten Pulang Pisau',
16
-    'Kabupaten Sukamara',
17
-    'Kabupaten Seruyan',
18
-    'Kota Palangka Raya'
19
-
20
-    // 14
21
-];
22
-
23
-exports.seedKalimantanTengahCities = async () => {
24
-    const province = await prisma.province.findFirst({
25
-        where: { name: 'Kalimantan Tengah' },
26
-    });
27
-
28
-    if (!province) {
29
-        console.error('❌ Province Kalimantan Tengah not found. Seed it first.');
30
-        return;
31
-    }
32
-
33
-    for (const name of cityNames) {
34
-        await prisma.city.upsert({
35
-            where: {
36
-                name_province_id: {
37
-                    name,
38
-                    province_id: province.id,
39
-                },
40
-            },
41
-            update: {
42
-                updatedAt: timeLocal.now().toDate()
43
-            },
44
-            create: {
45
-                name,
46
-                province_id: province.id,
47
-                createdAt: timeLocal.now().toDate()
48
-            },
49
-        });
50
-    }
51
-
52
-    console.log('✅ Kalimantan Tengah City seeded!.');
53
-};

+ 105 - 0
prisma/seeders/city/KalimantanTengahCitySeeder.ts

@@ -0,0 +1,105 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Barito Selatan',
6
+    'Kabupaten Barito Timur',
7
+    'Kabupaten Barito Utara',
8
+    'Kabupaten Gunung Mas',
9
+    'Kabupaten Kapuas',
10
+    'Kabupaten Katingan',
11
+    'Kabupaten Kotawaringin Barat',
12
+    'Kabupaten Kotawaringin Timur',
13
+    'Kabupaten Lamandau',
14
+    'Kabupaten Murung Raya',
15
+    'Kabupaten Pulang Pisau',
16
+    'Kabupaten Sukamara',
17
+    'Kabupaten Seruyan',
18
+    'Kota Palangka Raya'
19
+];
20
+
21
+export async function seedKalimantanTengahCities(): Promise<void> {
22
+    const province = await prisma.province.findFirst({
23
+        where: { name: 'Kalimantan Tengah' },
24
+    });
25
+
26
+    if (!province) {
27
+        console.error('❌ Province Kalimantan Tengah not found. Seed it first.');
28
+        return;
29
+    }
30
+
31
+    for (const name of cityNames) {
32
+        await prisma.city.upsert({
33
+            where: {
34
+                name_province_id: {
35
+                    name,
36
+                    province_id: province.id,
37
+                },
38
+            },
39
+            update: {
40
+                updatedAt: now().toDate(),
41
+            },
42
+            create: {
43
+                name,
44
+                province_id: province.id,
45
+                createdAt: now().toDate(),
46
+            },
47
+        });
48
+    }
49
+
50
+    console.log('✅ Kalimantan Tengah City seeded!');
51
+}
52
+
53
+// const prisma = require('../../../src/prisma/PrismaClient.js');
54
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
55
+
56
+// const cityNames = [
57
+//     'Kabupaten Barito Selatan',
58
+//     'Kabupaten Barito Timur',
59
+//     'Kabupaten Barito Utara',
60
+//     'Kabupaten Gunung Mas',
61
+//     'Kabupaten Kapuas',
62
+//     'Kabupaten Katingan',
63
+//     'Kabupaten Kotawaringin Barat',
64
+//     'Kabupaten Kotawaringin Timur',
65
+//     'Kabupaten Lamandau',
66
+//     'Kabupaten Murung Raya',
67
+//     'Kabupaten Pulang Pisau',
68
+//     'Kabupaten Sukamara',
69
+//     'Kabupaten Seruyan',
70
+//     'Kota Palangka Raya'
71
+
72
+//     // 14
73
+// ];
74
+
75
+// exports.seedKalimantanTengahCities = async () => {
76
+//     const province = await prisma.province.findFirst({
77
+//         where: { name: 'Kalimantan Tengah' },
78
+//     });
79
+
80
+//     if (!province) {
81
+//         console.error('❌ Province Kalimantan Tengah not found. Seed it first.');
82
+//         return;
83
+//     }
84
+
85
+//     for (const name of cityNames) {
86
+//         await prisma.city.upsert({
87
+//             where: {
88
+//                 name_province_id: {
89
+//                     name,
90
+//                     province_id: province.id,
91
+//                 },
92
+//             },
93
+//             update: {
94
+//                 updatedAt: timeLocal.now().toDate()
95
+//             },
96
+//             create: {
97
+//                 name,
98
+//                 province_id: province.id,
99
+//                 createdAt: timeLocal.now().toDate()
100
+//             },
101
+//         });
102
+//     }
103
+
104
+//     console.log('✅ Kalimantan Tengah City seeded!.');
105
+// };

+ 0 - 49
prisma/seeders/city/KalimantanTimurCitySeeder.js

@@ -1,49 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Berau',
6
-    'Kabupaten Kutai Barat',
7
-    'Kabupaten Kutai Kartanegara',
8
-    'Kabupaten Kutai Timur',
9
-    'Kabupaten Mahakam Ulu',
10
-    'Kabupaten Paser',
11
-    'Kabupaten Penajam Paser Utara',
12
-    'Kota Balikpapan',
13
-    'Kota Bontang',
14
-    'Kota Samarinda'
15
-
16
-    // 10
17
-];
18
-
19
-exports.seedKalimantanTimurCities = async () => {
20
-    const province = await prisma.province.findFirst({
21
-        where: { name: 'Kalimantan Timur' },
22
-    });
23
-
24
-    if (!province) {
25
-        console.error('❌ Province Kalimantan Timur not found. Seed it first.');
26
-        return;
27
-    }
28
-
29
-    for (const name of cityNames) {
30
-        await prisma.city.upsert({
31
-            where: {
32
-                name_province_id: {
33
-                    name,
34
-                    province_id: province.id,
35
-                },
36
-            },
37
-            update: {
38
-                updatedAt: timeLocal.now().toDate()
39
-            },
40
-            create: {
41
-                name,
42
-                province_id: province.id,
43
-                createdAt: timeLocal.now().toDate()
44
-            },
45
-        });
46
-    }
47
-
48
-    console.log('✅ Kalimantan Timur City seeded!.');
49
-};

+ 98 - 0
prisma/seeders/city/KalimantanTimurCitySeeder.ts

@@ -0,0 +1,98 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Berau',
6
+    'Kabupaten Kutai Barat',
7
+    'Kabupaten Kutai Kartanegara',
8
+    'Kabupaten Kutai Timur',
9
+    'Kabupaten Mahakam Ulu',
10
+    'Kabupaten Paser',
11
+    'Kabupaten Penajam Paser Utara',
12
+    'Kota Balikpapan',
13
+    'Kota Bontang',
14
+    'Kota Samarinda'
15
+];
16
+
17
+export async function seedKalimantanTimurCities(): Promise<void> {
18
+    const province = await prisma.province.findFirst({
19
+        where: { name: 'Kalimantan Timur' },
20
+    });
21
+
22
+    if (!province) {
23
+        console.error('❌ Province Kalimantan Timur not found. Seed it first.');
24
+        return;
25
+    }
26
+
27
+    for (const name of cityNames) {
28
+        await prisma.city.upsert({
29
+            where: {
30
+                name_province_id: {
31
+                    name,
32
+                    province_id: province.id,
33
+                },
34
+            },
35
+            update: {
36
+                updatedAt: now().toDate(),
37
+            },
38
+            create: {
39
+                name,
40
+                province_id: province.id,
41
+                createdAt: now().toDate(),
42
+            },
43
+        });
44
+    }
45
+
46
+    console.log('✅ Kalimantan Timur City seeded!');
47
+}
48
+
49
+
50
+// const prisma = require('../../../src/prisma/PrismaClient.js');
51
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
52
+
53
+// const cityNames = [
54
+//     'Kabupaten Berau',
55
+//     'Kabupaten Kutai Barat',
56
+//     'Kabupaten Kutai Kartanegara',
57
+//     'Kabupaten Kutai Timur',
58
+//     'Kabupaten Mahakam Ulu',
59
+//     'Kabupaten Paser',
60
+//     'Kabupaten Penajam Paser Utara',
61
+//     'Kota Balikpapan',
62
+//     'Kota Bontang',
63
+//     'Kota Samarinda'
64
+
65
+//     // 10
66
+// ];
67
+
68
+// exports.seedKalimantanTimurCities = async () => {
69
+//     const province = await prisma.province.findFirst({
70
+//         where: { name: 'Kalimantan Timur' },
71
+//     });
72
+
73
+//     if (!province) {
74
+//         console.error('❌ Province Kalimantan Timur not found. Seed it first.');
75
+//         return;
76
+//     }
77
+
78
+//     for (const name of cityNames) {
79
+//         await prisma.city.upsert({
80
+//             where: {
81
+//                 name_province_id: {
82
+//                     name,
83
+//                     province_id: province.id,
84
+//                 },
85
+//             },
86
+//             update: {
87
+//                 updatedAt: timeLocal.now().toDate()
88
+//             },
89
+//             create: {
90
+//                 name,
91
+//                 province_id: province.id,
92
+//                 createdAt: timeLocal.now().toDate()
93
+//             },
94
+//         });
95
+//     }
96
+
97
+//     console.log('✅ Kalimantan Timur City seeded!.');
98
+// };

+ 0 - 44
prisma/seeders/city/KalimantanUtaraCitySeeder.js

@@ -1,44 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bulungan',
6
-    'Kabupaten Malinau',
7
-    'Kabupaten Nunukan',
8
-    'Kabupaten Tana Tidung',
9
-    'Kota Tarakan'
10
-
11
-    // 5
12
-];
13
-
14
-exports.seedKalimantanUtaraCities = async () => {
15
-    const province = await prisma.province.findFirst({
16
-        where: { name: 'Kalimantan Utara' },
17
-    });
18
-
19
-    if (!province) {
20
-        console.error('❌ Province Kalimantan Utara not found. Seed it first.');
21
-        return;
22
-    }
23
-
24
-    for (const name of cityNames) {
25
-        await prisma.city.upsert({
26
-            where: {
27
-                name_province_id: {
28
-                    name,
29
-                    province_id: province.id,
30
-                },
31
-            },
32
-            update: {
33
-                updatedAt: timeLocal.now().toDate()
34
-            },
35
-            create: {
36
-                name,
37
-                province_id: province.id,
38
-                createdAt: timeLocal.now().toDate()
39
-            },
40
-        });
41
-    }
42
-
43
-    console.log('✅ Kalimantan Utara City seeded!.');
44
-};

+ 87 - 0
prisma/seeders/city/KalimantanUtaraCitySeeder.ts

@@ -0,0 +1,87 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bulungan',
6
+    'Kabupaten Malinau',
7
+    'Kabupaten Nunukan',
8
+    'Kabupaten Tana Tidung',
9
+    'Kota Tarakan'
10
+];
11
+
12
+export async function seedKalimantanUtaraCities(): Promise<void> {
13
+    const province = await prisma.province.findFirst({
14
+        where: { name: 'Kalimantan Utara' },
15
+    });
16
+
17
+    if (!province) {
18
+        console.error('❌ Province Kalimantan Utara not found. Seed it first.');
19
+        return;
20
+    }
21
+
22
+    for (const name of cityNames) {
23
+        await prisma.city.upsert({
24
+            where: {
25
+                name_province_id: {
26
+                    name,
27
+                    province_id: province.id,
28
+                },
29
+            },
30
+            update: {
31
+                updatedAt: now().toDate(),
32
+            },
33
+            create: {
34
+                name,
35
+                province_id: province.id,
36
+                createdAt: now().toDate(),
37
+            },
38
+        });
39
+    }
40
+
41
+    console.log('✅ Kalimantan Utara City seeded!');
42
+}
43
+
44
+// const prisma = require('../../../src/prisma/PrismaClient.js');
45
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
46
+
47
+// const cityNames = [
48
+//     'Kabupaten Bulungan',
49
+//     'Kabupaten Malinau',
50
+//     'Kabupaten Nunukan',
51
+//     'Kabupaten Tana Tidung',
52
+//     'Kota Tarakan'
53
+
54
+//     // 5
55
+// ];
56
+
57
+// exports.seedKalimantanUtaraCities = async () => {
58
+//     const province = await prisma.province.findFirst({
59
+//         where: { name: 'Kalimantan Utara' },
60
+//     });
61
+
62
+//     if (!province) {
63
+//         console.error('❌ Province Kalimantan Utara not found. Seed it first.');
64
+//         return;
65
+//     }
66
+
67
+//     for (const name of cityNames) {
68
+//         await prisma.city.upsert({
69
+//             where: {
70
+//                 name_province_id: {
71
+//                     name,
72
+//                     province_id: province.id,
73
+//                 },
74
+//             },
75
+//             update: {
76
+//                 updatedAt: timeLocal.now().toDate()
77
+//             },
78
+//             create: {
79
+//                 name,
80
+//                 province_id: province.id,
81
+//                 createdAt: timeLocal.now().toDate()
82
+//             },
83
+//         });
84
+//     }
85
+
86
+//     console.log('✅ Kalimantan Utara City seeded!.');
87
+// };

+ 0 - 46
prisma/seeders/city/KepulauanBangkaBelitungCitySeeder.js

@@ -1,46 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bangka',
6
-    'Kabupaten Bangka Barat',
7
-    'Kabupaten Bangka Selatan',
8
-    'Kabupaten Bangka Tengah',
9
-    'Kabupaten Belitung',
10
-    'Kabupaten Belitung Timur',
11
-    'Kota Pangkal Pinang'
12
-
13
-    // 7
14
-];
15
-
16
-exports.seedKepulauanBangkaBelitungCities = async () => {
17
-    const province = await prisma.province.findFirst({
18
-        where: { name: 'Kepulauan Bangka Belitung' },
19
-    });
20
-
21
-    if (!province) {
22
-        console.error('❌ Province Kepulauan Bangka Belitung not found. Seed it first.');
23
-        return;
24
-    }
25
-
26
-    for (const name of cityNames) {
27
-        await prisma.city.upsert({
28
-            where: {
29
-                name_province_id: {
30
-                    name,
31
-                    province_id: province.id,
32
-                },
33
-            },
34
-            update: {
35
-                updatedAt: timeLocal.now().toDate()
36
-            },
37
-            create: {
38
-                name,
39
-                province_id: province.id,
40
-                createdAt: timeLocal.now().toDate()
41
-            },
42
-        });
43
-    }
44
-
45
-    console.log('✅ Kepulauan Bangka Belitung City seeded!.');
46
-};

+ 91 - 0
prisma/seeders/city/KepulauanBangkaBelitungCitySeeder.ts

@@ -0,0 +1,91 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bangka',
6
+    'Kabupaten Bangka Barat',
7
+    'Kabupaten Bangka Selatan',
8
+    'Kabupaten Bangka Tengah',
9
+    'Kabupaten Belitung',
10
+    'Kabupaten Belitung Timur',
11
+    'Kota Pangkal Pinang'
12
+];
13
+
14
+export async function seedKepulauanBangkaBelitungCities(): Promise<void> {
15
+    const province = await prisma.province.findFirst({
16
+        where: { name: 'Kepulauan Bangka Belitung' },
17
+    });
18
+
19
+    if (!province) {
20
+        console.error('❌ Province Kepulauan Bangka Belitung not found. Seed it first.');
21
+        return;
22
+    }
23
+
24
+    for (const name of cityNames) {
25
+        await prisma.city.upsert({
26
+            where: {
27
+                name_province_id: {
28
+                    name,
29
+                    province_id: province.id,
30
+                },
31
+            },
32
+            update: {
33
+                updatedAt: now().toDate(),
34
+            },
35
+            create: {
36
+                name,
37
+                province_id: province.id,
38
+                createdAt: now().toDate(),
39
+            },
40
+        });
41
+    }
42
+
43
+    console.log('✅ Kepulauan Bangka Belitung City seeded!');
44
+}
45
+
46
+// const prisma = require('../../../src/prisma/PrismaClient.js');
47
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
48
+
49
+// const cityNames = [
50
+//     'Kabupaten Bangka',
51
+//     'Kabupaten Bangka Barat',
52
+//     'Kabupaten Bangka Selatan',
53
+//     'Kabupaten Bangka Tengah',
54
+//     'Kabupaten Belitung',
55
+//     'Kabupaten Belitung Timur',
56
+//     'Kota Pangkal Pinang'
57
+
58
+//     // 7
59
+// ];
60
+
61
+// exports.seedKepulauanBangkaBelitungCities = async () => {
62
+//     const province = await prisma.province.findFirst({
63
+//         where: { name: 'Kepulauan Bangka Belitung' },
64
+//     });
65
+
66
+//     if (!province) {
67
+//         console.error('❌ Province Kepulauan Bangka Belitung not found. Seed it first.');
68
+//         return;
69
+//     }
70
+
71
+//     for (const name of cityNames) {
72
+//         await prisma.city.upsert({
73
+//             where: {
74
+//                 name_province_id: {
75
+//                     name,
76
+//                     province_id: province.id,
77
+//                 },
78
+//             },
79
+//             update: {
80
+//                 updatedAt: timeLocal.now().toDate()
81
+//             },
82
+//             create: {
83
+//                 name,
84
+//                 province_id: province.id,
85
+//                 createdAt: timeLocal.now().toDate()
86
+//             },
87
+//         });
88
+//     }
89
+
90
+//     console.log('✅ Kepulauan Bangka Belitung City seeded!.');
91
+// };

+ 0 - 46
prisma/seeders/city/KepulauanRiauCitySeeder.js

@@ -1,46 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bintan',
6
-    'Kabupaten Karimun',
7
-    'Kabupaten Kepulauan Anambas',
8
-    'Kabupaten Lingga',
9
-    'Kabupaten Natuna',
10
-    'Kota Batam',
11
-    'Kota Tanjung Pinang'
12
-
13
-    // 7
14
-];
15
-
16
-exports.seedKepulauanRiauCities = async () => {
17
-    const province = await prisma.province.findFirst({
18
-        where: { name: 'Kepulauan Riau' },
19
-    });
20
-
21
-    if (!province) {
22
-        console.error('❌ Province Kepulauan Riau not found. Seed it first.');
23
-        return;
24
-    }
25
-
26
-    for (const name of cityNames) {
27
-        await prisma.city.upsert({
28
-            where: {
29
-                name_province_id: {
30
-                    name,
31
-                    province_id: province.id,
32
-                },
33
-            },
34
-            update: {
35
-                updatedAt: timeLocal.now().toDate()
36
-            },
37
-            create: {
38
-                name,
39
-                province_id: province.id,
40
-                createdAt: timeLocal.now().toDate()
41
-            },
42
-        });
43
-    }
44
-
45
-    console.log('✅ Kepulauan Riau City seeded!.');
46
-};

+ 91 - 0
prisma/seeders/city/KepulauanRiauCitySeeder.ts

@@ -0,0 +1,91 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bintan',
6
+    'Kabupaten Karimun',
7
+    'Kabupaten Kepulauan Anambas',
8
+    'Kabupaten Lingga',
9
+    'Kabupaten Natuna',
10
+    'Kota Batam',
11
+    'Kota Tanjung Pinang'
12
+];
13
+
14
+export async function seedKepulauanRiauCities(): Promise<void> {
15
+    const province = await prisma.province.findFirst({
16
+        where: { name: 'Kepulauan Riau' },
17
+    });
18
+
19
+    if (!province) {
20
+        console.error('❌ Province Kepulauan Riau not found. Seed it first.');
21
+        return;
22
+    }
23
+
24
+    for (const name of cityNames) {
25
+        await prisma.city.upsert({
26
+            where: {
27
+                name_province_id: {
28
+                    name,
29
+                    province_id: province.id,
30
+                },
31
+            },
32
+            update: {
33
+                updatedAt: now().toDate(),
34
+            },
35
+            create: {
36
+                name,
37
+                province_id: province.id,
38
+                createdAt: now().toDate(),
39
+            },
40
+        });
41
+    }
42
+
43
+    console.log('✅ Kepulauan Riau City seeded!');
44
+}
45
+
46
+// const prisma = require('../../../src/prisma/PrismaClient.js');
47
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
48
+
49
+// const cityNames = [
50
+//     'Kabupaten Bintan',
51
+//     'Kabupaten Karimun',
52
+//     'Kabupaten Kepulauan Anambas',
53
+//     'Kabupaten Lingga',
54
+//     'Kabupaten Natuna',
55
+//     'Kota Batam',
56
+//     'Kota Tanjung Pinang'
57
+
58
+//     // 7
59
+// ];
60
+
61
+// exports.seedKepulauanRiauCities = async () => {
62
+//     const province = await prisma.province.findFirst({
63
+//         where: { name: 'Kepulauan Riau' },
64
+//     });
65
+
66
+//     if (!province) {
67
+//         console.error('❌ Province Kepulauan Riau not found. Seed it first.');
68
+//         return;
69
+//     }
70
+
71
+//     for (const name of cityNames) {
72
+//         await prisma.city.upsert({
73
+//             where: {
74
+//                 name_province_id: {
75
+//                     name,
76
+//                     province_id: province.id,
77
+//                 },
78
+//             },
79
+//             update: {
80
+//                 updatedAt: timeLocal.now().toDate()
81
+//             },
82
+//             create: {
83
+//                 name,
84
+//                 province_id: province.id,
85
+//                 createdAt: timeLocal.now().toDate()
86
+//             },
87
+//         });
88
+//     }
89
+
90
+//     console.log('✅ Kepulauan Riau City seeded!.');
91
+// };

+ 0 - 54
prisma/seeders/city/LampungCitySeeder.js

@@ -1,54 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Lampung Barat',
6
-    'Kabupaten Lampung Selatan',
7
-    'Kabupaten Lampung Tengah',
8
-    'Kabupaten Lampung Timur',
9
-    'Kabupaten Lampung Utara',
10
-    'Kabupaten Mesuji',
11
-    'Kabupaten Pesawaran',
12
-    'Kabupaten Pesisir Barat',
13
-    'Kabupaten Pringsewu',
14
-    'Kabupaten Tanggamus',
15
-    'Kabupaten Tulang Bawang',
16
-    'Kabupaten Tulang Bawang Barat',
17
-    'Kabupaten Way Kanan',
18
-    'Kota Bandar Lampung',
19
-    'Kota Metro'
20
-
21
-    // 15
22
-];
23
-
24
-exports.seedLampungCities = async () => {
25
-    const province = await prisma.province.findFirst({
26
-        where: { name: 'Lampung' },
27
-    });
28
-
29
-    if (!province) {
30
-        console.error('❌ Province Lampung not found. Seed it first.');
31
-        return;
32
-    }
33
-
34
-    for (const name of cityNames) {
35
-        await prisma.city.upsert({
36
-            where: {
37
-                name_province_id: {
38
-                    name,
39
-                    province_id: province.id,
40
-                },
41
-            },
42
-            update: {
43
-                updatedAt: timeLocal.now().toDate()
44
-            },
45
-            create: {
46
-                name,
47
-                province_id: province.id,
48
-                createdAt: timeLocal.now().toDate()
49
-            },
50
-        });
51
-    }
52
-
53
-    console.log('✅ Lampung City seeded!.');
54
-};

+ 107 - 0
prisma/seeders/city/LampungCitySeeder.ts

@@ -0,0 +1,107 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Lampung Barat',
6
+    'Kabupaten Lampung Selatan',
7
+    'Kabupaten Lampung Tengah',
8
+    'Kabupaten Lampung Timur',
9
+    'Kabupaten Lampung Utara',
10
+    'Kabupaten Mesuji',
11
+    'Kabupaten Pesawaran',
12
+    'Kabupaten Pesisir Barat',
13
+    'Kabupaten Pringsewu',
14
+    'Kabupaten Tanggamus',
15
+    'Kabupaten Tulang Bawang',
16
+    'Kabupaten Tulang Bawang Barat',
17
+    'Kabupaten Way Kanan',
18
+    'Kota Bandar Lampung',
19
+    'Kota Metro'
20
+];
21
+
22
+export async function seedLampungCities(): Promise<void> {
23
+    const province = await prisma.province.findFirst({
24
+        where: { name: 'Lampung' },
25
+    });
26
+
27
+    if (!province) {
28
+        console.error('❌ Province Lampung not found. Seed it first.');
29
+        return;
30
+    }
31
+
32
+    for (const name of cityNames) {
33
+        await prisma.city.upsert({
34
+            where: {
35
+                name_province_id: {
36
+                    name,
37
+                    province_id: province.id,
38
+                },
39
+            },
40
+            update: {
41
+                updatedAt: now().toDate(),
42
+            },
43
+            create: {
44
+                name,
45
+                province_id: province.id,
46
+                createdAt: now().toDate(),
47
+            },
48
+        });
49
+    }
50
+
51
+    console.log('✅ Lampung City seeded!');
52
+}
53
+
54
+// const prisma = require('../../../src/prisma/PrismaClient.js');
55
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
56
+
57
+// const cityNames = [
58
+//     'Kabupaten Lampung Barat',
59
+//     'Kabupaten Lampung Selatan',
60
+//     'Kabupaten Lampung Tengah',
61
+//     'Kabupaten Lampung Timur',
62
+//     'Kabupaten Lampung Utara',
63
+//     'Kabupaten Mesuji',
64
+//     'Kabupaten Pesawaran',
65
+//     'Kabupaten Pesisir Barat',
66
+//     'Kabupaten Pringsewu',
67
+//     'Kabupaten Tanggamus',
68
+//     'Kabupaten Tulang Bawang',
69
+//     'Kabupaten Tulang Bawang Barat',
70
+//     'Kabupaten Way Kanan',
71
+//     'Kota Bandar Lampung',
72
+//     'Kota Metro'
73
+
74
+//     // 15
75
+// ];
76
+
77
+// exports.seedLampungCities = async () => {
78
+//     const province = await prisma.province.findFirst({
79
+//         where: { name: 'Lampung' },
80
+//     });
81
+
82
+//     if (!province) {
83
+//         console.error('❌ Province Lampung not found. Seed it first.');
84
+//         return;
85
+//     }
86
+
87
+//     for (const name of cityNames) {
88
+//         await prisma.city.upsert({
89
+//             where: {
90
+//                 name_province_id: {
91
+//                     name,
92
+//                     province_id: province.id,
93
+//                 },
94
+//             },
95
+//             update: {
96
+//                 updatedAt: timeLocal.now().toDate()
97
+//             },
98
+//             create: {
99
+//                 name,
100
+//                 province_id: province.id,
101
+//                 createdAt: timeLocal.now().toDate()
102
+//             },
103
+//         });
104
+//     }
105
+
106
+//     console.log('✅ Lampung City seeded!.');
107
+// };

+ 0 - 50
prisma/seeders/city/MalukuCitySeeder.js

@@ -1,50 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Buru',
6
-    'Kabupaten Buru Selatan',
7
-    'Kabupaten Kepulauan Aru',
8
-    'Kabupaten Maluku Barat Daya',
9
-    'Kabupaten Maluku Tengah',
10
-    'Kabupaten Maluku Tenggara',
11
-    'Kabupaten Seram Bagian Barat',
12
-    'Kabupaten Seram Bagian Timur',
13
-    'Kota Ambon',
14
-    'Kota Tual',
15
-    'Kabupaten Maluku Tenggara Barat'
16
-
17
-    // 11
18
-];
19
-
20
-exports.seedMalukuCities = async () => {
21
-    const province = await prisma.province.findFirst({
22
-        where: { name: 'Maluku' },
23
-    });
24
-
25
-    if (!province) {
26
-        console.error('❌ Province Maluku not found. Seed it first.');
27
-        return;
28
-    }
29
-
30
-    for (const name of cityNames) {
31
-        await prisma.city.upsert({
32
-            where: {
33
-                name_province_id: {
34
-                    name,
35
-                    province_id: province.id,
36
-                },
37
-            },
38
-            update: {
39
-                updatedAt: timeLocal.now().toDate()
40
-            },
41
-            create: {
42
-                name,
43
-                province_id: province.id,
44
-                createdAt: timeLocal.now().toDate()
45
-            },
46
-        });
47
-    }
48
-
49
-    console.log('✅ Maluku City seeded!.');
50
-};

+ 99 - 0
prisma/seeders/city/MalukuCitySeeder.ts

@@ -0,0 +1,99 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Buru',
6
+    'Kabupaten Buru Selatan',
7
+    'Kabupaten Kepulauan Aru',
8
+    'Kabupaten Maluku Barat Daya',
9
+    'Kabupaten Maluku Tengah',
10
+    'Kabupaten Maluku Tenggara',
11
+    'Kabupaten Seram Bagian Barat',
12
+    'Kabupaten Seram Bagian Timur',
13
+    'Kota Ambon',
14
+    'Kota Tual',
15
+    'Kabupaten Maluku Tenggara Barat'
16
+];
17
+
18
+export async function seedMalukuCities(): Promise<void> {
19
+    const province = await prisma.province.findFirst({
20
+        where: { name: 'Maluku' },
21
+    });
22
+
23
+    if (!province) {
24
+        console.error('❌ Province Maluku not found. Seed it first.');
25
+        return;
26
+    }
27
+
28
+    for (const name of cityNames) {
29
+        await prisma.city.upsert({
30
+            where: {
31
+                name_province_id: {
32
+                    name,
33
+                    province_id: province.id,
34
+                },
35
+            },
36
+            update: {
37
+                updatedAt: now().toDate(),
38
+            },
39
+            create: {
40
+                name,
41
+                province_id: province.id,
42
+                createdAt: now().toDate(),
43
+            },
44
+        });
45
+    }
46
+
47
+    console.log('✅ Maluku City seeded!');
48
+}
49
+
50
+// const prisma = require('../../../src/prisma/PrismaClient.js');
51
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
52
+
53
+// const cityNames = [
54
+//     'Kabupaten Buru',
55
+//     'Kabupaten Buru Selatan',
56
+//     'Kabupaten Kepulauan Aru',
57
+//     'Kabupaten Maluku Barat Daya',
58
+//     'Kabupaten Maluku Tengah',
59
+//     'Kabupaten Maluku Tenggara',
60
+//     'Kabupaten Seram Bagian Barat',
61
+//     'Kabupaten Seram Bagian Timur',
62
+//     'Kota Ambon',
63
+//     'Kota Tual',
64
+//     'Kabupaten Maluku Tenggara Barat'
65
+
66
+//     // 11
67
+// ];
68
+
69
+// exports.seedMalukuCities = async () => {
70
+//     const province = await prisma.province.findFirst({
71
+//         where: { name: 'Maluku' },
72
+//     });
73
+
74
+//     if (!province) {
75
+//         console.error('❌ Province Maluku not found. Seed it first.');
76
+//         return;
77
+//     }
78
+
79
+//     for (const name of cityNames) {
80
+//         await prisma.city.upsert({
81
+//             where: {
82
+//                 name_province_id: {
83
+//                     name,
84
+//                     province_id: province.id,
85
+//                 },
86
+//             },
87
+//             update: {
88
+//                 updatedAt: timeLocal.now().toDate()
89
+//             },
90
+//             create: {
91
+//                 name,
92
+//                 province_id: province.id,
93
+//                 createdAt: timeLocal.now().toDate()
94
+//             },
95
+//         });
96
+//     }
97
+
98
+//     console.log('✅ Maluku City seeded!.');
99
+// };

+ 0 - 49
prisma/seeders/city/MalukuUtaraCitySeeder.js

@@ -1,49 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Halmahera Barat',
6
-    'Kabupaten Halmahera Tengah',
7
-    'Kabupaten Halmahera Timur',
8
-    'Kabupaten Halmahera Selatan',
9
-    'Kabupaten Halmahera Utara',
10
-    'Kabupaten Kepulauan Sula',
11
-    'Kabupaten Pulau Morotai',
12
-    'Kabupaten Pulau Taliabu',
13
-    'Kota Ternate',
14
-    'Kota Tidore Kepulauan'
15
-
16
-    // 10
17
-];
18
-
19
-exports.seedMalukuUtaraCities = async () => {
20
-    const province = await prisma.province.findFirst({
21
-        where: { name: 'Maluku Utara' },
22
-    });
23
-
24
-    if (!province) {
25
-        console.error('❌ Province Maluku Utara not found. Seed it first.');
26
-        return;
27
-    }
28
-
29
-    for (const name of cityNames) {
30
-        await prisma.city.upsert({
31
-            where: {
32
-                name_province_id: {
33
-                    name,
34
-                    province_id: province.id,
35
-                },
36
-            },
37
-            update: {
38
-                updatedAt: timeLocal.now().toDate()
39
-            },
40
-            create: {
41
-                name,
42
-                province_id: province.id,
43
-                createdAt: timeLocal.now().toDate()
44
-            },
45
-        });
46
-    }
47
-
48
-    console.log('✅ Maluku Utara City seeded!.');
49
-};

+ 97 - 0
prisma/seeders/city/MalukuUtaraCitySeeder.ts

@@ -0,0 +1,97 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Halmahera Barat',
6
+    'Kabupaten Halmahera Tengah',
7
+    'Kabupaten Halmahera Timur',
8
+    'Kabupaten Halmahera Selatan',
9
+    'Kabupaten Halmahera Utara',
10
+    'Kabupaten Kepulauan Sula',
11
+    'Kabupaten Pulau Morotai',
12
+    'Kabupaten Pulau Taliabu',
13
+    'Kota Ternate',
14
+    'Kota Tidore Kepulauan'
15
+];
16
+
17
+export async function seedMalukuUtaraCities(): Promise<void> {
18
+    const province = await prisma.province.findFirst({
19
+        where: { name: 'Maluku Utara' },
20
+    });
21
+
22
+    if (!province) {
23
+        console.error('❌ Province Maluku Utara not found. Seed it first.');
24
+        return;
25
+    }
26
+
27
+    for (const name of cityNames) {
28
+        await prisma.city.upsert({
29
+            where: {
30
+                name_province_id: {
31
+                    name,
32
+                    province_id: province.id,
33
+                },
34
+            },
35
+            update: {
36
+                updatedAt: now().toDate(),
37
+            },
38
+            create: {
39
+                name,
40
+                province_id: province.id,
41
+                createdAt: now().toDate(),
42
+            },
43
+        });
44
+    }
45
+
46
+    console.log('✅ Maluku Utara City seeded!');
47
+}
48
+
49
+// const prisma = require('../../../src/prisma/PrismaClient.js');
50
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
51
+
52
+// const cityNames = [
53
+//     'Kabupaten Halmahera Barat',
54
+//     'Kabupaten Halmahera Tengah',
55
+//     'Kabupaten Halmahera Timur',
56
+//     'Kabupaten Halmahera Selatan',
57
+//     'Kabupaten Halmahera Utara',
58
+//     'Kabupaten Kepulauan Sula',
59
+//     'Kabupaten Pulau Morotai',
60
+//     'Kabupaten Pulau Taliabu',
61
+//     'Kota Ternate',
62
+//     'Kota Tidore Kepulauan'
63
+
64
+//     // 10
65
+// ];
66
+
67
+// exports.seedMalukuUtaraCities = async () => {
68
+//     const province = await prisma.province.findFirst({
69
+//         where: { name: 'Maluku Utara' },
70
+//     });
71
+
72
+//     if (!province) {
73
+//         console.error('❌ Province Maluku Utara not found. Seed it first.');
74
+//         return;
75
+//     }
76
+
77
+//     for (const name of cityNames) {
78
+//         await prisma.city.upsert({
79
+//             where: {
80
+//                 name_province_id: {
81
+//                     name,
82
+//                     province_id: province.id,
83
+//                 },
84
+//             },
85
+//             update: {
86
+//                 updatedAt: timeLocal.now().toDate()
87
+//             },
88
+//             create: {
89
+//                 name,
90
+//                 province_id: province.id,
91
+//                 createdAt: timeLocal.now().toDate()
92
+//             },
93
+//         });
94
+//     }
95
+
96
+//     console.log('✅ Maluku Utara City seeded!.');
97
+// };

+ 0 - 49
prisma/seeders/city/NusaTenggaraBaratCitySeeder.js

@@ -1,49 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bima',
6
-    'Kabupaten Dompu',
7
-    'Kabupaten Lombok Barat',
8
-    'Kabupaten Lombok Tengah',
9
-    'Kabupaten Lombok Timur',
10
-    'Kabupaten Lombok Utara',
11
-    'Kabupaten Sumbawa',
12
-    'Kabupaten Sumbawa Barat',
13
-    'Kota Bima',
14
-    'Kota Mataram'
15
-
16
-    // 10
17
-];
18
-
19
-exports.seedNusaTenggaraBaratCities = async () => {
20
-    const province = await prisma.province.findFirst({
21
-        where: { name: 'Nusa Tenggara Barat' },
22
-    });
23
-
24
-    if (!province) {
25
-        console.error('❌ Province Nusa Tenggara Barat not found. Seed it first.');
26
-        return;
27
-    }
28
-
29
-    for (const name of cityNames) {
30
-        await prisma.city.upsert({
31
-            where: {
32
-                name_province_id: {
33
-                    name,
34
-                    province_id: province.id,
35
-                },
36
-            },
37
-            update: {
38
-                updatedAt: timeLocal.now().toDate()
39
-            },
40
-            create: {
41
-                name,
42
-                province_id: province.id,
43
-                createdAt: timeLocal.now().toDate()
44
-            },
45
-        });
46
-    }
47
-
48
-    console.log('✅ Nusa Tenggara Barat City seeded!.');
49
-};

+ 97 - 0
prisma/seeders/city/NusaTenggaraBaratCitySeeder.ts

@@ -0,0 +1,97 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bima',
6
+    'Kabupaten Dompu',
7
+    'Kabupaten Lombok Barat',
8
+    'Kabupaten Lombok Tengah',
9
+    'Kabupaten Lombok Timur',
10
+    'Kabupaten Lombok Utara',
11
+    'Kabupaten Sumbawa',
12
+    'Kabupaten Sumbawa Barat',
13
+    'Kota Bima',
14
+    'Kota Mataram'
15
+];
16
+
17
+export async function seedNusaTenggaraBaratCities(): Promise<void> {
18
+    const province = await prisma.province.findFirst({
19
+        where: { name: 'Nusa Tenggara Barat' },
20
+    });
21
+
22
+    if (!province) {
23
+        console.error('❌ Province Nusa Tenggara Barat not found. Seed it first.');
24
+        return;
25
+    }
26
+
27
+    for (const name of cityNames) {
28
+        await prisma.city.upsert({
29
+            where: {
30
+                name_province_id: {
31
+                    name,
32
+                    province_id: province.id,
33
+                },
34
+            },
35
+            update: {
36
+                updatedAt: now().toDate(),
37
+            },
38
+            create: {
39
+                name,
40
+                province_id: province.id,
41
+                createdAt: now().toDate(),
42
+            },
43
+        });
44
+    }
45
+
46
+    console.log('✅ Nusa Tenggara Barat City seeded!');
47
+}
48
+
49
+// const prisma = require('../../../src/prisma/PrismaClient.js');
50
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
51
+
52
+// const cityNames = [
53
+//     'Kabupaten Bima',
54
+//     'Kabupaten Dompu',
55
+//     'Kabupaten Lombok Barat',
56
+//     'Kabupaten Lombok Tengah',
57
+//     'Kabupaten Lombok Timur',
58
+//     'Kabupaten Lombok Utara',
59
+//     'Kabupaten Sumbawa',
60
+//     'Kabupaten Sumbawa Barat',
61
+//     'Kota Bima',
62
+//     'Kota Mataram'
63
+
64
+//     // 10
65
+// ];
66
+
67
+// exports.seedNusaTenggaraBaratCities = async () => {
68
+//     const province = await prisma.province.findFirst({
69
+//         where: { name: 'Nusa Tenggara Barat' },
70
+//     });
71
+
72
+//     if (!province) {
73
+//         console.error('❌ Province Nusa Tenggara Barat not found. Seed it first.');
74
+//         return;
75
+//     }
76
+
77
+//     for (const name of cityNames) {
78
+//         await prisma.city.upsert({
79
+//             where: {
80
+//                 name_province_id: {
81
+//                     name,
82
+//                     province_id: province.id,
83
+//                 },
84
+//             },
85
+//             update: {
86
+//                 updatedAt: timeLocal.now().toDate()
87
+//             },
88
+//             create: {
89
+//                 name,
90
+//                 province_id: province.id,
91
+//                 createdAt: timeLocal.now().toDate()
92
+//             },
93
+//         });
94
+//     }
95
+
96
+//     console.log('✅ Nusa Tenggara Barat City seeded!.');
97
+// };

+ 0 - 61
prisma/seeders/city/NusaTenggaraTimurCitySeeder.js

@@ -1,61 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Alor',
6
-    'Kabupaten Belu',
7
-    'Kabupaten Ende',
8
-    'Kabupaten Flores Timur',
9
-    'Kabupaten Kupang',
10
-    'Kabupaten Lembata',
11
-    'Kabupaten Malaka',
12
-    'Kabupaten Manggarai',
13
-    'Kabupaten Manggarai Barat',
14
-    'Kabupaten Manggarai Timur',
15
-    'Kabupaten Nagekeo',
16
-    'Kabupaten Ngada',
17
-    'Kabupaten Rote Ndao',
18
-    'Kabupaten Sabu Raijua',
19
-    'Kabupaten Sikka',
20
-    'Kabupaten Sumba Barat',
21
-    'Kabupaten Sumba Barat Daya',
22
-    'Kabupaten Sumba Tengah',
23
-    'Kabupaten Sumba Timur',
24
-    'Kabupaten Timor Tengah Selatan',
25
-    'Kabupaten Timor Tengah Utara',
26
-    'Kota Kupang'
27
-
28
-    // 22
29
-];
30
-
31
-exports.seedNusaTenggaraTimurCities = async () => {
32
-    const province = await prisma.province.findFirst({
33
-        where: { name: 'Nusa Tenggara Timur' },
34
-    });
35
-
36
-    if (!province) {
37
-        console.error('❌ Province Nusa Tenggara Timur not found. Seed it first.');
38
-        return;
39
-    }
40
-
41
-    for (const name of cityNames) {
42
-        await prisma.city.upsert({
43
-            where: {
44
-                name_province_id: {
45
-                    name,
46
-                    province_id: province.id,
47
-                },
48
-            },
49
-            update: {
50
-                updatedAt: timeLocal.now().toDate()
51
-            },
52
-            create: {
53
-                name,
54
-                province_id: province.id,
55
-                createdAt: timeLocal.now().toDate()
56
-            },
57
-        });
58
-    }
59
-
60
-    console.log('✅ Nusa Tenggara Timur City seeded!.');
61
-};

+ 121 - 0
prisma/seeders/city/NusaTenggaraTimurCitySeeder.ts

@@ -0,0 +1,121 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Alor',
6
+    'Kabupaten Belu',
7
+    'Kabupaten Ende',
8
+    'Kabupaten Flores Timur',
9
+    'Kabupaten Kupang',
10
+    'Kabupaten Lembata',
11
+    'Kabupaten Malaka',
12
+    'Kabupaten Manggarai',
13
+    'Kabupaten Manggarai Barat',
14
+    'Kabupaten Manggarai Timur',
15
+    'Kabupaten Nagekeo',
16
+    'Kabupaten Ngada',
17
+    'Kabupaten Rote Ndao',
18
+    'Kabupaten Sabu Raijua',
19
+    'Kabupaten Sikka',
20
+    'Kabupaten Sumba Barat',
21
+    'Kabupaten Sumba Barat Daya',
22
+    'Kabupaten Sumba Tengah',
23
+    'Kabupaten Sumba Timur',
24
+    'Kabupaten Timor Tengah Selatan',
25
+    'Kabupaten Timor Tengah Utara',
26
+    'Kota Kupang'
27
+];
28
+
29
+export async function seedNusaTenggaraTimurCities(): Promise<void> {
30
+    const province = await prisma.province.findFirst({
31
+        where: { name: 'Nusa Tenggara Timur' },
32
+    });
33
+
34
+    if (!province) {
35
+        console.error('❌ Province Nusa Tenggara Timur not found. Seed it first.');
36
+        return;
37
+    }
38
+
39
+    for (const name of cityNames) {
40
+        await prisma.city.upsert({
41
+            where: {
42
+                name_province_id: {
43
+                    name,
44
+                    province_id: province.id,
45
+                },
46
+            },
47
+            update: {
48
+                updatedAt: now().toDate(),
49
+            },
50
+            create: {
51
+                name,
52
+                province_id: province.id,
53
+                createdAt: now().toDate(),
54
+            },
55
+        });
56
+    }
57
+
58
+    console.log('✅ Nusa Tenggara Timur City seeded!');
59
+}
60
+
61
+// const prisma = require('../../../src/prisma/PrismaClient.js');
62
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
63
+
64
+// const cityNames = [
65
+//     'Kabupaten Alor',
66
+//     'Kabupaten Belu',
67
+//     'Kabupaten Ende',
68
+//     'Kabupaten Flores Timur',
69
+//     'Kabupaten Kupang',
70
+//     'Kabupaten Lembata',
71
+//     'Kabupaten Malaka',
72
+//     'Kabupaten Manggarai',
73
+//     'Kabupaten Manggarai Barat',
74
+//     'Kabupaten Manggarai Timur',
75
+//     'Kabupaten Nagekeo',
76
+//     'Kabupaten Ngada',
77
+//     'Kabupaten Rote Ndao',
78
+//     'Kabupaten Sabu Raijua',
79
+//     'Kabupaten Sikka',
80
+//     'Kabupaten Sumba Barat',
81
+//     'Kabupaten Sumba Barat Daya',
82
+//     'Kabupaten Sumba Tengah',
83
+//     'Kabupaten Sumba Timur',
84
+//     'Kabupaten Timor Tengah Selatan',
85
+//     'Kabupaten Timor Tengah Utara',
86
+//     'Kota Kupang'
87
+
88
+//     // 22
89
+// ];
90
+
91
+// exports.seedNusaTenggaraTimurCities = async () => {
92
+//     const province = await prisma.province.findFirst({
93
+//         where: { name: 'Nusa Tenggara Timur' },
94
+//     });
95
+
96
+//     if (!province) {
97
+//         console.error('❌ Province Nusa Tenggara Timur not found. Seed it first.');
98
+//         return;
99
+//     }
100
+
101
+//     for (const name of cityNames) {
102
+//         await prisma.city.upsert({
103
+//             where: {
104
+//                 name_province_id: {
105
+//                     name,
106
+//                     province_id: province.id,
107
+//                 },
108
+//             },
109
+//             update: {
110
+//                 updatedAt: timeLocal.now().toDate()
111
+//             },
112
+//             create: {
113
+//                 name,
114
+//                 province_id: province.id,
115
+//                 createdAt: timeLocal.now().toDate()
116
+//             },
117
+//         });
118
+//     }
119
+
120
+//     console.log('✅ Nusa Tenggara Timur City seeded!.');
121
+// };

+ 0 - 46
prisma/seeders/city/PapuaBaratCitySeeder.js

@@ -1,46 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Fakfak',
6
-    'Kabupaten Kaimana',
7
-    'Kabupaten Manokwari',
8
-    'Kabupaten Manokwari Selatan',
9
-    'Kabupaten Pegunungan Arfak',
10
-    'Kabupaten Teluk Bintuni',
11
-    'Kabupaten Teluk Wondama',
12
-
13
-    // 7
14
-];
15
-
16
-exports.seedPapuaBaratCities = async () => {
17
-    const province = await prisma.province.findFirst({
18
-        where: { name: 'Papua Barat' },
19
-    });
20
-
21
-    if (!province) {
22
-        console.error('❌ Province Papua Barat not found. Seed it first.');
23
-        return;
24
-    }
25
-
26
-    for (const name of cityNames) {
27
-        await prisma.city.upsert({
28
-            where: {
29
-                name_province_id: {
30
-                    name,
31
-                    province_id: province.id,
32
-                },
33
-            },
34
-            update: {
35
-                updatedAt: timeLocal.now().toDate()
36
-            },
37
-            create: {
38
-                name,
39
-                province_id: province.id,
40
-                createdAt: timeLocal.now().toDate()
41
-            },
42
-        });
43
-    }
44
-
45
-    console.log('✅ Papua Barat City seeded!.');
46
-};

+ 92 - 0
prisma/seeders/city/PapuaBaratCitySeeder.ts

@@ -0,0 +1,92 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Fakfak',
6
+    'Kabupaten Kaimana',
7
+    'Kabupaten Manokwari',
8
+    'Kabupaten Manokwari Selatan',
9
+    'Kabupaten Pegunungan Arfak',
10
+    'Kabupaten Teluk Bintuni',
11
+    'Kabupaten Teluk Wondama',
12
+];
13
+
14
+export const seedPapuaBaratCities = async (): Promise<void> => {
15
+    const province = await prisma.province.findFirst({
16
+        where: { name: 'Papua Barat' },
17
+    });
18
+
19
+    if (!province) {
20
+        console.error('❌ Province Papua Barat not found. Seed it first.');
21
+        return;
22
+    }
23
+
24
+    for (const name of cityNames) {
25
+        await prisma.city.upsert({
26
+            where: {
27
+                // Pastikan composite key ini sudah dibuat di schema.prisma
28
+                name_province_id: {
29
+                    name,
30
+                    province_id: province.id,
31
+                },
32
+            },
33
+            update: {
34
+                updatedAt: now().toDate(),
35
+            },
36
+            create: {
37
+                name,
38
+                province_id: province.id,
39
+                createdAt: now().toDate(),
40
+            },
41
+        });
42
+    }
43
+
44
+    console.log('✅ Papua Barat City seeded!.');
45
+};
46
+
47
+// const prisma = require('../../../src/prisma/PrismaClient.js');
48
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
49
+
50
+// const cityNames = [
51
+//     'Kabupaten Fakfak',
52
+//     'Kabupaten Kaimana',
53
+//     'Kabupaten Manokwari',
54
+//     'Kabupaten Manokwari Selatan',
55
+//     'Kabupaten Pegunungan Arfak',
56
+//     'Kabupaten Teluk Bintuni',
57
+//     'Kabupaten Teluk Wondama',
58
+
59
+//     // 7
60
+// ];
61
+
62
+// exports.seedPapuaBaratCities = async () => {
63
+//     const province = await prisma.province.findFirst({
64
+//         where: { name: 'Papua Barat' },
65
+//     });
66
+
67
+//     if (!province) {
68
+//         console.error('❌ Province Papua Barat not found. Seed it first.');
69
+//         return;
70
+//     }
71
+
72
+//     for (const name of cityNames) {
73
+//         await prisma.city.upsert({
74
+//             where: {
75
+//                 name_province_id: {
76
+//                     name,
77
+//                     province_id: province.id,
78
+//                 },
79
+//             },
80
+//             update: {
81
+//                 updatedAt: timeLocal.now().toDate()
82
+//             },
83
+//             create: {
84
+//                 name,
85
+//                 province_id: province.id,
86
+//                 createdAt: timeLocal.now().toDate()
87
+//             },
88
+//         });
89
+//     }
90
+
91
+//     console.log('✅ Papua Barat City seeded!.');
92
+// };

+ 0 - 45
prisma/seeders/city/PapuaBaratDayaCitySeeder.js

@@ -1,45 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Maybrat',
6
-    'Kabupaten Sorong',
7
-    'Kabupaten Sorong Selatan',
8
-    'Kabupaten Tambrauw',
9
-    'Kabupaten Raja Ampat',
10
-    'Kota Sorong'
11
-
12
-    // 6
13
-];
14
-
15
-exports.seedPapuaBaratDayaCities = async () => {
16
-    const province = await prisma.province.findFirst({
17
-        where: { name: 'Papua Barat Daya' },
18
-    });
19
-
20
-    if (!province) {
21
-        console.error('❌ Province Papua Barat Daya not found. Seed it first.');
22
-        return;
23
-    }
24
-
25
-    for (const name of cityNames) {
26
-        await prisma.city.upsert({
27
-            where: {
28
-                name_province_id: {
29
-                    name,
30
-                    province_id: province.id,
31
-                },
32
-            },
33
-            update: {
34
-                updatedAt: timeLocal.now().toDate()
35
-            },
36
-            create: {
37
-                name,
38
-                province_id: province.id,
39
-                createdAt: timeLocal.now().toDate()
40
-            },
41
-        });
42
-    }
43
-
44
-    console.log('✅ Papua Barat Daya City seeded!.');
45
-};

+ 90 - 0
prisma/seeders/city/PapuaBaratDayaCitySeeder.ts

@@ -0,0 +1,90 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Maybrat',
6
+    'Kabupaten Sorong',
7
+    'Kabupaten Sorong Selatan',
8
+    'Kabupaten Tambrauw',
9
+    'Kabupaten Raja Ampat',
10
+    'Kota Sorong',
11
+];
12
+
13
+export const seedPapuaBaratDayaCities = async (): Promise<void> => {
14
+    const province = await prisma.province.findFirst({
15
+        where: { name: 'Papua Barat Daya' },
16
+    });
17
+
18
+    if (!province) {
19
+        console.error('❌ Province Papua Barat Daya not found. Seed it first.');
20
+        return;
21
+    }
22
+
23
+    for (const name of cityNames) {
24
+        await prisma.city.upsert({
25
+            where: {
26
+                // Requires a unique constraint on [name, province_id] in your Prisma schema
27
+                name_province_id: {
28
+                    name,
29
+                    province_id: province.id,
30
+                },
31
+            },
32
+            update: {
33
+                updatedAt: now().toDate(),
34
+            },
35
+            create: {
36
+                name,
37
+                province_id: province.id,
38
+                createdAt: now().toDate(),
39
+            },
40
+        });
41
+    }
42
+
43
+    console.log('✅ Papua Barat Daya City seeded!.');
44
+};
45
+
46
+// const prisma = require('../../../src/prisma/PrismaClient.js');
47
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
48
+
49
+// const cityNames = [
50
+//     'Kabupaten Maybrat',
51
+//     'Kabupaten Sorong',
52
+//     'Kabupaten Sorong Selatan',
53
+//     'Kabupaten Tambrauw',
54
+//     'Kabupaten Raja Ampat',
55
+//     'Kota Sorong'
56
+
57
+//     // 6
58
+// ];
59
+
60
+// exports.seedPapuaBaratDayaCities = async () => {
61
+//     const province = await prisma.province.findFirst({
62
+//         where: { name: 'Papua Barat Daya' },
63
+//     });
64
+
65
+//     if (!province) {
66
+//         console.error('❌ Province Papua Barat Daya not found. Seed it first.');
67
+//         return;
68
+//     }
69
+
70
+//     for (const name of cityNames) {
71
+//         await prisma.city.upsert({
72
+//             where: {
73
+//                 name_province_id: {
74
+//                     name,
75
+//                     province_id: province.id,
76
+//                 },
77
+//             },
78
+//             update: {
79
+//                 updatedAt: timeLocal.now().toDate()
80
+//             },
81
+//             create: {
82
+//                 name,
83
+//                 province_id: province.id,
84
+//                 createdAt: timeLocal.now().toDate()
85
+//             },
86
+//         });
87
+//     }
88
+
89
+//     console.log('✅ Papua Barat Daya City seeded!.');
90
+// };

+ 0 - 46
prisma/seeders/city/PapuaCitySeeder.js

@@ -1,46 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Biak Numfor',
6
-    'Kabupaten Jayapura',
7
-    'Kabupaten Keerom',
8
-    'Kabupaten Kepulauan Yapen',
9
-    'Kabupaten Mamberamo Raya',
10
-    'Kabupaten Sarmi',
11
-    'Kabupaten Supiori',
12
-    'Kabupaten Waropen',
13
-    'Kota Jayapura'
14
-
15
-    // 9
16
-];
17
-
18
-exports.seedPapuaCities = async () => {
19
-    const province = await prisma.province.findFirst({
20
-        where: { name: 'Papua' },
21
-    });
22
-
23
-    if (!province) {
24
-        console.error('❌ Province Papua not found. Seed it first.');
25
-        return;
26
-    }
27
-
28
-    for (const name of cityNames) {
29
-        await prisma.city.upsert({
30
-            where: {
31
-                name_province_id: {
32
-                    name,
33
-                    province_id: province.id,
34
-                },
35
-            },
36
-            update: { updatedAt: timeLocal.now().toDate() },
37
-            create: {
38
-                name,
39
-                province_id: province.id,
40
-                createdAt: timeLocal.now().toDate()
41
-            },
42
-        });
43
-    }
44
-
45
-    console.log('✅ Papua City seeded!.');
46
-};

+ 93 - 0
prisma/seeders/city/PapuaCitySeeder.ts

@@ -0,0 +1,93 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Biak Numfor',
6
+    'Kabupaten Jayapura',
7
+    'Kabupaten Keerom',
8
+    'Kabupaten Kepulauan Yapen',
9
+    'Kabupaten Mamberamo Raya',
10
+    'Kabupaten Sarmi',
11
+    'Kabupaten Supiori',
12
+    'Kabupaten Waropen',
13
+    'Kota Jayapura'
14
+];
15
+
16
+export async function seedPapuaCities(): Promise<void> {
17
+    const province = await prisma.province.findFirst({
18
+        where: { name: 'Papua' },
19
+    });
20
+
21
+    if (!province) {
22
+        console.error('❌ Province Papua not found. Seed it first.');
23
+        return;
24
+    }
25
+
26
+    for (const name of cityNames) {
27
+        await prisma.city.upsert({
28
+            where: {
29
+                name_province_id: {
30
+                    name,
31
+                    province_id: province.id,
32
+                },
33
+            },
34
+            update: {
35
+                updatedAt: now().toDate(),
36
+            },
37
+            create: {
38
+                name,
39
+                province_id: province.id,
40
+                createdAt: now().toDate(),
41
+            },
42
+        });
43
+    }
44
+
45
+    console.log('✅ Papua City seeded!');
46
+}
47
+
48
+// const prisma = require('../../../src/prisma/PrismaClient.js');
49
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
50
+
51
+// const cityNames = [
52
+//     'Kabupaten Biak Numfor',
53
+//     'Kabupaten Jayapura',
54
+//     'Kabupaten Keerom',
55
+//     'Kabupaten Kepulauan Yapen',
56
+//     'Kabupaten Mamberamo Raya',
57
+//     'Kabupaten Sarmi',
58
+//     'Kabupaten Supiori',
59
+//     'Kabupaten Waropen',
60
+//     'Kota Jayapura'
61
+
62
+//     // 9
63
+// ];
64
+
65
+// exports.seedPapuaCities = async () => {
66
+//     const province = await prisma.province.findFirst({
67
+//         where: { name: 'Papua' },
68
+//     });
69
+
70
+//     if (!province) {
71
+//         console.error('❌ Province Papua not found. Seed it first.');
72
+//         return;
73
+//     }
74
+
75
+//     for (const name of cityNames) {
76
+//         await prisma.city.upsert({
77
+//             where: {
78
+//                 name_province_id: {
79
+//                     name,
80
+//                     province_id: province.id,
81
+//                 },
82
+//             },
83
+//             update: { updatedAt: timeLocal.now().toDate() },
84
+//             create: {
85
+//                 name,
86
+//                 province_id: province.id,
87
+//                 createdAt: timeLocal.now().toDate()
88
+//             },
89
+//         });
90
+//     }
91
+
92
+//     console.log('✅ Papua City seeded!.');
93
+// };

+ 0 - 45
prisma/seeders/city/PapuaPegununganCitySeeder.js

@@ -1,45 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Jayawijaya',
6
-    'Kabupaten Lanny Jaya',
7
-    'Kabupaten Mamberamo Tengah',
8
-    'Kabupaten Nduga',
9
-    'Kabupaten Pegunungan Bintang',
10
-    'Kabupaten Tolikara',
11
-    'Kabupaten Yahukimo',
12
-    'Kabupaten Yalimo'
13
-
14
-    // 8
15
-];
16
-
17
-exports.seedPapuaPegununganCities = async () => {
18
-    const province = await prisma.province.findFirst({
19
-        where: { name: 'Papua Pegunungan' },
20
-    });
21
-
22
-    if (!province) {
23
-        console.error('❌ Province Papua Pegunungan not found. Seed it first.');
24
-        return;
25
-    }
26
-
27
-    for (const name of cityNames) {
28
-        await prisma.city.upsert({
29
-            where: {
30
-                name_province_id: {
31
-                    name,
32
-                    province_id: province.id,
33
-                },
34
-            },
35
-            update: { updatedAt: timeLocal.now().toDate() },
36
-            create: {
37
-                name,
38
-                province_id: province.id,
39
-                createdAt: timeLocal.now().toDate()
40
-            },
41
-        });
42
-    }
43
-
44
-    console.log('✅ Papua Pegunungan City seeded!.');
45
-};

+ 92 - 0
prisma/seeders/city/PapuaPegununganCitySeeder.ts

@@ -0,0 +1,92 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Jayawijaya',
6
+    'Kabupaten Lanny Jaya',
7
+    'Kabupaten Mamberamo Tengah',
8
+    'Kabupaten Nduga',
9
+    'Kabupaten Pegunungan Bintang',
10
+    'Kabupaten Tolikara',
11
+    'Kabupaten Yahukimo',
12
+    'Kabupaten Yalimo',
13
+];
14
+
15
+export const seedPapuaPegununganCities = async (): Promise<void> => {
16
+    const province = await prisma.province.findFirst({
17
+        where: { name: 'Papua Pegunungan' },
18
+    });
19
+
20
+    if (!province) {
21
+        console.error('❌ Province Papua Pegunungan not found. Seed it first.');
22
+        return;
23
+    }
24
+
25
+    for (const name of cityNames) {
26
+        await prisma.city.upsert({
27
+            where: {
28
+                // Pastikan ada composite unique constraint [name, province_id] di schema.prisma
29
+                name_province_id: {
30
+                    name,
31
+                    province_id: province.id,
32
+                },
33
+            },
34
+            update: {
35
+                updatedAt: now().toDate(),
36
+            },
37
+            create: {
38
+                name,
39
+                province_id: province.id,
40
+                createdAt: now().toDate(),
41
+            },
42
+        });
43
+    }
44
+
45
+    console.log('✅ Papua Pegunungan City seeded!.');
46
+};
47
+
48
+// const prisma = require('../../../src/prisma/PrismaClient.js');
49
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
50
+
51
+// const cityNames = [
52
+//     'Kabupaten Jayawijaya',
53
+//     'Kabupaten Lanny Jaya',
54
+//     'Kabupaten Mamberamo Tengah',
55
+//     'Kabupaten Nduga',
56
+//     'Kabupaten Pegunungan Bintang',
57
+//     'Kabupaten Tolikara',
58
+//     'Kabupaten Yahukimo',
59
+//     'Kabupaten Yalimo'
60
+
61
+//     // 8
62
+// ];
63
+
64
+// exports.seedPapuaPegununganCities = async () => {
65
+//     const province = await prisma.province.findFirst({
66
+//         where: { name: 'Papua Pegunungan' },
67
+//     });
68
+
69
+//     if (!province) {
70
+//         console.error('❌ Province Papua Pegunungan not found. Seed it first.');
71
+//         return;
72
+//     }
73
+
74
+//     for (const name of cityNames) {
75
+//         await prisma.city.upsert({
76
+//             where: {
77
+//                 name_province_id: {
78
+//                     name,
79
+//                     province_id: province.id,
80
+//                 },
81
+//             },
82
+//             update: { updatedAt: timeLocal.now().toDate() },
83
+//             create: {
84
+//                 name,
85
+//                 province_id: province.id,
86
+//                 createdAt: timeLocal.now().toDate()
87
+//             },
88
+//         });
89
+//     }
90
+
91
+//     console.log('✅ Papua Pegunungan City seeded!.');
92
+// };

+ 0 - 41
prisma/seeders/city/PapuaSelatanCitySeeder.js

@@ -1,41 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Asmat',
6
-    'Kabupaten Boven Digoel',
7
-    'Kabupaten Mappi',
8
-    'Kabupaten Merauke'
9
-
10
-    // 4
11
-];
12
-
13
-exports.seedPapuaSelatanCities = async () => {
14
-    const province = await prisma.province.findFirst({
15
-        where: { name: 'Papua Selatan' },
16
-    });
17
-
18
-    if (!province) {
19
-        console.error('❌ Province Papua Selatan not found. Seed it first.');
20
-        return;
21
-    }
22
-
23
-    for (const name of cityNames) {
24
-        await prisma.city.upsert({
25
-            where: {
26
-                name_province_id: {
27
-                    name,
28
-                    province_id: province.id,
29
-                },
30
-            },
31
-            update: { updatedAt: timeLocal.now().toDate() },
32
-            create: {
33
-                name,
34
-                province_id: province.id,
35
-                createdAt: timeLocal.now().toDate()
36
-            },
37
-        });
38
-    }
39
-
40
-    console.log('✅ Papua Selatan City seeded!.');
41
-};

+ 84 - 0
prisma/seeders/city/PapuaSelatanCitySeeder.ts

@@ -0,0 +1,84 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Asmat',
6
+    'Kabupaten Boven Digoel',
7
+    'Kabupaten Mappi',
8
+    'Kabupaten Merauke'
9
+];
10
+
11
+export const seedPapuaSelatanCities = async (): Promise<void> => {
12
+    const province = await prisma.province.findFirst({
13
+        where: { name: 'Papua Selatan' },
14
+    });
15
+
16
+    if (!province) {
17
+        console.error('❌ Province Papua Selatan not found. Seed it first.');
18
+        return;
19
+    }
20
+
21
+    for (const name of cityNames) {
22
+        await prisma.city.upsert({
23
+            where: {
24
+                name_province_id: {
25
+                    name,
26
+                    province_id: province.id,
27
+                },
28
+            },
29
+            update: {
30
+                updatedAt: now().toDate(),
31
+            },
32
+            create: {
33
+                name,
34
+                province_id: province.id,
35
+                createdAt: now().toDate(),
36
+            },
37
+        });
38
+    }
39
+
40
+    console.log('✅ Papua Selatan City seeded!.');
41
+};
42
+
43
+
44
+// const prisma = require('../../../src/prisma/PrismaClient.js');
45
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
46
+
47
+// const cityNames = [
48
+//     'Kabupaten Asmat',
49
+//     'Kabupaten Boven Digoel',
50
+//     'Kabupaten Mappi',
51
+//     'Kabupaten Merauke'
52
+
53
+//     // 4
54
+// ];
55
+
56
+// exports.seedPapuaSelatanCities = async () => {
57
+//     const province = await prisma.province.findFirst({
58
+//         where: { name: 'Papua Selatan' },
59
+//     });
60
+
61
+//     if (!province) {
62
+//         console.error('❌ Province Papua Selatan not found. Seed it first.');
63
+//         return;
64
+//     }
65
+
66
+//     for (const name of cityNames) {
67
+//         await prisma.city.upsert({
68
+//             where: {
69
+//                 name_province_id: {
70
+//                     name,
71
+//                     province_id: province.id,
72
+//                 },
73
+//             },
74
+//             update: { updatedAt: timeLocal.now().toDate() },
75
+//             create: {
76
+//                 name,
77
+//                 province_id: province.id,
78
+//                 createdAt: timeLocal.now().toDate()
79
+//             },
80
+//         });
81
+//     }
82
+
83
+//     console.log('✅ Papua Selatan City seeded!.');
84
+// };

+ 0 - 45
prisma/seeders/city/PapuaTengahCitySeeder.js

@@ -1,45 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Deiyai',
6
-    'Kabupaten Dogiyai',
7
-    'Kabupaten Intan Jaya',
8
-    'Kabupaten Mimika',
9
-    'Kabupaten Nabire',
10
-    'Kabupaten Paniai',
11
-    'Kabupaten Puncak',
12
-    'Kabupaten Puncak Jaya'
13
-
14
-    // 8
15
-];
16
-
17
-exports.seedPapuaTengahCities = async () => {
18
-    const province = await prisma.province.findFirst({
19
-        where: { name: 'Papua Tengah' },
20
-    });
21
-
22
-    if (!province) {
23
-        console.error('❌ Province Papua Tengah not found. Seed it first.');
24
-        return;
25
-    }
26
-
27
-    for (const name of cityNames) {
28
-        await prisma.city.upsert({
29
-            where: {
30
-                name_province_id: {
31
-                    name,
32
-                    province_id: province.id,
33
-                },
34
-            },
35
-            update: { updatedAt: timeLocal.now().toDate() },
36
-            create: {
37
-                name,
38
-                province_id: province.id,
39
-                createdAt: timeLocal.now().toDate()
40
-            },
41
-        });
42
-    }
43
-
44
-    console.log('✅ Papua Tengah City seeded!.');
45
-};

+ 92 - 0
prisma/seeders/city/PapuaTengahCitySeeder.ts

@@ -0,0 +1,92 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Deiyai',
6
+    'Kabupaten Dogiyai',
7
+    'Kabupaten Intan Jaya',
8
+    'Kabupaten Mimika',
9
+    'Kabupaten Nabire',
10
+    'Kabupaten Paniai',
11
+    'Kabupaten Puncak',
12
+    'Kabupaten Puncak Jaya',
13
+];
14
+
15
+export const seedPapuaTengahCities = async (): Promise<void> => {
16
+    const province = await prisma.province.findFirst({
17
+        where: { name: 'Papua Tengah' },
18
+    });
19
+
20
+    if (!province) {
21
+        console.error('❌ Province Papua Tengah not found. Seed it first.');
22
+        return;
23
+    }
24
+
25
+    for (const name of cityNames) {
26
+        await prisma.city.upsert({
27
+            where: {
28
+                name_province_id: {
29
+                    name,
30
+                    province_id: province.id,
31
+                },
32
+            },
33
+            update: {
34
+                updatedAt: now().toDate(),
35
+            },
36
+            create: {
37
+                name,
38
+                province_id: province.id,
39
+                createdAt: now().toDate(),
40
+            },
41
+        });
42
+    }
43
+
44
+    console.log('✅ Papua Tengah City seeded!.');
45
+};
46
+
47
+
48
+// const prisma = require('../../../src/prisma/PrismaClient.js');
49
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
50
+
51
+// const cityNames = [
52
+//     'Kabupaten Deiyai',
53
+//     'Kabupaten Dogiyai',
54
+//     'Kabupaten Intan Jaya',
55
+//     'Kabupaten Mimika',
56
+//     'Kabupaten Nabire',
57
+//     'Kabupaten Paniai',
58
+//     'Kabupaten Puncak',
59
+//     'Kabupaten Puncak Jaya'
60
+
61
+//     // 8
62
+// ];
63
+
64
+// exports.seedPapuaTengahCities = async () => {
65
+//     const province = await prisma.province.findFirst({
66
+//         where: { name: 'Papua Tengah' },
67
+//     });
68
+
69
+//     if (!province) {
70
+//         console.error('❌ Province Papua Tengah not found. Seed it first.');
71
+//         return;
72
+//     }
73
+
74
+//     for (const name of cityNames) {
75
+//         await prisma.city.upsert({
76
+//             where: {
77
+//                 name_province_id: {
78
+//                     name,
79
+//                     province_id: province.id,
80
+//                 },
81
+//             },
82
+//             update: { updatedAt: timeLocal.now().toDate() },
83
+//             create: {
84
+//                 name,
85
+//                 province_id: province.id,
86
+//                 createdAt: timeLocal.now().toDate()
87
+//             },
88
+//         });
89
+//     }
90
+
91
+//     console.log('✅ Papua Tengah City seeded!.');
92
+// };

+ 0 - 49
prisma/seeders/city/RiauCitySeeder.js

@@ -1,49 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bengkalis',
6
-    'Kabupaten Indragiri Hilir',
7
-    'Kabupaten Indragiri Hulu',
8
-    'Kabupaten Kampar',
9
-    'Kabupaten Kepulauan Meranti',
10
-    'Kabupaten Kuantan Singingi',
11
-    'Kabupaten Pelalawan',
12
-    'Kabupaten Rokan Hilir',
13
-    'Kabupaten Rokan Hulu',
14
-    'Kabupaten Siak',
15
-    'Kota Dumai',
16
-    'Kota Pekanbaru'
17
-
18
-    // 12
19
-];
20
-
21
-exports.seedRiauCities = async () => {
22
-    const province = await prisma.province.findFirst({
23
-        where: { name: 'Riau' },
24
-    });
25
-
26
-    if (!province) {
27
-        console.error('❌ Province Riau not found. Seed it first.');
28
-        return;
29
-    }
30
-
31
-    for (const name of cityNames) {
32
-        await prisma.city.upsert({
33
-            where: {
34
-                name_province_id: {
35
-                    name,
36
-                    province_id: province.id,
37
-                },
38
-            },
39
-            update: { updatedAt: timeLocal.now().toDate() },
40
-            create: {
41
-                name,
42
-                province_id: province.id,
43
-                createdAt: timeLocal.now().toDate()
44
-            },
45
-        });
46
-    }
47
-
48
-    console.log('✅ Riau City seeded!.');
49
-};

+ 100 - 0
prisma/seeders/city/RiauCitySeeder.ts

@@ -0,0 +1,100 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bengkalis',
6
+    'Kabupaten Indragiri Hilir',
7
+    'Kabupaten Indragiri Hulu',
8
+    'Kabupaten Kampar',
9
+    'Kabupaten Kepulauan Meranti',
10
+    'Kabupaten Kuantan Singingi',
11
+    'Kabupaten Pelalawan',
12
+    'Kabupaten Rokan Hilir',
13
+    'Kabupaten Rokan Hulu',
14
+    'Kabupaten Siak',
15
+    'Kota Dumai',
16
+    'Kota Pekanbaru'
17
+];
18
+
19
+export const seedRiauCities = async (): Promise<void> => {
20
+    const province = await prisma.province.findFirst({
21
+        where: { name: 'Riau' },
22
+    });
23
+
24
+    if (!province) {
25
+        console.error('❌ Province Riau not found. Seed it first.');
26
+        return;
27
+    }
28
+
29
+    for (const name of cityNames) {
30
+        await prisma.city.upsert({
31
+            where: {
32
+                // Pastikan kamu sudah buat @@unique([name, province_id]) di model City pada schema.prisma
33
+                name_province_id: {
34
+                    name,
35
+                    province_id: province.id,
36
+                },
37
+            },
38
+            update: {
39
+                updatedAt: now().toDate(),
40
+            },
41
+            create: {
42
+                name,
43
+                province_id: province.id,
44
+                createdAt: now().toDate(),
45
+            },
46
+        });
47
+    }
48
+
49
+    console.log('✅ Riau City seeded!.');
50
+};
51
+
52
+// const prisma = require('../../../src/prisma/PrismaClient.js');
53
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
54
+
55
+// const cityNames = [
56
+//     'Kabupaten Bengkalis',
57
+//     'Kabupaten Indragiri Hilir',
58
+//     'Kabupaten Indragiri Hulu',
59
+//     'Kabupaten Kampar',
60
+//     'Kabupaten Kepulauan Meranti',
61
+//     'Kabupaten Kuantan Singingi',
62
+//     'Kabupaten Pelalawan',
63
+//     'Kabupaten Rokan Hilir',
64
+//     'Kabupaten Rokan Hulu',
65
+//     'Kabupaten Siak',
66
+//     'Kota Dumai',
67
+//     'Kota Pekanbaru'
68
+
69
+//     // 12
70
+// ];
71
+
72
+// exports.seedRiauCities = async () => {
73
+//     const province = await prisma.province.findFirst({
74
+//         where: { name: 'Riau' },
75
+//     });
76
+
77
+//     if (!province) {
78
+//         console.error('❌ Province Riau not found. Seed it first.');
79
+//         return;
80
+//     }
81
+
82
+//     for (const name of cityNames) {
83
+//         await prisma.city.upsert({
84
+//             where: {
85
+//                 name_province_id: {
86
+//                     name,
87
+//                     province_id: province.id,
88
+//                 },
89
+//             },
90
+//             update: { updatedAt: timeLocal.now().toDate() },
91
+//             create: {
92
+//                 name,
93
+//                 province_id: province.id,
94
+//                 createdAt: timeLocal.now().toDate()
95
+//             },
96
+//         });
97
+//     }
98
+
99
+//     console.log('✅ Riau City seeded!.');
100
+// };

+ 0 - 43
prisma/seeders/city/SulawesiBaratCitySeeder.js

@@ -1,43 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Majene',
6
-    'Kabupaten Mamasa',
7
-    'Kabupaten Mamuju',
8
-    'Kabupaten Mamuju Tengah',
9
-    'Kabupaten Pasangkayu',
10
-    'Kabupaten Polewali Mandar'
11
-
12
-    // 6
13
-];
14
-
15
-exports.seedSulawesiBaratCities = async () => {
16
-    const province = await prisma.province.findFirst({
17
-        where: { name: 'Sulawesi Barat' },
18
-    });
19
-
20
-    if (!province) {
21
-        console.error('❌ Province Sulawesi Barat not found. Seed it first.');
22
-        return;
23
-    }
24
-
25
-    for (const name of cityNames) {
26
-        await prisma.city.upsert({
27
-            where: {
28
-                name_province_id: {
29
-                    name,
30
-                    province_id: province.id,
31
-                },
32
-            },
33
-            update: { updatedAt: timeLocal.now().toDate() },
34
-            create: {
35
-                name,
36
-                province_id: province.id,
37
-                createdAt: timeLocal.now().toDate()
38
-            },
39
-        });
40
-    }
41
-
42
-    console.log('✅ Sulawesi Barat City seeded!.');
43
-};

+ 88 - 0
prisma/seeders/city/SulawesiBaratCitySeeder.ts

@@ -0,0 +1,88 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Majene',
6
+    'Kabupaten Mamasa',
7
+    'Kabupaten Mamuju',
8
+    'Kabupaten Mamuju Tengah',
9
+    'Kabupaten Pasangkayu',
10
+    'Kabupaten Polewali Mandar'
11
+];
12
+
13
+export const seedSulawesiBaratCities = async (): Promise<void> => {
14
+    const province = await prisma.province.findFirst({
15
+        where: { name: 'Sulawesi Barat' },
16
+    });
17
+
18
+    if (!province) {
19
+        console.error('❌ Province Sulawesi Barat not found. Seed it first.');
20
+        return;
21
+    }
22
+
23
+    for (const name of cityNames) {
24
+        await prisma.city.upsert({
25
+            where: {
26
+                // Pastikan ada @@unique([name, province_id]) di model City di schema.prisma
27
+                name_province_id: {
28
+                    name,
29
+                    province_id: province.id,
30
+                },
31
+            },
32
+            update: {
33
+                updatedAt: now().toDate(),
34
+            },
35
+            create: {
36
+                name,
37
+                province_id: province.id,
38
+                createdAt: now().toDate(),
39
+            },
40
+        });
41
+    }
42
+
43
+    console.log('✅ Sulawesi Barat City seeded!.');
44
+};
45
+
46
+// const prisma = require('../../../src/prisma/PrismaClient.js');
47
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
48
+
49
+// const cityNames = [
50
+//     'Kabupaten Majene',
51
+//     'Kabupaten Mamasa',
52
+//     'Kabupaten Mamuju',
53
+//     'Kabupaten Mamuju Tengah',
54
+//     'Kabupaten Pasangkayu',
55
+//     'Kabupaten Polewali Mandar'
56
+
57
+//     // 6
58
+// ];
59
+
60
+// exports.seedSulawesiBaratCities = async () => {
61
+//     const province = await prisma.province.findFirst({
62
+//         where: { name: 'Sulawesi Barat' },
63
+//     });
64
+
65
+//     if (!province) {
66
+//         console.error('❌ Province Sulawesi Barat not found. Seed it first.');
67
+//         return;
68
+//     }
69
+
70
+//     for (const name of cityNames) {
71
+//         await prisma.city.upsert({
72
+//             where: {
73
+//                 name_province_id: {
74
+//                     name,
75
+//                     province_id: province.id,
76
+//                 },
77
+//             },
78
+//             update: { updatedAt: timeLocal.now().toDate() },
79
+//             create: {
80
+//                 name,
81
+//                 province_id: province.id,
82
+//                 createdAt: timeLocal.now().toDate()
83
+//             },
84
+//         });
85
+//     }
86
+
87
+//     console.log('✅ Sulawesi Barat City seeded!.');
88
+// };

+ 0 - 61
prisma/seeders/city/SulawesiSelatanCitySeeder.js

@@ -1,61 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bantaeng',
6
-    'Kabupaten Barru',
7
-    'Kabupaten Bone',
8
-    'Kabupaten Bulukumba',
9
-    'Kabupaten Enrekang',
10
-    'Kabupaten Gowa',
11
-    'Kabupaten Jeneponto',
12
-    'Kabupaten Kepulauan Selayar',
13
-    'Kabupaten Luwu',
14
-    'Kabupaten Luwu Timur',
15
-    'Kabupaten Luwu Utara',
16
-    'Kabupaten Maros',
17
-    'Kabupaten Pangkajene dan Kepulauan',
18
-    'Kabupaten Pinrang',
19
-    'Kabupaten Sidenreng Rappang',
20
-    'Kabupaten Sinjai',
21
-    'Kabupaten Soppeng',
22
-    'Kabupaten Takalar',
23
-    'Kabupaten Tana Toraja',
24
-    'Kabupaten Toraja Utara',
25
-    'Kabupaten Wajo',
26
-    'Kota Makassar',
27
-    'Kota Palopo',
28
-    'Kota Parepare'
29
-
30
-    // 24
31
-];
32
-
33
-exports.seedSulawesiSelatanCities = async () => {
34
-    const province = await prisma.province.findFirst({
35
-        where: { name: 'Sulawesi Selatan' },
36
-    });
37
-
38
-    if (!province) {
39
-        console.error('❌ Province Sulawesi Selatan not found. Seed it first.');
40
-        return;
41
-    }
42
-
43
-    for (const name of cityNames) {
44
-        await prisma.city.upsert({
45
-            where: {
46
-                name_province_id: {
47
-                    name,
48
-                    province_id: province.id,
49
-                },
50
-            },
51
-            update: { updatedAt: timeLocal.now().toDate() },
52
-            create: {
53
-                name,
54
-                province_id: province.id,
55
-                createdAt: timeLocal.now().toDate()
56
-            },
57
-        });
58
-    }
59
-
60
-    console.log('✅ Sulawesi Selatan City seeded!.');
61
-};

+ 124 - 0
prisma/seeders/city/SulawesiSelatanCitySeeder.ts

@@ -0,0 +1,124 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bantaeng',
6
+    'Kabupaten Barru',
7
+    'Kabupaten Bone',
8
+    'Kabupaten Bulukumba',
9
+    'Kabupaten Enrekang',
10
+    'Kabupaten Gowa',
11
+    'Kabupaten Jeneponto',
12
+    'Kabupaten Kepulauan Selayar',
13
+    'Kabupaten Luwu',
14
+    'Kabupaten Luwu Timur',
15
+    'Kabupaten Luwu Utara',
16
+    'Kabupaten Maros',
17
+    'Kabupaten Pangkajene dan Kepulauan',
18
+    'Kabupaten Pinrang',
19
+    'Kabupaten Sidenreng Rappang',
20
+    'Kabupaten Sinjai',
21
+    'Kabupaten Soppeng',
22
+    'Kabupaten Takalar',
23
+    'Kabupaten Tana Toraja',
24
+    'Kabupaten Toraja Utara',
25
+    'Kabupaten Wajo',
26
+    'Kota Makassar',
27
+    'Kota Palopo',
28
+    'Kota Parepare'
29
+];
30
+
31
+export const seedSulawesiSelatanCities = async (): Promise<void> => {
32
+    const province = await prisma.province.findFirst({
33
+        where: { name: 'Sulawesi Selatan' },
34
+    });
35
+
36
+    if (!province) {
37
+        console.error('❌ Province Sulawesi Selatan not found. Seed it first.');
38
+        return;
39
+    }
40
+
41
+    for (const name of cityNames) {
42
+        await prisma.city.upsert({
43
+            where: {
44
+                // Pastikan kombinasi ini unik di model City: @@unique([name, province_id], name: "name_province_id")
45
+                name_province_id: {
46
+                    name,
47
+                    province_id: province.id,
48
+                },
49
+            },
50
+            update: {
51
+                updatedAt: now().toDate(),
52
+            },
53
+            create: {
54
+                name,
55
+                province_id: province.id,
56
+                createdAt: now().toDate(),
57
+            },
58
+        });
59
+    }
60
+
61
+    console.log('✅ Sulawesi Selatan City seeded!.');
62
+};
63
+
64
+// const prisma = require('../../../src/prisma/PrismaClient.js');
65
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
66
+
67
+// const cityNames = [
68
+//     'Kabupaten Bantaeng',
69
+//     'Kabupaten Barru',
70
+//     'Kabupaten Bone',
71
+//     'Kabupaten Bulukumba',
72
+//     'Kabupaten Enrekang',
73
+//     'Kabupaten Gowa',
74
+//     'Kabupaten Jeneponto',
75
+//     'Kabupaten Kepulauan Selayar',
76
+//     'Kabupaten Luwu',
77
+//     'Kabupaten Luwu Timur',
78
+//     'Kabupaten Luwu Utara',
79
+//     'Kabupaten Maros',
80
+//     'Kabupaten Pangkajene dan Kepulauan',
81
+//     'Kabupaten Pinrang',
82
+//     'Kabupaten Sidenreng Rappang',
83
+//     'Kabupaten Sinjai',
84
+//     'Kabupaten Soppeng',
85
+//     'Kabupaten Takalar',
86
+//     'Kabupaten Tana Toraja',
87
+//     'Kabupaten Toraja Utara',
88
+//     'Kabupaten Wajo',
89
+//     'Kota Makassar',
90
+//     'Kota Palopo',
91
+//     'Kota Parepare'
92
+
93
+//     // 24
94
+// ];
95
+
96
+// exports.seedSulawesiSelatanCities = async () => {
97
+//     const province = await prisma.province.findFirst({
98
+//         where: { name: 'Sulawesi Selatan' },
99
+//     });
100
+
101
+//     if (!province) {
102
+//         console.error('❌ Province Sulawesi Selatan not found. Seed it first.');
103
+//         return;
104
+//     }
105
+
106
+//     for (const name of cityNames) {
107
+//         await prisma.city.upsert({
108
+//             where: {
109
+//                 name_province_id: {
110
+//                     name,
111
+//                     province_id: province.id,
112
+//                 },
113
+//             },
114
+//             update: { updatedAt: timeLocal.now().toDate() },
115
+//             create: {
116
+//                 name,
117
+//                 province_id: province.id,
118
+//                 createdAt: timeLocal.now().toDate()
119
+//             },
120
+//         });
121
+//     }
122
+
123
+//     console.log('✅ Sulawesi Selatan City seeded!.');
124
+// };

+ 0 - 50
prisma/seeders/city/SulawesiTengahCitySeeder.js

@@ -1,50 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Banggai',
6
-    'Kabupaten Banggai Kepulauan',
7
-    'Kabupaten Banggai Laut',
8
-    'Kabupaten Buol',
9
-    'Kabupaten Donggala',
10
-    'Kabupaten Morowali',
11
-    'Kabupaten Morowali Utara',
12
-    'Kabupaten Parigi Moutong',
13
-    'Kabupaten Poso',
14
-    'Kabupaten Sigi',
15
-    'Kabupaten Tojo Una-Una',
16
-    'Kabupaten Tolitoli',
17
-    'Kota Palu'
18
-
19
-    // 13
20
-];
21
-
22
-exports.seedSulawesiTengahCities = async () => {
23
-    const province = await prisma.province.findFirst({
24
-        where: { name: 'Sulawesi Tengah' },
25
-    });
26
-
27
-    if (!province) {
28
-        console.error('❌ Province Sulawesi Tengah not found. Seed it first.');
29
-        return;
30
-    }
31
-
32
-    for (const name of cityNames) {
33
-        await prisma.city.upsert({
34
-            where: {
35
-                name_province_id: {
36
-                    name,
37
-                    province_id: province.id,
38
-                },
39
-            },
40
-            update: { updatedAt: timeLocal.now().toDate() },
41
-            create: {
42
-                name,
43
-                province_id: province.id,
44
-                createdAt: timeLocal.now().toDate()
45
-            },
46
-        });
47
-    }
48
-
49
-    console.log('✅ Sulawesi Tengah City seeded!.');
50
-};

+ 102 - 0
prisma/seeders/city/SulawesiTengahCitySeeder.ts

@@ -0,0 +1,102 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Banggai',
6
+    'Kabupaten Banggai Kepulauan',
7
+    'Kabupaten Banggai Laut',
8
+    'Kabupaten Buol',
9
+    'Kabupaten Donggala',
10
+    'Kabupaten Morowali',
11
+    'Kabupaten Morowali Utara',
12
+    'Kabupaten Parigi Moutong',
13
+    'Kabupaten Poso',
14
+    'Kabupaten Sigi',
15
+    'Kabupaten Tojo Una-Una',
16
+    'Kabupaten Tolitoli',
17
+    'Kota Palu'
18
+];
19
+
20
+export const seedSulawesiTengahCities = async (): Promise<void> => {
21
+    const province = await prisma.province.findFirst({
22
+        where: { name: 'Sulawesi Tengah' },
23
+    });
24
+
25
+    if (!province) {
26
+        console.error('❌ Province Sulawesi Tengah not found. Seed it first.');
27
+        return;
28
+    }
29
+
30
+    for (const name of cityNames) {
31
+        await prisma.city.upsert({
32
+            where: {
33
+                // Harus ada constraint unik di schema.prisma: @@unique([name, province_id], name: "name_province_id")
34
+                name_province_id: {
35
+                    name,
36
+                    province_id: province.id,
37
+                },
38
+            },
39
+            update: {
40
+                updatedAt: now().toDate(),
41
+            },
42
+            create: {
43
+                name,
44
+                province_id: province.id,
45
+                createdAt: now().toDate(),
46
+            },
47
+        });
48
+    }
49
+
50
+    console.log('✅ Sulawesi Tengah City seeded!.');
51
+};
52
+
53
+// const prisma = require('../../../src/prisma/PrismaClient.js');
54
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
55
+
56
+// const cityNames = [
57
+//     'Kabupaten Banggai',
58
+//     'Kabupaten Banggai Kepulauan',
59
+//     'Kabupaten Banggai Laut',
60
+//     'Kabupaten Buol',
61
+//     'Kabupaten Donggala',
62
+//     'Kabupaten Morowali',
63
+//     'Kabupaten Morowali Utara',
64
+//     'Kabupaten Parigi Moutong',
65
+//     'Kabupaten Poso',
66
+//     'Kabupaten Sigi',
67
+//     'Kabupaten Tojo Una-Una',
68
+//     'Kabupaten Tolitoli',
69
+//     'Kota Palu'
70
+
71
+//     // 13
72
+// ];
73
+
74
+// exports.seedSulawesiTengahCities = async () => {
75
+//     const province = await prisma.province.findFirst({
76
+//         where: { name: 'Sulawesi Tengah' },
77
+//     });
78
+
79
+//     if (!province) {
80
+//         console.error('❌ Province Sulawesi Tengah not found. Seed it first.');
81
+//         return;
82
+//     }
83
+
84
+//     for (const name of cityNames) {
85
+//         await prisma.city.upsert({
86
+//             where: {
87
+//                 name_province_id: {
88
+//                     name,
89
+//                     province_id: province.id,
90
+//                 },
91
+//             },
92
+//             update: { updatedAt: timeLocal.now().toDate() },
93
+//             create: {
94
+//                 name,
95
+//                 province_id: province.id,
96
+//                 createdAt: timeLocal.now().toDate()
97
+//             },
98
+//         });
99
+//     }
100
+
101
+//     console.log('✅ Sulawesi Tengah City seeded!.');
102
+// };

+ 0 - 54
prisma/seeders/city/SulawesiTenggaraCitySeeder.js

@@ -1,54 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bombana',
6
-    'Kabupaten Buton',
7
-    'Kabupaten Buton Selatan',
8
-    'Kabupaten Buton Tengah',
9
-    'Kabupaten Buton Utara',
10
-    'Kabupaten Kolaka',
11
-    'Kabupaten Kolaka Timur',
12
-    'Kabupaten Kolaka Utara',
13
-    'Kabupaten Konawe',
14
-    'Kabupaten Konawe Kepulauan',
15
-    'Kabupaten Konawe Selatan',
16
-    'Kabupaten Konawe Utara',
17
-    'Kabupaten Muna',
18
-    'Kabupaten Muna Barat',
19
-    'Kabupaten Wakatobi',
20
-    'Kota Baubau',
21
-    'Kota Kendari'
22
-
23
-    // 17
24
-];
25
-
26
-exports.seedSulawesiTenggaraCities = async () => {
27
-    const province = await prisma.province.findFirst({
28
-        where: { name: 'Sulawesi Tenggara' },
29
-    });
30
-
31
-    if (!province) {
32
-        console.error('❌ Province Sulawesi Tenggara not found. Seed it first.');
33
-        return;
34
-    }
35
-
36
-    for (const name of cityNames) {
37
-        await prisma.city.upsert({
38
-            where: {
39
-                name_province_id: {
40
-                    name,
41
-                    province_id: province.id,
42
-                },
43
-            },
44
-            update: { updatedAt: timeLocal.now().toDate() },
45
-            create: {
46
-                name,
47
-                province_id: province.id,
48
-                createdAt: timeLocal.now().toDate()
49
-            },
50
-        });
51
-    }
52
-
53
-    console.log('✅ Sulawesi Tenggara City seeded!.');
54
-};

+ 110 - 0
prisma/seeders/city/SulawesiTenggaraCitySeeder.ts

@@ -0,0 +1,110 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bombana',
6
+    'Kabupaten Buton',
7
+    'Kabupaten Buton Selatan',
8
+    'Kabupaten Buton Tengah',
9
+    'Kabupaten Buton Utara',
10
+    'Kabupaten Kolaka',
11
+    'Kabupaten Kolaka Timur',
12
+    'Kabupaten Kolaka Utara',
13
+    'Kabupaten Konawe',
14
+    'Kabupaten Konawe Kepulauan',
15
+    'Kabupaten Konawe Selatan',
16
+    'Kabupaten Konawe Utara',
17
+    'Kabupaten Muna',
18
+    'Kabupaten Muna Barat',
19
+    'Kabupaten Wakatobi',
20
+    'Kota Baubau',
21
+    'Kota Kendari'
22
+];
23
+
24
+export const seedSulawesiTenggaraCities = async (): Promise<void> => {
25
+    const province = await prisma.province.findFirst({
26
+        where: { name: 'Sulawesi Tenggara' },
27
+    });
28
+
29
+    if (!province) {
30
+        console.error('❌ Province Sulawesi Tenggara not found. Seed it first.');
31
+        return;
32
+    }
33
+
34
+    for (const name of cityNames) {
35
+        await prisma.city.upsert({
36
+            where: {
37
+                name_province_id: {
38
+                    name,
39
+                    province_id: province.id,
40
+                },
41
+            },
42
+            update: {
43
+                updatedAt: now().toDate(),
44
+            },
45
+            create: {
46
+                name,
47
+                province_id: province.id,
48
+                createdAt: now().toDate(),
49
+            },
50
+        });
51
+    }
52
+
53
+    console.log('✅ Sulawesi Tenggara City seeded!.');
54
+};
55
+
56
+
57
+// const prisma = require('../../../src/prisma/PrismaClient.js');
58
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
59
+
60
+// const cityNames = [
61
+//     'Kabupaten Bombana',
62
+//     'Kabupaten Buton',
63
+//     'Kabupaten Buton Selatan',
64
+//     'Kabupaten Buton Tengah',
65
+//     'Kabupaten Buton Utara',
66
+//     'Kabupaten Kolaka',
67
+//     'Kabupaten Kolaka Timur',
68
+//     'Kabupaten Kolaka Utara',
69
+//     'Kabupaten Konawe',
70
+//     'Kabupaten Konawe Kepulauan',
71
+//     'Kabupaten Konawe Selatan',
72
+//     'Kabupaten Konawe Utara',
73
+//     'Kabupaten Muna',
74
+//     'Kabupaten Muna Barat',
75
+//     'Kabupaten Wakatobi',
76
+//     'Kota Baubau',
77
+//     'Kota Kendari'
78
+
79
+//     // 17
80
+// ];
81
+
82
+// exports.seedSulawesiTenggaraCities = async () => {
83
+//     const province = await prisma.province.findFirst({
84
+//         where: { name: 'Sulawesi Tenggara' },
85
+//     });
86
+
87
+//     if (!province) {
88
+//         console.error('❌ Province Sulawesi Tenggara not found. Seed it first.');
89
+//         return;
90
+//     }
91
+
92
+//     for (const name of cityNames) {
93
+//         await prisma.city.upsert({
94
+//             where: {
95
+//                 name_province_id: {
96
+//                     name,
97
+//                     province_id: province.id,
98
+//                 },
99
+//             },
100
+//             update: { updatedAt: timeLocal.now().toDate() },
101
+//             create: {
102
+//                 name,
103
+//                 province_id: province.id,
104
+//                 createdAt: timeLocal.now().toDate()
105
+//             },
106
+//         });
107
+//     }
108
+
109
+//     console.log('✅ Sulawesi Tenggara City seeded!.');
110
+// };

+ 0 - 52
prisma/seeders/city/SulawesiUtaraCitySeeder.js

@@ -1,52 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bolaang Mongondow',
6
-    'Kabupaten Bolaang Mongondow Selatan',
7
-    'Kabupaten Bolaang Mongondow Timur',
8
-    'Kabupaten Bolaang Mongondow Utara',
9
-    'Kabupaten Kepulauan Sangihe',
10
-    'Kabupaten Kepulauan Siau Tagulandang Biaro (Sitaro)',
11
-    'Kabupaten Kepulauan Talaud',
12
-    'Kabupaten Minahasa',
13
-    'Kabupaten Minahasa Selatan',
14
-    'Kabupaten Minahasa Tenggara',
15
-    'Kabupaten Minahasa Utara',
16
-    'Kota Bitung',
17
-    'Kota Kotamobagu',
18
-    'Kota Manado',
19
-    'Kota Tomohon'
20
-
21
-    // 15
22
-];
23
-
24
-exports.seedSulawesiUtaraCities = async () => {
25
-    const province = await prisma.province.findFirst({
26
-        where: { name: 'Sulawesi Utara' },
27
-    });
28
-
29
-    if (!province) {
30
-        console.error('❌ Province Sulawesi Utara not found. Seed it first.');
31
-        return;
32
-    }
33
-
34
-    for (const name of cityNames) {
35
-        await prisma.city.upsert({
36
-            where: {
37
-                name_province_id: {
38
-                    name,
39
-                    province_id: province.id,
40
-                },
41
-            },
42
-            update: { updatedAt: timeLocal.now().toDate() },
43
-            create: {
44
-                name,
45
-                province_id: province.id,
46
-                createdAt: timeLocal.now().toDate()
47
-            },
48
-        });
49
-    }
50
-
51
-    console.log('✅ Sulawesi Utara City seeded!.');
52
-};

+ 105 - 0
prisma/seeders/city/SulawesiUtaraCitySeeder.ts

@@ -0,0 +1,105 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bolaang Mongondow',
6
+    'Kabupaten Bolaang Mongondow Selatan',
7
+    'Kabupaten Bolaang Mongondow Timur',
8
+    'Kabupaten Bolaang Mongondow Utara',
9
+    'Kabupaten Kepulauan Sangihe',
10
+    'Kabupaten Kepulauan Siau Tagulandang Biaro (Sitaro)',
11
+    'Kabupaten Kepulauan Talaud',
12
+    'Kabupaten Minahasa',
13
+    'Kabupaten Minahasa Selatan',
14
+    'Kabupaten Minahasa Tenggara',
15
+    'Kabupaten Minahasa Utara',
16
+    'Kota Bitung',
17
+    'Kota Kotamobagu',
18
+    'Kota Manado',
19
+    'Kota Tomohon'
20
+];
21
+
22
+export const seedSulawesiUtaraCities = async (): Promise<void> => {
23
+    const province = await prisma.province.findFirst({
24
+        where: { name: 'Sulawesi Utara' },
25
+    });
26
+
27
+    if (!province) {
28
+        console.error('❌ Province Sulawesi Utara not found. Seed it first.');
29
+        return;
30
+    }
31
+
32
+    for (const name of cityNames) {
33
+        await prisma.city.upsert({
34
+            where: {
35
+                name_province_id: {
36
+                    name,
37
+                    province_id: province.id,
38
+                },
39
+            },
40
+            update: {
41
+                updatedAt: now().toDate(),
42
+            },
43
+            create: {
44
+                name,
45
+                province_id: province.id,
46
+                createdAt: now().toDate(),
47
+            },
48
+        });
49
+    }
50
+
51
+    console.log('✅ Sulawesi Utara City seeded!.');
52
+};
53
+
54
+// const prisma = require('../../../src/prisma/PrismaClient.js');
55
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
56
+
57
+// const cityNames = [
58
+//     'Kabupaten Bolaang Mongondow',
59
+//     'Kabupaten Bolaang Mongondow Selatan',
60
+//     'Kabupaten Bolaang Mongondow Timur',
61
+//     'Kabupaten Bolaang Mongondow Utara',
62
+//     'Kabupaten Kepulauan Sangihe',
63
+//     'Kabupaten Kepulauan Siau Tagulandang Biaro (Sitaro)',
64
+//     'Kabupaten Kepulauan Talaud',
65
+//     'Kabupaten Minahasa',
66
+//     'Kabupaten Minahasa Selatan',
67
+//     'Kabupaten Minahasa Tenggara',
68
+//     'Kabupaten Minahasa Utara',
69
+//     'Kota Bitung',
70
+//     'Kota Kotamobagu',
71
+//     'Kota Manado',
72
+//     'Kota Tomohon'
73
+
74
+//     // 15
75
+// ];
76
+
77
+// exports.seedSulawesiUtaraCities = async () => {
78
+//     const province = await prisma.province.findFirst({
79
+//         where: { name: 'Sulawesi Utara' },
80
+//     });
81
+
82
+//     if (!province) {
83
+//         console.error('❌ Province Sulawesi Utara not found. Seed it first.');
84
+//         return;
85
+//     }
86
+
87
+//     for (const name of cityNames) {
88
+//         await prisma.city.upsert({
89
+//             where: {
90
+//                 name_province_id: {
91
+//                     name,
92
+//                     province_id: province.id,
93
+//                 },
94
+//             },
95
+//             update: { updatedAt: timeLocal.now().toDate() },
96
+//             create: {
97
+//                 name,
98
+//                 province_id: province.id,
99
+//                 createdAt: timeLocal.now().toDate()
100
+//             },
101
+//         });
102
+//     }
103
+
104
+//     console.log('✅ Sulawesi Utara City seeded!.');
105
+// };

+ 0 - 56
prisma/seeders/city/SumateraBaratCitySeeder.js

@@ -1,56 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Agam',
6
-    'Kabupaten Dharmasraya',
7
-    'Kabupaten Kepulauan Mentawai',
8
-    'Kabupaten Lima Puluh Kota',
9
-    'Kabupaten Padang Pariaman',
10
-    'Kabupaten Pasaman',
11
-    'Kabupaten Pasaman Barat',
12
-    'Kabupaten Pesisir Selatan',
13
-    'Kabupaten Sijunjung',
14
-    'Kabupaten Solok',
15
-    'Kabupaten Solok Selatan',
16
-    'Kabupaten Tanah Datar',
17
-    'Kota Bukittinggi',
18
-    'Kota Padang',
19
-    'Kota Padang Panjang',
20
-    'Kota Pariaman',
21
-    'Kota Payakumbuh',
22
-    'Kota Sawahlunto',
23
-    'Kota Solok'
24
-
25
-    // 19
26
-];
27
-
28
-exports.seedSumateraBaratCities = async () => {
29
-    const province = await prisma.province.findFirst({
30
-        where: { name: 'Sumatera Barat' },
31
-    });
32
-
33
-    if (!province) {
34
-        console.error('❌ Province Sumatera Barat not found. Seed it first.');
35
-        return;
36
-    }
37
-
38
-    for (const name of cityNames) {
39
-        await prisma.city.upsert({
40
-            where: {
41
-                name_province_id: {
42
-                    name,
43
-                    province_id: province.id,
44
-                },
45
-            },
46
-            update: { updatedAt: timeLocal.now().toDate() },
47
-            create: {
48
-                name,
49
-                province_id: province.id,
50
-                createdAt: timeLocal.now().toDate()
51
-            },
52
-        });
53
-    }
54
-
55
-    console.log('✅ Sumatera Barat City seeded!.');
56
-};

+ 113 - 0
prisma/seeders/city/SumateraBaratCitySeeder.ts

@@ -0,0 +1,113 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Agam',
6
+    'Kabupaten Dharmasraya',
7
+    'Kabupaten Kepulauan Mentawai',
8
+    'Kabupaten Lima Puluh Kota',
9
+    'Kabupaten Padang Pariaman',
10
+    'Kabupaten Pasaman',
11
+    'Kabupaten Pasaman Barat',
12
+    'Kabupaten Pesisir Selatan',
13
+    'Kabupaten Sijunjung',
14
+    'Kabupaten Solok',
15
+    'Kabupaten Solok Selatan',
16
+    'Kabupaten Tanah Datar',
17
+    'Kota Bukittinggi',
18
+    'Kota Padang',
19
+    'Kota Padang Panjang',
20
+    'Kota Pariaman',
21
+    'Kota Payakumbuh',
22
+    'Kota Sawahlunto',
23
+    'Kota Solok'
24
+];
25
+
26
+export const seedSumateraBaratCities = async (): Promise<void> => {
27
+    const province = await prisma.province.findFirst({
28
+        where: { name: 'Sumatera Barat' },
29
+    });
30
+
31
+    if (!province) {
32
+        console.error('❌ Province Sumatera Barat not found. Seed it first.');
33
+        return;
34
+    }
35
+
36
+    for (const name of cityNames) {
37
+        await prisma.city.upsert({
38
+            where: {
39
+                name_province_id: {
40
+                    name,
41
+                    province_id: province.id,
42
+                },
43
+            },
44
+            update: {
45
+                updatedAt: now().toDate(),
46
+            },
47
+            create: {
48
+                name,
49
+                province_id: province.id,
50
+                createdAt: now().toDate(),
51
+            },
52
+        });
53
+    }
54
+
55
+    console.log('✅ Sumatera Barat City seeded!.');
56
+};
57
+
58
+// const prisma = require('../../../src/prisma/PrismaClient.js');
59
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
60
+
61
+// const cityNames = [
62
+//     'Kabupaten Agam',
63
+//     'Kabupaten Dharmasraya',
64
+//     'Kabupaten Kepulauan Mentawai',
65
+//     'Kabupaten Lima Puluh Kota',
66
+//     'Kabupaten Padang Pariaman',
67
+//     'Kabupaten Pasaman',
68
+//     'Kabupaten Pasaman Barat',
69
+//     'Kabupaten Pesisir Selatan',
70
+//     'Kabupaten Sijunjung',
71
+//     'Kabupaten Solok',
72
+//     'Kabupaten Solok Selatan',
73
+//     'Kabupaten Tanah Datar',
74
+//     'Kota Bukittinggi',
75
+//     'Kota Padang',
76
+//     'Kota Padang Panjang',
77
+//     'Kota Pariaman',
78
+//     'Kota Payakumbuh',
79
+//     'Kota Sawahlunto',
80
+//     'Kota Solok'
81
+
82
+//     // 19
83
+// ];
84
+
85
+// exports.seedSumateraBaratCities = async () => {
86
+//     const province = await prisma.province.findFirst({
87
+//         where: { name: 'Sumatera Barat' },
88
+//     });
89
+
90
+//     if (!province) {
91
+//         console.error('❌ Province Sumatera Barat not found. Seed it first.');
92
+//         return;
93
+//     }
94
+
95
+//     for (const name of cityNames) {
96
+//         await prisma.city.upsert({
97
+//             where: {
98
+//                 name_province_id: {
99
+//                     name,
100
+//                     province_id: province.id,
101
+//                 },
102
+//             },
103
+//             update: { updatedAt: timeLocal.now().toDate() },
104
+//             create: {
105
+//                 name,
106
+//                 province_id: province.id,
107
+//                 createdAt: timeLocal.now().toDate()
108
+//             },
109
+//         });
110
+//     }
111
+
112
+//     console.log('✅ Sumatera Barat City seeded!.');
113
+// };

+ 0 - 54
prisma/seeders/city/SumateraSelatanCitySeeder.js

@@ -1,54 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Banyuasin',
6
-    'Kabupaten Empat Lawang',
7
-    'Kabupaten Lahat',
8
-    'Kabupaten Muara Enim',
9
-    'Kabupaten Musi Banyuasin',
10
-    'Kabupaten Musi Rawas',
11
-    'Kabupaten Musi Rawas Utara',
12
-    'Kabupaten Ogan Ilir',
13
-    'Kabupaten Ogan Komering Ilir',
14
-    'Kabupaten Ogan Komering Ulu',
15
-    'Kabupaten Ogan Komering Ulu Selatan',
16
-    'Kabupaten Ogan Komering Ulu Timur',
17
-    'Kabupaten Penukal Abab Lematang Ilir',
18
-    'Kota Lubuklinggau',
19
-    'Kota Pagar Alam',
20
-    'Kota Palembang',
21
-    'Kota Prabumulih'
22
-
23
-    // 17
24
-];
25
-
26
-exports.seedSumateraSelatanCities = async () => {
27
-    const province = await prisma.province.findFirst({
28
-        where: { name: 'Sumatera Selatan' },
29
-    });
30
-
31
-    if (!province) {
32
-        console.error('❌ Province Sumatera Selatan not found. Seed it first.');
33
-        return;
34
-    }
35
-
36
-    for (const name of cityNames) {
37
-        await prisma.city.upsert({
38
-            where: {
39
-                name_province_id: {
40
-                    name,
41
-                    province_id: province.id,
42
-                },
43
-            },
44
-            update: { updatedAt: timeLocal.now().toDate() },
45
-            create: {
46
-                name,
47
-                province_id: province.id,
48
-                createdAt: timeLocal.now().toDate()
49
-            },
50
-        });
51
-    }
52
-
53
-    console.log('✅ Sumatera Selatan City seeded!.');
54
-};

+ 110 - 0
prisma/seeders/city/SumateraSelatanCitySeeder.ts

@@ -0,0 +1,110 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Banyuasin',
6
+    'Kabupaten Empat Lawang',
7
+    'Kabupaten Lahat',
8
+    'Kabupaten Muara Enim',
9
+    'Kabupaten Musi Banyuasin',
10
+    'Kabupaten Musi Rawas',
11
+    'Kabupaten Musi Rawas Utara',
12
+    'Kabupaten Ogan Ilir',
13
+    'Kabupaten Ogan Komering Ilir',
14
+    'Kabupaten Ogan Komering Ulu',
15
+    'Kabupaten Ogan Komering Ulu Selatan',
16
+    'Kabupaten Ogan Komering Ulu Timur',
17
+    'Kabupaten Penukal Abab Lematang Ilir',
18
+    'Kota Lubuklinggau',
19
+    'Kota Pagar Alam',
20
+    'Kota Palembang',
21
+    'Kota Prabumulih'
22
+];
23
+
24
+export const seedSumateraSelatanCities = async (): Promise<void> => {
25
+    const province = await prisma.province.findFirst({
26
+        where: { name: 'Sumatera Selatan' },
27
+    });
28
+
29
+    if (!province) {
30
+        console.error('❌ Province Sumatera Selatan not found. Seed it first.');
31
+        return;
32
+    }
33
+
34
+    for (const name of cityNames) {
35
+        await prisma.city.upsert({
36
+            where: {
37
+                // Field composite unique [name, province_id] harus didefinisikan di schema.prisma
38
+                name_province_id: {
39
+                    name,
40
+                    province_id: province.id,
41
+                },
42
+            },
43
+            update: {
44
+                updatedAt: now().toDate(),
45
+            },
46
+            create: {
47
+                name,
48
+                province_id: province.id,
49
+                createdAt: now().toDate(),
50
+            },
51
+        });
52
+    }
53
+
54
+    console.log('✅ Sumatera Selatan City seeded!.');
55
+};
56
+
57
+// const prisma = require('../../../src/prisma/PrismaClient.js');
58
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
59
+
60
+// const cityNames = [
61
+//     'Kabupaten Banyuasin',
62
+//     'Kabupaten Empat Lawang',
63
+//     'Kabupaten Lahat',
64
+//     'Kabupaten Muara Enim',
65
+//     'Kabupaten Musi Banyuasin',
66
+//     'Kabupaten Musi Rawas',
67
+//     'Kabupaten Musi Rawas Utara',
68
+//     'Kabupaten Ogan Ilir',
69
+//     'Kabupaten Ogan Komering Ilir',
70
+//     'Kabupaten Ogan Komering Ulu',
71
+//     'Kabupaten Ogan Komering Ulu Selatan',
72
+//     'Kabupaten Ogan Komering Ulu Timur',
73
+//     'Kabupaten Penukal Abab Lematang Ilir',
74
+//     'Kota Lubuklinggau',
75
+//     'Kota Pagar Alam',
76
+//     'Kota Palembang',
77
+//     'Kota Prabumulih'
78
+
79
+//     // 17
80
+// ];
81
+
82
+// exports.seedSumateraSelatanCities = async () => {
83
+//     const province = await prisma.province.findFirst({
84
+//         where: { name: 'Sumatera Selatan' },
85
+//     });
86
+
87
+//     if (!province) {
88
+//         console.error('❌ Province Sumatera Selatan not found. Seed it first.');
89
+//         return;
90
+//     }
91
+
92
+//     for (const name of cityNames) {
93
+//         await prisma.city.upsert({
94
+//             where: {
95
+//                 name_province_id: {
96
+//                     name,
97
+//                     province_id: province.id,
98
+//                 },
99
+//             },
100
+//             update: { updatedAt: timeLocal.now().toDate() },
101
+//             create: {
102
+//                 name,
103
+//                 province_id: province.id,
104
+//                 createdAt: timeLocal.now().toDate()
105
+//             },
106
+//         });
107
+//     }
108
+
109
+//     console.log('✅ Sumatera Selatan City seeded!.');
110
+// };

+ 0 - 70
prisma/seeders/city/SumateraUtaraCitySeeder.js

@@ -1,70 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Asahan',
6
-    'Kabupaten Batu Bara',
7
-    'Kabupaten Dairi',
8
-    'Kabupaten Deli Serdang',
9
-    'Kabupaten Humbang Hasundutan',
10
-    'Kabupaten Karo',
11
-    'Kabupaten Labuhanbatu',
12
-    'Kabupaten Labuhanbatu Selatan',
13
-    'Kabupaten Labuhanbatu Utara',
14
-    'Kabupaten Langkat',
15
-    'Kabupaten Mandailing Natal',
16
-    'Kabupaten Nias',
17
-    'Kabupaten Nias Barat',
18
-    'Kabupaten Nias Selatan',
19
-    'Kabupaten Nias Utara',
20
-    'Kabupaten Padang Lawas',
21
-    'Kabupaten Padang Lawas Utara',
22
-    'Kabupaten Pakpak Bharat',
23
-    'Kabupaten Samosir',
24
-    'Kabupaten Serdang Bedagai',
25
-    'Kabupaten Simalungun',
26
-    'Kabupaten Tapanuli Selatan',
27
-    'Kabupaten Tapanuli Tengah',
28
-    'Kabupaten Tapanuli Utara',
29
-    'Kabupaten Toba',
30
-    'Kota Binjai',
31
-    'Kota Gunungsitoli',
32
-    'Kota Medan',
33
-    'Kota Padangsidimpuan',
34
-    'Kota Pematangsiantar',
35
-    'Kota Sibolga',
36
-    'Kota Tanjungbalai',
37
-    'Kota Tebing Tinggi'
38
-
39
-    // 33
40
-];
41
-
42
-exports.seedSumateraUtaraCities = async () => {
43
-    const province = await prisma.province.findFirst({
44
-        where: { name: 'Sumatera Utara' },
45
-    });
46
-
47
-    if (!province) {
48
-        console.error('❌ Province Sumatera Utara not found. Seed it first.');
49
-        return;
50
-    }
51
-
52
-    for (const name of cityNames) {
53
-        await prisma.city.upsert({
54
-            where: {
55
-                name_province_id: {
56
-                    name,
57
-                    province_id: province.id,
58
-                },
59
-            },
60
-            update: { updatedAt: timeLocal.now().toDate() },
61
-            create: {
62
-                name,
63
-                province_id: province.id,
64
-                createdAt: timeLocal.now().toDate()
65
-            },
66
-        });
67
-    }
68
-
69
-    console.log('✅ Sumatera Utara City seeded!.');
70
-};

+ 142 - 0
prisma/seeders/city/SumateraUtaraCitySeeder.ts

@@ -0,0 +1,142 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Asahan',
6
+    'Kabupaten Batu Bara',
7
+    'Kabupaten Dairi',
8
+    'Kabupaten Deli Serdang',
9
+    'Kabupaten Humbang Hasundutan',
10
+    'Kabupaten Karo',
11
+    'Kabupaten Labuhanbatu',
12
+    'Kabupaten Labuhanbatu Selatan',
13
+    'Kabupaten Labuhanbatu Utara',
14
+    'Kabupaten Langkat',
15
+    'Kabupaten Mandailing Natal',
16
+    'Kabupaten Nias',
17
+    'Kabupaten Nias Barat',
18
+    'Kabupaten Nias Selatan',
19
+    'Kabupaten Nias Utara',
20
+    'Kabupaten Padang Lawas',
21
+    'Kabupaten Padang Lawas Utara',
22
+    'Kabupaten Pakpak Bharat',
23
+    'Kabupaten Samosir',
24
+    'Kabupaten Serdang Bedagai',
25
+    'Kabupaten Simalungun',
26
+    'Kabupaten Tapanuli Selatan',
27
+    'Kabupaten Tapanuli Tengah',
28
+    'Kabupaten Tapanuli Utara',
29
+    'Kabupaten Toba',
30
+    'Kota Binjai',
31
+    'Kota Gunungsitoli',
32
+    'Kota Medan',
33
+    'Kota Padangsidimpuan',
34
+    'Kota Pematangsiantar',
35
+    'Kota Sibolga',
36
+    'Kota Tanjungbalai',
37
+    'Kota Tebing Tinggi'
38
+];
39
+
40
+export const seedSumateraUtaraCities = async (): Promise<void> => {
41
+    const province = await prisma.province.findFirst({
42
+        where: { name: 'Sumatera Utara' },
43
+    });
44
+
45
+    if (!province) {
46
+        console.error('❌ Province Sumatera Utara not found. Seed it first.');
47
+        return;
48
+    }
49
+
50
+    for (const name of cityNames) {
51
+        await prisma.city.upsert({
52
+            where: {
53
+                name_province_id: {
54
+                    name,
55
+                    province_id: province.id,
56
+                },
57
+            },
58
+            update: {
59
+                updatedAt: now().toDate(),
60
+            },
61
+            create: {
62
+                name,
63
+                province_id: province.id,
64
+                createdAt: now().toDate(),
65
+            },
66
+        });
67
+    }
68
+
69
+    console.log('✅ Sumatera Utara City seeded!.');
70
+};
71
+
72
+
73
+// const prisma = require('../../../src/prisma/PrismaClient.js');
74
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
75
+
76
+// const cityNames = [
77
+//     'Kabupaten Asahan',
78
+//     'Kabupaten Batu Bara',
79
+//     'Kabupaten Dairi',
80
+//     'Kabupaten Deli Serdang',
81
+//     'Kabupaten Humbang Hasundutan',
82
+//     'Kabupaten Karo',
83
+//     'Kabupaten Labuhanbatu',
84
+//     'Kabupaten Labuhanbatu Selatan',
85
+//     'Kabupaten Labuhanbatu Utara',
86
+//     'Kabupaten Langkat',
87
+//     'Kabupaten Mandailing Natal',
88
+//     'Kabupaten Nias',
89
+//     'Kabupaten Nias Barat',
90
+//     'Kabupaten Nias Selatan',
91
+//     'Kabupaten Nias Utara',
92
+//     'Kabupaten Padang Lawas',
93
+//     'Kabupaten Padang Lawas Utara',
94
+//     'Kabupaten Pakpak Bharat',
95
+//     'Kabupaten Samosir',
96
+//     'Kabupaten Serdang Bedagai',
97
+//     'Kabupaten Simalungun',
98
+//     'Kabupaten Tapanuli Selatan',
99
+//     'Kabupaten Tapanuli Tengah',
100
+//     'Kabupaten Tapanuli Utara',
101
+//     'Kabupaten Toba',
102
+//     'Kota Binjai',
103
+//     'Kota Gunungsitoli',
104
+//     'Kota Medan',
105
+//     'Kota Padangsidimpuan',
106
+//     'Kota Pematangsiantar',
107
+//     'Kota Sibolga',
108
+//     'Kota Tanjungbalai',
109
+//     'Kota Tebing Tinggi'
110
+
111
+//     // 33
112
+// ];
113
+
114
+// exports.seedSumateraUtaraCities = async () => {
115
+//     const province = await prisma.province.findFirst({
116
+//         where: { name: 'Sumatera Utara' },
117
+//     });
118
+
119
+//     if (!province) {
120
+//         console.error('❌ Province Sumatera Utara not found. Seed it first.');
121
+//         return;
122
+//     }
123
+
124
+//     for (const name of cityNames) {
125
+//         await prisma.city.upsert({
126
+//             where: {
127
+//                 name_province_id: {
128
+//                     name,
129
+//                     province_id: province.id,
130
+//                 },
131
+//             },
132
+//             update: { updatedAt: timeLocal.now().toDate() },
133
+//             create: {
134
+//                 name,
135
+//                 province_id: province.id,
136
+//                 createdAt: timeLocal.now().toDate()
137
+//             },
138
+//         });
139
+//     }
140
+
141
+//     console.log('✅ Sumatera Utara City seeded!.');
142
+// };

+ 0 - 61
src/controllers/admin/CityController.js

@@ -1,61 +0,0 @@
1
-const { CityCollection } = require('../../resources/admin/city/CityCollection.js');
2
-const { CityResource } = require('../../resources/admin/city/CityResource.js');
3
-const cityService = require('../../services/admin/CityService.js');
4
-const { PaginationParam } = require('../../utils/PaginationParams.js');
5
-const { errorResponse, messageSuccessResponse } = require('../../utils/Response.js');
6
-const { validateStoreCityRequest, validateUpdateCityRequest } = require('../../validators/admin/city/CityValidators.js');
7
-
8
-exports.getAllCity = async (req, res) => {
9
-    try {
10
-        const { page, limit, search, sortBy, orderBy } = PaginationParam(req);
11
-
12
-        const { cities, total } = await cityService.getAllCityService({
13
-            page, limit, search, sortBy, orderBy
14
-        });
15
-
16
-        return CityCollection(req, res, cities, total, page, limit, 'City data successfully retrieved');
17
-    } catch (err) {
18
-        return errorResponse(res, err);
19
-    }
20
-};
21
-
22
-exports.showCity = async (req, res) => {
23
-    try {
24
-        const id = req.params.id;
25
-        const data = await cityService.showCityService(id);
26
-        return CityResource(res, data, 'Success show city');
27
-    } catch (err) {
28
-        return errorResponse(res, err);
29
-    }
30
-};
31
-
32
-exports.storeCity = async (req, res) => {
33
-    try {
34
-        const validatedData = validateStoreCityRequest(req.body);
35
-        await cityService.storeCityService(validatedData, req);
36
-        return messageSuccessResponse(res, 'Success added city', 201);
37
-    } catch (err) {
38
-        return errorResponse(res, err);
39
-    }
40
-}
41
-
42
-exports.updateCity = async (req, res) => {
43
-    try {
44
-        const id = req.params.id;
45
-        const validatedData = validateUpdateCityRequest(req.body);
46
-        await cityService.updateCityService(validatedData, id, req);
47
-        return messageSuccessResponse(res, 'Success update city');
48
-    } catch (err) {
49
-        return errorResponse(res, err);
50
-    }
51
-}
52
-
53
-exports.deleteCity = async (req, res) => {
54
-    try {
55
-        const id = req.params.id;
56
-        await cityService.deleteCityService(id, req);
57
-        return messageSuccessResponse(res, 'Success delete city');
58
-    } catch (err) {
59
-        return errorResponse(res, err);
60
-    }
61
-};

+ 134 - 0
src/controllers/admin/CityController.ts

@@ -0,0 +1,134 @@
1
+import { Request, Response } from 'express';
2
+import { CityCollection } from '../../resources/admin/city/CityCollection';
3
+import { CityResource } from '../../resources/admin/city/CityResource';
4
+import {
5
+    getAllCityService,
6
+    showCityService,
7
+    storeCityService,
8
+    updateCityService,
9
+    deleteCityService
10
+} from '../../services/admin/CityService';
11
+import { PaginationParam } from '../../utils/PaginationParams';
12
+import { errorResponse, messageSuccessResponse } from '../../utils/Response';
13
+import {
14
+    validateStoreCityRequest,
15
+    // validateUpdateCityRequest,
16
+} from '../../validators/admin/city/CityValidators';
17
+
18
+// interface CustomRequest extends Request {
19
+//     tokenData?: any;
20
+// }
21
+
22
+export const getAllCity = async (req: Request, res: Response): Promise<Response> => {
23
+    try {
24
+        const { page, limit, search, sortBy, orderBy } = PaginationParam(req);
25
+        const { cities, total } = await getAllCityService({ page, limit, search, sortBy, orderBy });
26
+
27
+        return CityCollection(req, res, cities, total, page, limit, 'City data successfully retrieved');
28
+    } catch (err) {
29
+        return errorResponse(res, err);
30
+    }
31
+};
32
+
33
+export const showCity = async (req: Request, res: Response): Promise<Response> => {
34
+    try {
35
+        const id = req.params.id;
36
+        const data = await showCityService(id);
37
+        return CityResource(res, data, 'Success show city');
38
+    } catch (err) {
39
+        return errorResponse(res, err);
40
+    }
41
+};
42
+
43
+export const storeCity = async (req: Request, res: Response): Promise<Response> => {
44
+    try {
45
+        const validatedData = validateStoreCityRequest(req.body);
46
+        await storeCityService(validatedData, req);
47
+        return messageSuccessResponse(res, 'Success added city', 201);
48
+    } catch (err) {
49
+        return errorResponse(res, err);
50
+    }
51
+};
52
+
53
+export const updateCity = async (req: Request, res: Response): Promise<Response> => {
54
+    try {
55
+        const id = req.params.id;
56
+        // const validatedData = validateUpdateCityRequest(req.body);
57
+        // await updateCityService(validatedData, id, req);
58
+        return messageSuccessResponse(res, 'Success update city');
59
+    } catch (err) {
60
+        return errorResponse(res, err);
61
+    }
62
+};
63
+
64
+export const deleteCity = async (req: Request, res: Response): Promise<Response> => {
65
+    try {
66
+        const id = req.params.id;
67
+        await deleteCityService(id, req);
68
+        return messageSuccessResponse(res, 'Success delete city');
69
+    } catch (err) {
70
+        return errorResponse(res, err);
71
+    }
72
+};
73
+
74
+// const { CityCollection } = require('../../resources/admin/city/CityCollection.js');
75
+// const { CityResource } = require('../../resources/admin/city/CityResource.js');
76
+// const cityService = require('../../services/admin/CityService.js');
77
+// const { PaginationParam } = require('../../utils/PaginationParams.js');
78
+// const { errorResponse, messageSuccessResponse } = require('../../utils/Response.js');
79
+// const { validateStoreCityRequest, validateUpdateCityRequest } = require('../../validators/admin/city/CityValidators.js');
80
+
81
+// exports.getAllCity = async (req, res) => {
82
+//     try {
83
+//         const { page, limit, search, sortBy, orderBy } = PaginationParam(req);
84
+
85
+//         const { cities, total } = await cityService.getAllCityService({
86
+//             page, limit, search, sortBy, orderBy
87
+//         });
88
+
89
+//         return CityCollection(req, res, cities, total, page, limit, 'City data successfully retrieved');
90
+//     } catch (err) {
91
+//         return errorResponse(res, err);
92
+//     }
93
+// };
94
+
95
+// exports.showCity = async (req, res) => {
96
+//     try {
97
+//         const id = req.params.id;
98
+//         const data = await cityService.showCityService(id);
99
+//         return CityResource(res, data, 'Success show city');
100
+//     } catch (err) {
101
+//         return errorResponse(res, err);
102
+//     }
103
+// };
104
+
105
+// exports.storeCity = async (req, res) => {
106
+//     try {
107
+//         const validatedData = validateStoreCityRequest(req.body);
108
+//         await cityService.storeCityService(validatedData, req);
109
+//         return messageSuccessResponse(res, 'Success added city', 201);
110
+//     } catch (err) {
111
+//         return errorResponse(res, err);
112
+//     }
113
+// }
114
+
115
+// exports.updateCity = async (req, res) => {
116
+//     try {
117
+//         const id = req.params.id;
118
+//         const validatedData = validateUpdateCityRequest(req.body);
119
+//         await cityService.updateCityService(validatedData, id, req);
120
+//         return messageSuccessResponse(res, 'Success update city');
121
+//     } catch (err) {
122
+//         return errorResponse(res, err);
123
+//     }
124
+// }
125
+
126
+// exports.deleteCity = async (req, res) => {
127
+//     try {
128
+//         const id = req.params.id;
129
+//         await cityService.deleteCityService(id, req);
130
+//         return messageSuccessResponse(res, 'Success delete city');
131
+//     } catch (err) {
132
+//         return errorResponse(res, err);
133
+//     }
134
+// };

+ 0 - 61
src/controllers/admin/ProvinceController.js

@@ -1,61 +0,0 @@
1
-const { ProvinceCollection } = require('../../resources/admin/province/ProvinceCollection.js');
2
-const { ProvinceResource } = require('../../resources/admin/province/ProvinceResource.js');
3
-const provinceService = require('../../services/admin/ProvinceService.js');
4
-const { PaginationParam } = require('../../utils/PaginationParams.js');
5
-const { errorResponse, messageSuccessResponse } = require('../../utils/Response.js');
6
-const { validateStoreProvinceRequest } = require('../../validators/admin/province/ProvinceValidators.js');
7
-
8
-exports.getAllProvince = async (req, res) => {
9
-    try {
10
-        const { page, limit, search, sortBy, orderBy } = PaginationParam(req);
11
-
12
-        const { provinces, total } = await provinceService.getAllProvinceService({
13
-            page, limit, search, sortBy, orderBy
14
-        });
15
-
16
-        return ProvinceCollection(req, res, provinces, total, page, limit, 'Province data successfully retrieved');
17
-    } catch (err) {
18
-        return errorResponse(res, err);
19
-    }
20
-};
21
-
22
-exports.showProvince = async (req, res) => {
23
-    try {
24
-        const id = req.params.id;
25
-        const data = await provinceService.showProvinceService(id);
26
-        return ProvinceResource(res, data, 'Success show province');
27
-    } catch (err) {
28
-        return errorResponse(res, err);
29
-    }
30
-};
31
-
32
-exports.storeProvince = async (req, res) => {
33
-    try {
34
-        const validatedData = validateStoreProvinceRequest(req.body);
35
-        await provinceService.storeProvinceService(validatedData, req);
36
-        return messageSuccessResponse(res, 'Success added province', 201);
37
-    } catch (err) {
38
-        return errorResponse(res, err);
39
-    }
40
-}
41
-
42
-exports.updateProvince = async (req, res) => {
43
-    try {
44
-        const id = req.params.id;
45
-        const validatedData = validateStoreProvinceRequest(req.body);
46
-        await provinceService.updateProvinceService(validatedData, id, req);
47
-        return messageSuccessResponse(res, 'Success update province');
48
-    } catch (err) {
49
-        return errorResponse(res, err);
50
-    }
51
-}
52
-
53
-exports.deleteProvince = async (req, res) => {
54
-    try {
55
-        const id = req.params.id;
56
-        await provinceService.deleteProvinceService(id, req);
57
-        return messageSuccessResponse(res, 'Success delete province');
58
-    } catch (err) {
59
-        return errorResponse(res, err);
60
-    }
61
-};

+ 125 - 0
src/controllers/admin/ProvinceController.ts

@@ -0,0 +1,125 @@
1
+import { Request, Response } from 'express';
2
+import { ProvinceCollection } from '../../resources/admin/province/ProvinceCollection';
3
+import { ProvinceResource } from '../../resources/admin/province/ProvinceResource';
4
+import { getAllProvinceService, storeProvinceService, showProvinceService, updateProvinceService, deleteProvinceService } from '../../services/admin/ProvinceService';
5
+import { PaginationParam } from '../../utils/PaginationParams';
6
+import { errorResponse, messageSuccessResponse } from '../../utils/Response';
7
+import { validateStoreProvinceRequest } from '../../validators/admin/province/ProvinceValidators';
8
+
9
+export const getAllProvince = async (req: Request, res: Response): Promise<Response> => {
10
+    try {
11
+        const { page, limit, search, sortBy, orderBy } = PaginationParam(req);
12
+
13
+        const { provinces, total } = await getAllProvinceService({
14
+            page, limit, search, sortBy, orderBy
15
+        });
16
+
17
+        return ProvinceCollection(req, res, provinces, total, page, limit, 'Province data successfully retrieved');
18
+    } catch (err) {
19
+        return errorResponse(res, err);
20
+    }
21
+};
22
+
23
+export const showProvince = async (req: Request, res: Response): Promise<Response> => {
24
+    try {
25
+        const id = req.params.id;
26
+        const data = await showProvinceService(id);
27
+        return ProvinceResource(res, data, 'Success show province');
28
+    } catch (err) {
29
+        return errorResponse(res, err);
30
+    }
31
+};
32
+
33
+export const storeProvince = async (req: Request, res: Response): Promise<Response> => {
34
+    try {
35
+        const validatedData = validateStoreProvinceRequest(req.body);
36
+        await storeProvinceService(validatedData, req);
37
+        return messageSuccessResponse(res, 'Success added province', 201);
38
+    } catch (err) {
39
+        return errorResponse(res, err);
40
+    }
41
+};
42
+
43
+export const updateProvince = async (req: Request, res: Response): Promise<Response> => {
44
+    try {
45
+        const id = req.params.id;
46
+        const validatedData = validateStoreProvinceRequest(req.body);
47
+        await updateProvinceService(validatedData, id, req);
48
+        return messageSuccessResponse(res, 'Success update province');
49
+    } catch (err) {
50
+        return errorResponse(res, err);
51
+    }
52
+};
53
+
54
+export const deleteProvince = async (req: Request, res: Response): Promise<Response> => {
55
+    try {
56
+        const id = req.params.id;
57
+        await deleteProvinceService(id, req);
58
+        return messageSuccessResponse(res, 'Success delete province');
59
+    } catch (err) {
60
+        return errorResponse(res, err);
61
+    }
62
+};
63
+
64
+
65
+// const { ProvinceCollection } = require('../../resources/admin/province/ProvinceCollection.js');
66
+// const { ProvinceResource } = require('../../resources/admin/province/ProvinceResource.js');
67
+// const provinceService = require('../../services/admin/ProvinceService.js');
68
+// const { PaginationParam } = require('../../utils/PaginationParams.js');
69
+// const { errorResponse, messageSuccessResponse } = require('../../utils/Response.js');
70
+// const { validateStoreProvinceRequest } = require('../../validators/admin/province/ProvinceValidators.js');
71
+
72
+// exports.getAllProvince = async (req, res) => {
73
+//     try {
74
+//         const { page, limit, search, sortBy, orderBy } = PaginationParam(req);
75
+
76
+//         const { provinces, total } = await provinceService.getAllProvinceService({
77
+//             page, limit, search, sortBy, orderBy
78
+//         });
79
+
80
+//         return ProvinceCollection(req, res, provinces, total, page, limit, 'Province data successfully retrieved');
81
+//     } catch (err) {
82
+//         return errorResponse(res, err);
83
+//     }
84
+// };
85
+
86
+// exports.showProvince = async (req, res) => {
87
+//     try {
88
+//         const id = req.params.id;
89
+//         const data = await provinceService.showProvinceService(id);
90
+//         return ProvinceResource(res, data, 'Success show province');
91
+//     } catch (err) {
92
+//         return errorResponse(res, err);
93
+//     }
94
+// };
95
+
96
+// exports.storeProvince = async (req, res) => {
97
+//     try {
98
+//         const validatedData = validateStoreProvinceRequest(req.body);
99
+//         await provinceService.storeProvinceService(validatedData, req);
100
+//         return messageSuccessResponse(res, 'Success added province', 201);
101
+//     } catch (err) {
102
+//         return errorResponse(res, err);
103
+//     }
104
+// }
105
+
106
+// exports.updateProvince = async (req, res) => {
107
+//     try {
108
+//         const id = req.params.id;
109
+//         const validatedData = validateStoreProvinceRequest(req.body);
110
+//         await provinceService.updateProvinceService(validatedData, id, req);
111
+//         return messageSuccessResponse(res, 'Success update province');
112
+//     } catch (err) {
113
+//         return errorResponse(res, err);
114
+//     }
115
+// }
116
+
117
+// exports.deleteProvince = async (req, res) => {
118
+//     try {
119
+//         const id = req.params.id;
120
+//         await provinceService.deleteProvinceService(id, req);
121
+//         return messageSuccessResponse(res, 'Success delete province');
122
+//     } catch (err) {
123
+//         return errorResponse(res, err);
124
+//     }
125
+// };

+ 0 - 0
src/middleware/CheckRole.js


Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott