feat: add location tier presets (3, 6, 15) to Globalping settings

## Changes

### Server
- Expand LOCATION_MAP to support city/country-level locations for the
  15-location tier (US East/West, Toronto, London, Frankfurt, Amsterdam,
  Warsaw, Tokyo, Singapore, Mumbai, Sydney, Brazil, Santiago, Johannesburg,
  Dubai)
- Add globalpingLocationsTier field to Settings type, Mongoose model,
  repository mapper, and Joi validation (valid: 3, 6, 15, default: 6)
- Update getGlobalpingLocations endpoint to return locations based on
  the configured tier from settings
- Pass settingsService to MonitorController for tier lookup

### Client
- Add tier selector (radio buttons) to SettingsGlobalping component
  with descriptions for each option:
  - 3 locations: North America, Europe, Asia
  - 6 locations: all continents
  - 15 locations: city-level global coverage
- Add rate limits info box explaining credit usage per tier:
  - Without token: 250 tests/hour
  - With free token: 500 tests/hour
  - GitHub sponsors: higher limits
- Add all translation keys for tier labels, descriptions, and rate info

## Benefits
- Admins can choose the right balance of coverage vs API usage
- Rate limit info helps users decide whether they need authentication
This commit is contained in:
gorkem-bwl committed 2026-02-19 10:31:15 -05:00
1 parent 134c2ebbf4
commit 27c3a9e12b
12 files changed
+202 -10

No files matched your search

+1 -1
View File
@@ -29,7 +29,7 @@ export interface InitializedControllers {
export const initializeControllers = (services: InitializedServices): InitializedControllers => {
return {
authController: new AuthController(services.userService),
monitorController: new MonitorController(services.monitorService),
monitorController: new MonitorController(services.monitorService, services.settingsService),
settingsController: new SettingsController(services.settingsService, services.emailService),
checkController: new CheckController(services.checkService),
inviteController: new InviteController(services.inviteService),
+9 -3
View File
@@ -26,16 +26,19 @@ import {
} from "./controllerUtils.js";
import { AppError } from "@/utils/AppError.js";
import { IMonitorService } from "@/service/index.js";
import { GLOBALPING_LOCATIONS } from "@/service/infrastructure/globalpingService.js";
import { getGlobalpingLocationsByTier } from "@/service/infrastructure/globalpingService.js";
import type { ISettingsService } from "@/service/system/settingsService.js";
const SERVICE_NAME = "monitorController";
class MonitorController {
static SERVICE_NAME = SERVICE_NAME;
private monitorService: IMonitorService;
private settingsService: ISettingsService;
constructor(monitorService: IMonitorService) {
constructor(monitorService: IMonitorService, settingsService: ISettingsService) {
this.monitorService = monitorService;
this.settingsService = settingsService;
}
get serviceName() {
@@ -390,10 +393,13 @@ class MonitorController {
getGlobalpingLocations = async (_req: Request, res: Response, next: NextFunction) => {
try {
const settings = await this.settingsService.getDBSettings();
const tier = settings.globalpingLocationsTier ?? 6;
const locations = getGlobalpingLocationsByTier(tier);
return res.status(200).json({
success: true,
msg: "Globalping locations retrieved successfully",
data: GLOBALPING_LOCATIONS,
data: locations,
});
} catch (error) {
next(error);
+1
View File
@@ -24,6 +24,7 @@ const AppSettingsSchema = new Schema<AppSettingsDocument>(
jwtSecret: { type: String },
pagespeedApiKey: { type: String },
globalpingApiKey: { type: String },
globalpingLocationsTier: { type: Number, default: 6 },
systemEmailHost: { type: String },
systemEmailPort: { type: Number },
systemEmailAddress: { type: String },
@@ -39,6 +39,7 @@ class MongoSettingsRepository implements ISettingsRepository {
systemEmailRejectUnauthorized: doc.systemEmailRejectUnauthorized ?? true,
showURL: doc.showURL ?? false,
globalpingApiKey: doc.globalpingApiKey ?? undefined,
globalpingLocationsTier: doc.globalpingLocationsTier ?? 6,
singleton: doc.singleton,
version: doc.version ?? 1,
globalThresholds: doc.globalThresholds ?? undefined,
@@ -5,16 +5,47 @@ import type { MonitorStatusResponse } from "@/types/network.js";
const SERVICE_NAME = "GlobalpingService";
const LOCATION_MAP: Record<string, { continent: string }> = {
// Maps location IDs to Globalping API location objects
const LOCATION_MAP: Record<string, Record<string, string>> = {
// Continent-level (used for 3 and 6 tier)
"north-america": { continent: "NA" },
europe: { continent: "EU" },
asia: { continent: "AS" },
"south-america": { continent: "SA" },
oceania: { continent: "OC" },
africa: { continent: "AF" },
// City-level (used for 15 tier)
"us-east": { country: "US", state: "VA" },
"us-west": { country: "US", state: "CA" },
canada: { country: "CA", city: "Toronto" },
"uk": { country: "GB", city: "London" },
germany: { country: "DE", city: "Frankfurt" },
netherlands: { country: "NL", city: "Amsterdam" },
poland: { country: "PL", city: "Warsaw" },
japan: { country: "JP", city: "Tokyo" },
singapore: { country: "SG", city: "Singapore" },
india: { country: "IN", city: "Mumbai" },
australia: { country: "AU", city: "Sydney" },
brazil: { country: "BR" },
chile: { country: "CL", city: "Santiago" },
"south-africa": { country: "ZA", city: "Johannesburg" },
uae: { country: "AE", city: "Dubai" },
};
export const GLOBALPING_LOCATIONS = [
interface GlobalpingLocationOption {
id: string;
label: string;
}
// 3 locations: core regions
const LOCATIONS_TIER_3: GlobalpingLocationOption[] = [
{ id: "north-america", label: "North America" },
{ id: "europe", label: "Europe" },
{ id: "asia", label: "Asia" },
];
// 6 locations: all continents
const LOCATIONS_TIER_6: GlobalpingLocationOption[] = [
{ id: "north-america", label: "North America" },
{ id: "europe", label: "Europe" },
{ id: "asia", label: "Asia" },
@@ -23,6 +54,35 @@ export const GLOBALPING_LOCATIONS = [
{ id: "africa", label: "Africa" },
];
// 15 locations: city/country level
const LOCATIONS_TIER_15: GlobalpingLocationOption[] = [
{ id: "us-east", label: "US East (Virginia)" },
{ id: "us-west", label: "US West (California)" },
{ id: "canada", label: "Canada (Toronto)" },
{ id: "uk", label: "UK (London)" },
{ id: "germany", label: "Germany (Frankfurt)" },
{ id: "netherlands", label: "Netherlands (Amsterdam)" },
{ id: "poland", label: "Poland (Warsaw)" },
{ id: "japan", label: "Japan (Tokyo)" },
{ id: "singapore", label: "Singapore" },
{ id: "india", label: "India (Mumbai)" },
{ id: "australia", label: "Australia (Sydney)" },
{ id: "brazil", label: "Brazil" },
{ id: "chile", label: "Chile (Santiago)" },
{ id: "south-africa", label: "South Africa (Johannesburg)" },
{ id: "uae", label: "UAE (Dubai)" },
];
const LOCATIONS_BY_TIER: Record<number, GlobalpingLocationOption[]> = {
3: LOCATIONS_TIER_3,
6: LOCATIONS_TIER_6,
15: LOCATIONS_TIER_15,
};
export const getGlobalpingLocationsByTier = (tier: number): GlobalpingLocationOption[] => {
return LOCATIONS_BY_TIER[tier] ?? LOCATIONS_TIER_6;
};
class GlobalpingService {
static SERVICE_NAME = SERVICE_NAME;
+1
View File
@@ -25,6 +25,7 @@ export interface Settings {
systemEmailRejectUnauthorized: boolean;
showURL: boolean;
globalpingApiKey?: string;
globalpingLocationsTier?: number;
singleton: boolean;
version: number;
globalThresholds?: SettingsThresholds;
+1
View File
@@ -431,6 +431,7 @@ const updateAppSettingsBodyValidation = joi.object({
systemEmailRejectUnauthorized: joi.boolean(),
globalpingApiKey: joi.string().allow(""),
globalpingLocationsTier: joi.number().valid(3, 6, 15).optional(),
globalThresholds: joi
.object({
cpu: joi.number().min(1).max(100).allow(""),