Cung cấp các API để quản lý các cấu hình hệ thống như domain email cho phép, định dạng số điện thoại hợp lệ, và các quy tắc trạng thái. Các API này chủ yếu phục vụ cho admin hoặc các chức năng cấu hình hệ thống.
Phần dưới đây cung cấp chi tiết về model của Settings API, bao gồm các cấu hình và phương thức sử dụng.
const SettingsSchema = new mongoose.Schema({
allowDomains: { type: [String], required: true },
allowPhones: [{
countryCode: { type: String, required: true },
countryName: { type: String, required: true },
prefix: { type: String, required: true },
pattern: { type: String, required: true },
example: { type: String, required: true }
}]
});
Mẫu dữ liệu:
{
"_id": "...",
"allowDomains": [
"gmail.com",
"hcmus.edu.vn",
"student.university.edu.vn"
],
"allowPhones": [
{
"countryCode": "VN",
"countryName": "Việt Nam",
"prefix": "+84",
"pattern": "^(0|\\\\+84)[3|5|7|8|9][0-9]{8}$",
"example": "090123459 hoặc +84901234569"
},
...
]
}
Sử dụng endpoint GET /api/settings
để lấy những đuôi email cho phép
/api/settings
settingController.getAllSettings
{
"statusTransitionRules": [
{
"fromStatus": "status-1",
"toStatus": [
"status-4",
"status-3",
"status-5"
]
},
...
],
"allowedEmailDomains": [
"gmail.com",
"hcmus.edu.vn",
"student.university.edu.vn",
"example.com",
"student.hcmus.edu.vn"
],
"phoneFormats": [
{
"countryCode": "VN",
"countryName": "Việt Nam",
"prefix": "+84",
"pattern": "^(0|\\\\+84)[3|5|7|8|9][0-9]{8}$",
"example": "090123459 hoặc +84901234569",
"_id": "67e6b459e4410f987e96a1cc"
},
...
]
}