npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@michaelbhaines/photo-weather-shared

v1.0.0

Published

Shared types and utilities for Photo-to-DB backend and frontend projects

Readme

Photo-Weather Shared Package

Shared TypeScript types, constants, and utilities for the Photo-to-DB backend and Angular frontend projects.

📦 Installation

npm install @mhaines/photo-weather-shared

🚀 Usage

Import Types

import {
  WeatherData,
  TidalData,
  ImageMetadata,
  ExifData,
  ApiResponse
} from '@mhaines/photo-weather-shared';

Import Constants

import {
  ENDPOINTS,
  QUERY_PARAMS,
  DEFAULTS,
  WeatherProvider,
  DataQuality
} from '@mhaines/photo-weather-shared';

Import Utilities

import {
  validateCoordinates,
  calculateDistance,
  formatDateForAPI,
  getRelativeTime
} from '@mhaines/photo-weather-shared';

📋 What's Included

🌤️ Weather Types

  • WeatherData - Complete weather information structure
  • TidalData - Tidal conditions and predictions
  • WeatherDataRequest - Request parameters for weather APIs
  • WeatherProvider, DataQuality enums

📷 Image Types

  • ImageMetadata - Complete image information
  • ExifData - Camera and GPS metadata
  • ImageUploadRequest/Response - Upload API contracts
  • ImageQueryParams - Filtering and pagination

🌐 API Types

  • ApiResponse<T> - Standardized API response format
  • ApiError - Error response structure
  • HealthCheckResponse - System health information
  • HttpStatus enum - Standard HTTP status codes

🔧 Utilities

  • Coordinates: Validation, distance calculation, formatting
  • Dates: API formatting, validation, relative time
  • Constants: API endpoints, query parameters, defaults

🎯 Frontend Usage (Angular)

Service Integration

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import {
  ENDPOINTS,
  ImageUploadResponse,
  WeatherData,
  ApiResponse
} from '@mhaines/photo-weather-shared';

@Injectable()
export class PhotoService {
  constructor(private http: HttpClient) {}

  uploadImage(formData: FormData): Observable<ImageUploadResponse> {
    return this.http.post<ImageUploadResponse>(ENDPOINTS.IMAGES.UPLOAD, formData);
  }

  getWeatherData(lat: number, lon: number): Observable<ApiResponse<WeatherData>> {
    return this.http.get<ApiResponse<WeatherData>>(ENDPOINTS.WEATHER.BASE, {
      params: { latitude: lat.toString(), longitude: lon.toString() }
    });
  }
}

Component Usage

import { Component } from '@angular/core';
import {
  ImageMetadata,
  WeatherData,
  formatDisplayDateTime,
  getRelativeTime
} from '@mhaines/photo-weather-shared';

@Component({
  template: `
    <div *ngFor="let image of images">
      <h3>{{ image.originalName }}</h3>
      <p>Uploaded: {{ getRelativeTime(image.uploadDate) }}</p>
      <div *ngIf="image.weatherData">
        <p>Temperature: {{ image.weatherData.temperature.value }}°{{ image.weatherData.temperature.unit }}</p>
        <p *ngIf="image.weatherData.tidalData">
          Tide: {{ image.weatherData.tidalData.tidalPhase }}
        </p>
      </div>
    </div>
  `
})
export class ImageListComponent {
  images: ImageMetadata[] = [];
  
  getRelativeTime = getRelativeTime;
}

🔧 Backend Usage (Node.js)

API Response Formatting

import { ApiResponse, ImageUploadResponse } from '@mhaines/photo-weather-shared';

export function createSuccessResponse<T>(data: T, message: string): ApiResponse<T> {
  return {
    success: true,
    data,
    message
  };
}

export function createErrorResponse(error: string, message: string): ApiResponse {
  return {
    success: false,
    error,
    message
  };
}

Validation

import { validateCoordinates, isValidWeatherDate } from '@mhaines/photo-weather-shared';

export function validateWeatherRequest(lat: number, lon: number, date: Date) {
  const coordValidation = validateCoordinates(lat, lon);
  if (!coordValidation.isValid) {
    throw new Error(coordValidation.errors.join(', '));
  }
  
  if (!isValidWeatherDate(date)) {
    throw new Error('Invalid date for weather data');
  }
}

🔄 Development Workflow

Making Changes

  1. Update types/constants/utilities in this package
  2. Build and publish new version
  3. Update both backend and frontend projects
  4. Ensures consistency across projects

Publishing

npm run build
npm version patch  # or minor/major
npm publish

Updating Projects

# In backend project
npm update @mhaines/photo-weather-shared

# In frontend project  
npm update @mhaines/photo-weather-shared

📝 Type Safety Benefits

  • Consistent APIs: Same types across backend and frontend
  • Compile-time Validation: Catch mismatches early
  • IntelliSense Support: Better developer experience
  • Refactoring Safety: Changes propagate across projects
  • Documentation: Types serve as living documentation

🎯 Best Practices

  1. Version Carefully: Breaking changes require major version bump
  2. Document Changes: Update README for new features
  3. Test Thoroughly: Validate in both backend and frontend
  4. Keep Focused: Only shared code belongs here
  5. Semantic Versioning: Follow semver for predictable updates

Shared package ensures type safety and consistency across your Photo-to-DB ecosystem! 🚀