feat: integrate @flare/utiliyo for path handling, optimize dependency management, and update project configuration

This commit is contained in:
Tudor Stanciu 2025-10-05 23:51:18 +03:00
parent 093893ba50
commit 228807cfed
12 changed files with 66 additions and 44 deletions

1
.npmrc Normal file
View File

@ -0,0 +1 @@
@flare:registry=https://lab.code-rove.com/public-node-registry

View File

@ -5,6 +5,7 @@ FROM node:24.9-alpine3.21 AS builder
WORKDIR /app
# Copy workspace configuration
COPY .npmrc .npmrc
COPY package*.json ./
# Copy workspace package files
@ -13,6 +14,7 @@ COPY src/frontend/package*.json ./src/frontend/
# Install all dependencies (including devDependencies for build)
RUN npm ci
RUN rm -f .npmrc
# Copy source code
COPY src/ ./src/

View File

@ -1,5 +1,43 @@
{
"releases": [
{
"version": "1.0.4",
"date": "2025-10-05T20:30:00Z",
"title": "Dependency Optimization - @flare/utiliyo Integration",
"summary": "Replaced local pathCombine utility with battle-tested @flare/utiliyo package, reducing code duplication and leveraging shared utilities.",
"sections": [
{
"title": "Overview",
"content": "Version 1.0.4 optimizes frontend dependencies by integrating @flare/utiliyo, a shared utility package from the @flare ecosystem. This change eliminates duplicate code by replacing the local pathCombine implementation with a well-tested, maintained alternative from the custom npm registry."
},
{
"title": "Dependency Management",
"items": [
"**@flare/utiliyo Integration** - Added @flare/utiliyo v1.2.2 as frontend dependency",
"**Custom Registry Configuration** - Configured .npmrc for @flare scoped packages",
"**Code Deduplication** - Removed local pathCombine implementation (33 lines)",
"**Shared Utilities** - Leverages battle-tested path manipulation utilities"
]
},
{
"title": "Technical Changes",
"items": [
"Added `.npmrc` in project root with `@flare:registry=https://lab.code-rove.com/public-node-registry`",
"Updated frontend package.json with `@flare/utiliyo: ^1.2.2` dependency"
]
},
{
"title": "Benefits",
"items": [
"**Reduced Maintenance** - No need to maintain local path utilities",
"**Bug Fixes** - Automatic bug fixes from upstream package updates",
"**Feature Updates** - Access to new utilities as they're added",
"**Consistency** - Same path handling across multiple @flare projects",
"**Testing** - Leverages comprehensive test suite from utiliyo package"
]
}
]
},
{
"version": "1.0.3",
"date": "2025-10-05T16:30:00Z",

15
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "bitip",
"version": "1.0.2",
"version": "1.0.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "bitip",
"version": "1.0.2",
"version": "1.0.3",
"license": "MIT",
"workspaces": [
"src/backend",
@ -977,6 +977,12 @@
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
}
},
"node_modules/@flare/utiliyo": {
"version": "1.2.2",
"resolved": "https://lab.code-rove.com/public-node-registry/@flare/utiliyo/-/utiliyo-1.2.2.tgz",
"integrity": "sha512-NTre0lTmxZXkNM9sS8T28jhHjftycYDRGzpDh6aq1aOjbXQyzfn0VdexK/B82zvnv95Ba0jbQoqdoLia/62yXg==",
"license": "MIT"
},
"node_modules/@hapi/address": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/@hapi/address/-/address-5.1.1.tgz",
@ -6646,7 +6652,7 @@
},
"src/backend": {
"name": "bitip-backend",
"version": "1.0.2",
"version": "1.0.3",
"dependencies": {
"@maxmind/geoip2-node": "^6.1.0",
"compression": "^1.7.4",
@ -7135,8 +7141,9 @@
},
"src/frontend": {
"name": "bitip-frontend",
"version": "1.0.2",
"version": "1.0.3",
"dependencies": {
"@flare/utiliyo": "^1.2.2",
"axios": "^1.12.2",
"leaflet": "^1.9.4",
"lucide-react": "^0.544.0",

View File

@ -1,6 +1,6 @@
{
"name": "bitip",
"version": "1.0.3",
"version": "1.0.4",
"description": "Bitip - GeoIP Lookup Service with REST API and Web Interface",
"main": "dist/backend/index.js",
"scripts": {

View File

@ -1,6 +1,6 @@
{
"name": "bitip-backend",
"version": "1.0.3",
"version": "1.0.4",
"description": "Bitip Backend - GeoIP REST API Service",
"type": "module",
"main": "dist/index.js",

View File

@ -1,6 +1,6 @@
{
"name": "bitip-frontend",
"version": "1.0.3",
"version": "1.0.4",
"description": "Bitip Frontend - GeoIP Web Interface",
"type": "module",
"scripts": {
@ -12,6 +12,7 @@
"clean": "rimraf dist"
},
"dependencies": {
"@flare/utiliyo": "^1.2.2",
"axios": "^1.12.2",
"leaflet": "^1.9.4",
"lucide-react": "^0.544.0",

View File

@ -0,0 +1,8 @@
// Runtime configuration generated at container startup
// DO NOT EDIT - This file is automatically generated
// eslint-disable-next-line no-undef
window.env = {
"BASE_PATH": "/",
"FRONTEND_API_KEY": "frontend-dev-key",
"DEBOUNCE_MS": 2000
};

View File

@ -7,7 +7,7 @@ import ExternalLinks from './components/ExternalLinks';
import BitipAPI from './services/api';
import './App.css';
import config from '@/services/config';
import { pathCombine } from './utils';
import { pathCombine } from '@flare/utiliyo';
interface VersionInfo {
version: string;

View File

@ -8,7 +8,7 @@ import {
OverviewResponse,
} from '../types';
import config from './config';
import { pathCombine } from '@/utils/paths';
import { pathCombine } from '@flare/utiliyo';
const isDevelopment = config.MODE === 'development';
const BASE_URL = isDevelopment

View File

@ -1 +0,0 @@
export * from './paths';

View File

@ -1,34 +0,0 @@
/**
* Combines multiple URL segments, ensuring proper slash handling
* @param segments - URL segments to combine (e.g., 'http://localhost:5172', '/api', 'health')
* @returns Combined URL path with proper slash separators
* @example
* pathCombine('http://localhost:5172', '/api', 'health') // 'http://localhost:5172/api/health'
* pathCombine('/base', 'api/', '/endpoint') // '/base/api/endpoint'
* pathCombine('/', '/api') // '/api'
*/
const pathCombine = (...segments: string[]): string => {
// Filter out null, undefined, and empty strings
const validSegments = segments.filter(
seg => seg !== null && seg !== undefined && seg !== ''
);
if (validSegments.length === 0) return '';
if (validSegments.length === 1) return validSegments[0];
// Process first segment (keep leading slash or protocol)
let result = validSegments[0].replace(/\/+$/, '');
// Process middle and last segments
for (let i = 1; i < validSegments.length; i++) {
const segment = validSegments[i].replace(/^\/+|\/+$/g, ''); // Remove leading and trailing slashes
if (segment) {
// Only add non-empty segments
result += `/${segment}`;
}
}
return result;
};
export { pathCombine };