Skip to content

bernardbaker/node.time.zone.converter.microservice

Repository files navigation

Node Time Zone Converter Microservice

gRPC microservice that converts a timestamp into a target IANA timezone, matching the Java implementation.

Prerequisites

  • Node.js 18+
  • pnpm 9+ (corepack enable or npm install -g pnpm)
  • grpcurl for manual calls and load tests (brew install grpcurl)

Quick start

pnpm install
pnpm test
pnpm start

Server listens on port 8080 by default (PORT env overrides).

Manual request

./curl.sh

Load testing

Start the server, then in another terminal:

# Light smoke
DURATION_SECONDS=30 CONCURRENCY=8 ./simulate_traffic.sh

# Heavier soak (defaults: 300s, 128 concurrent)
./simulate_traffic.sh

Environment variables: HOST, DURATION_SECONDS, CONCURRENCY, TZ_MODE, TZ_POOL, GRPCURL_MAX_TIME.

Preview traffic shape without hitting the server:

./simulate_traffic_graph.sh

API

Item Value
Service timezone.TimeZoneConverter
Method ConvertTime
Port 8080 (plaintext gRPC)

Example (grpcurl):

grpcurl -plaintext \
  -import-path ./proto \
  -proto api.proto \
  -d '{"timestamp": "2024-12-04T15:00:00Z", "target_timezone": "America/New_York"}' \
  localhost:8080 \
  timezone.TimeZoneConverter/ConvertTime

Golden example: 2024-12-04T15:00:00Z + America/New_York2024-12-04T10:00:00-05:00

Project layout

  • proto/api.proto — gRPC contract
  • src/timeConverter.ts — conversion logic (Luxon)
  • src/timeZoneConverterService.ts — RPC handler
  • src/server.ts — server entrypoint

Scripts

Command Description
pnpm install Install dependencies
pnpm test Run Vitest unit and integration tests
pnpm start Start gRPC server
./scripts/generate-proto.sh Optional static proto codegen

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors