feat: Google Maps API key management in admin settings
- Backend: GET /settings/maps-key (public) + PATCH /settings/maps (protected) - Admin: sección para guardar/ver estado de la Maps API key - Flutter web carga la key dinámicamente desde el backend Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
39c4301d1b
commit
3e1632e776
@@ -29,6 +29,19 @@ export class SettingsController {
|
||||
return this.settings.updatePolicy(key, body.content);
|
||||
}
|
||||
|
||||
// Maps key
|
||||
@Get('maps-key')
|
||||
async getMapsKey() {
|
||||
const api_key = await this.settings.getMapsKey();
|
||||
return { configured: !!api_key, api_key: api_key ?? '' };
|
||||
}
|
||||
|
||||
@Patch('maps')
|
||||
@UseGuards(JwtAuthGuard) @ApiBearerAuth()
|
||||
saveMapsKey(@Body() body: { api_key: string }) {
|
||||
return this.settings.saveMapsKey(body.api_key);
|
||||
}
|
||||
|
||||
// Public policy pages
|
||||
@Get('policy/:key')
|
||||
async getPublicPolicy(@Param('key') key: string, @Res() res: Response) {
|
||||
|
||||
@@ -41,4 +41,17 @@ export class SettingsService {
|
||||
]);
|
||||
return { privacy, terms };
|
||||
}
|
||||
|
||||
async getMapsKey(): Promise<string | null> {
|
||||
const setting = await this.prisma.settings.findUnique({ where: { key: 'maps_config' } });
|
||||
return (setting?.value as any)?.api_key ?? null;
|
||||
}
|
||||
|
||||
async saveMapsKey(api_key: string) {
|
||||
return this.prisma.settings.upsert({
|
||||
where: { key: 'maps_config' },
|
||||
create: { key: 'maps_config', value: { api_key } },
|
||||
update: { value: { api_key } },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user