Set up backend API server with Express and Prisma
- Initialize Node.js/Express backend project structure - Configure TypeScript for backend development - Set up Prisma ORM with MySQL database schema - Implement authentication middleware with Clerk - Create photo upload endpoint with EXIF extraction - Build report CRUD endpoints (create, read, delete) - Add file upload handling with Multer - Configure CORS and security middleware (helmet) - Set up error handling and validation - Create development environment configuration Task 21 complete: Backend foundation ready for report submissions
This commit is contained in:
33
server/src/utils/exif.ts
Normal file
33
server/src/utils/exif.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import exifr from 'exifr';
|
||||
|
||||
export interface ExifData {
|
||||
latitude?: number;
|
||||
longitude?: number;
|
||||
timestamp?: Date;
|
||||
make?: string;
|
||||
model?: string;
|
||||
}
|
||||
|
||||
export async function extractExifData(filePath: string): Promise<ExifData> {
|
||||
try {
|
||||
const exif = await exifr.parse(filePath, {
|
||||
gps: true,
|
||||
pick: ['latitude', 'longitude', 'DateTimeOriginal', 'Make', 'Model'],
|
||||
});
|
||||
|
||||
if (!exif) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return {
|
||||
latitude: exif.latitude,
|
||||
longitude: exif.longitude,
|
||||
timestamp: exif.DateTimeOriginal,
|
||||
make: exif.Make,
|
||||
model: exif.Model,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error extracting EXIF data:', error);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user