feature/fitlien-add-cors #13
@ -24,7 +24,7 @@ if (!admin.apps.length) {
|
||||
const corsHandler = cors({ origin: true });
|
||||
|
||||
export const sendEmailWithAttachment = onRequest({
|
||||
region: process.env.SERVICES_RGN
|
||||
region: '#{SERVICES_RGN}#'
|
||||
}, async (request: Request, response: express.Response) => {
|
||||
return corsHandler(request, response, async () => {
|
||||
try {
|
||||
@ -157,7 +157,7 @@ export const sendEmailMessage = onRequest({
|
||||
});
|
||||
|
||||
export const sendSMSMessage = onRequest({
|
||||
region: process.env.SERVICES_RGN
|
||||
region: '#{SERVICES_RGN}#'
|
||||
}, (request: Request, response: express.Response) => {
|
||||
return corsHandler(request, response, async () => {
|
||||
|
||||
@ -181,7 +181,7 @@ export const sendSMSMessage = onRequest({
|
||||
});
|
||||
|
||||
export const processNotificationOnCreate = onDocumentCreated({
|
||||
region: process.env.SERVICES_RGN,
|
||||
region: '#{SERVICES_RGN}#',
|
||||
document: 'notifications/{notificationId}'
|
||||
}, async (event) => {
|
||||
try {
|
||||
@ -569,3 +569,44 @@ export const getPlacesAutocomplete = onRequest({
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
export const getPlaceDetails = onRequest({
|
||||
region: '#{SERVICES_RGN}#'
|
||||
}, async (request: Request, response: express.Response) => {
|
||||
return corsHandler(request, response, async () => {
|
||||
try {
|
||||
const { place_id, fields } = request.query;
|
||||
|
||||
if (!place_id) {
|
||||
response.status(400).json({
|
||||
error: 'place_id parameter is required'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const apiKey = process.env.GOOGLE_MAPS_API_KEY;
|
||||
if (!apiKey) {
|
||||
logger.error('Google Places API key is not configured');
|
||||
response.status(500).json({ error: 'Server configuration error' });
|
||||
return;
|
||||
}
|
||||
|
||||
const url = 'https://maps.googleapis.com/maps/api/place/details/json';
|
||||
const params: any = {
|
||||
key: apiKey,
|
||||
place_id: place_id,
|
||||
fields: fields || 'geometry'
|
||||
};
|
||||
|
||||
const result = await axios.get(url, { params });
|
||||
logger.info('Google Places Details API request completed successfully');
|
||||
response.json(result.data);
|
||||
} catch (error) {
|
||||
logger.error('Error fetching place details:', error);
|
||||
response.status(500).json({
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : String(error)
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user