mirror of
https://github.com/Crazyco-xyz/48hr.email.git
synced 2026-01-09 11:19:36 +01:00
68 lines
No EOL
1.8 KiB
JavaScript
68 lines
No EOL
1.8 KiB
JavaScript
const express = require('express')
|
|
|
|
/**
|
|
* Configuration API Routes (Public)
|
|
* GET /domains - Get allowed email domains
|
|
* GET /limits - Get rate limits and constraints
|
|
* GET /features - Get enabled features
|
|
*/
|
|
function createConfigRouter(dependencies) {
|
|
// API enabled toggle
|
|
router.use((req, res, next) => {
|
|
if (!config.apiEnabled) {
|
|
return res.apiError('API is disabled', 'API_DISABLED', 503);
|
|
}
|
|
next();
|
|
});
|
|
const router = express.Router()
|
|
const { config } = dependencies
|
|
|
|
/**
|
|
* GET /domains - Get allowed email domains
|
|
*/
|
|
router.get('/domains', (req, res) => {
|
|
res.apiSuccess({
|
|
domains: config.email.domains
|
|
})
|
|
})
|
|
|
|
/**
|
|
* GET /limits - Get rate limits and constraints
|
|
*/
|
|
router.get('/limits', (req, res) => {
|
|
res.apiSuccess({
|
|
api: {
|
|
rateLimit: {
|
|
requests: 100,
|
|
window: '1 minute'
|
|
}
|
|
},
|
|
email: {
|
|
purgeTime: config.email.purgeTime,
|
|
purgeUnit: config.email.purgeUnit,
|
|
maxForwardedPerRequest: 25
|
|
},
|
|
user: {
|
|
maxVerifiedEmails: config.user.maxVerifiedEmails || 5,
|
|
maxLockedInboxes: config.user.maxLockedInboxes || 5,
|
|
lockReleaseHours: config.user.lockReleaseHours || 168
|
|
}
|
|
})
|
|
})
|
|
|
|
/**
|
|
* GET /features - Get enabled features
|
|
*/
|
|
router.get('/features', (req, res) => {
|
|
res.apiSuccess({
|
|
authentication: config.user.authEnabled,
|
|
forwarding: config.smtp.enabled,
|
|
statistics: config.http.statisticsEnabled,
|
|
inboxLocking: config.user.authEnabled
|
|
})
|
|
})
|
|
|
|
return router
|
|
}
|
|
|
|
module.exports = createConfigRouter |