{"id":28999679,"url":"https://github.com/technway/rvnjs","last_synced_at":"2025-10-20T07:13:00.763Z","repository":{"id":299842278,"uuid":"1003609949","full_name":"technway/rvnjs","owner":"technway","description":"A minimal utility library providing React using Vite \u0026 Next.js utilities","archived":false,"fork":false,"pushed_at":"2025-06-18T15:47:01.000Z","size":66,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-18T16:01:37.967Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/technway.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-17T12:03:29.000Z","updated_at":"2025-06-18T15:42:51.000Z","dependencies_parsed_at":"2025-06-18T16:01:49.441Z","dependency_job_id":"5e84ef99-a709-457a-b68e-f01589488b03","html_url":"https://github.com/technway/rvnjs","commit_stats":null,"previous_names":["technway/rvnjs"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/technway/rvnjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technway%2Frvnjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technway%2Frvnjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technway%2Frvnjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technway%2Frvnjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/technway","download_url":"https://codeload.github.com/technway/rvnjs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technway%2Frvnjs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261832970,"owners_count":23216499,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-25T08:08:19.182Z","updated_at":"2025-10-20T07:12:55.714Z","avatar_url":"https://github.com/technway.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\"https://github.com/user-attachments/assets/867c5d8c-0c1a-45f1-87ce-cf333c4987ba\" alt=\"RVNJS Logo\" width=\"190\" /\u003e\n\n\u003ch1\u003eRVNJS – Utilities for React (using Vite) and Next.js\u003c/h1\u003e\n\n\u003cp\u003eA minimal utility library offering essential helpers for React (using Vite) and Next.js applications.\u003c/p\u003e\n\n\u003ca href=\"https://www.npmjs.com/package/@technway/rvnjs\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@technway/rvnjs.svg\" alt=\"npm version\"\u003e\u003c/a\u003e \u003ca href=\"https://www.npmjs.com/package/@technway/rvnjs\"\u003e\u003cimg src=\"https://img.shields.io/npm/dt/@technway/rvnjs.svg\" alt=\"npm downloads\"\u003e\u003c/a\u003e \u003ca href=\"https://github.com/technway/rvnjs/actions\"\u003e\u003cimg src=\"https://github.com/technway/rvnjs/actions/workflows/ci.yml/badge.svg\" alt=\"CI Status\"\u003e\u003c/a\u003e \u003ca href=\"https://www.typescriptlang.org/\"\u003e\u003cimg src=\"https://img.shields.io/badge/TypeScript-5.0%2B-blue.svg\" alt=\"TypeScript\"\u003e\u003c/a\u003e\n\n\u003c/div\u003e\n\n- [Features](#features)\n- [Installation](#installation)\n- [API Reference](#api-reference)\n  - [User Utilities](#user-utilities)\n    - [Type Exports](#type-exports)\n    - [Examples](#examples)\n  - [Logging Utilities](#logging-utilities)\n    - [Why use this?](#why-use-this)\n    - [Limitations](#limitations)\n    - [Comparison](#comparison)\n    - [Main Logging](#main-logging)\n    - [Dev Logging Functions](#dev-logging-functions)\n    - [Logger Methods](#logger-methods)\n    - [Type Exports](#type-exports-1)\n    - [Examples](#examples-1)\n  - [Environment Utilities](#environment-utilities)\n    - [Environment Variable Priority](#environment-variable-priority)\n    - [Type Exports](#type-exports-2)\n- [License](#license)\n\n---\n\n## Features\n\n* Automatically supports both Vite (React) and Next.js environments\n* TypeScript support with full definitions and JSDoc for all functions\n* Utilities adapt based on environment variables\n* Most-featured utilities: [Logging Utilities](#logging-utilities)\n\n## Installation\n\n```bash\n# npm\nnpm install @technway/rvnjs\n\n# yarn\nyarn add @technway/rvnjs\n\n# pnpm\npnpm add @technway/rvnjs\n```\n\n---\n\n## API Reference\n\n### User Utilities\n\n| Function                 | Description                                                        | Parameters                                                                                                          | Returns                      | Notes                                                                                                                                                                                                                                |\n| ------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `resolveAvatar`          | Resolves a user profile image URL                                  | `options: { path?: string \\| null, fallback?: string, baseUrl?: string \\| false }`                                  | `string` - Final image URL   | HTTPS URLs returned as-is. HTTP URLs only allowed in dev. Relative paths are prefixed with API base URL. Fallback is returned for empty or disallowed paths. Requires `VITE_API_BASE_URL` (Vite) or `NEXT_PUBLIC_API_URL` (Next.js). |\n| `getDisplayName`         | Builds a readable name from a full name                            | `options: { fullName: string, useFullName?: boolean, maxLength?: number }`                                          | `string` - Display name      | Returns full name or a shortened version depending on flags. Trims and safely handles edge cases. No environment variables required.                                                                                                 |\n| `getDefaultProfilePhoto` | ~~Returns a user avatar based on role or fallback~~ *(deprecated)* | `options: { role?: string \\| null, photoPath?: string \\| null, userAvatarPath?: string, adminAvatarPath?: string }` | `string` - Profile photo URL | **Deprecated**. Use `resolveAvatar` instead. Falls back to role-specific avatars or API base + `photoPath`.                                                                                                                          |\n\n#### Type Exports\n\n| Type                  | Description                                         | Notes                                                                     |\n| --------------------- | --------------------------------------------------- | ------------------------------------------------------------------------- |\n| `AvatarOptions`       | Options for `resolveAvatar()`                       | `{ path?: string \\| null, fallback?: string, baseUrl?: string \\| false }` |\n| `DisplayNameOptions`  | Options for `getDisplayName()`                      | `{ fullName: string, useFullName?: boolean, maxLength?: number }`         |\n| `ProfilePhotoOptions` | *(Deprecated)* Legacy options for avatar resolution | Used by `getDefaultProfilePhoto()`. Prefer `AvatarOptions`.               |\n\n#### Examples\n\n```ts\nimport { resolveAvatar, getDisplayName } from '@technway/rvnjs';\n\nresolveAvatar({ path: 'https://example.com/photo.jpg' });\n// → 'https://example.com/photo.jpg'\n\nresolveAvatar({ path: '/uploads/user.jpg' });\n// → 'https://your-api.com/uploads/user.jpg'\n\ngetDisplayName({ fullName: 'John Michael Doe Smith' });\n// → 'John'\n\ngetDisplayName({ fullName: 'John Michael Doe Smith', useFullName: true, maxLength: 15 });\n// → 'John Michael...'\n```\n\n---\n\n### Logging Utilities\n\n\u003e Logging is automatically disabled in production unless explicitly enabled.\n\n#### Why use this?\n\n* 🧠 Environment-aware: auto-disables in production\n* ⚡ Zero cost in prod when unused\n* ℹ️ Emoji-prefixed logs for easier scanning\n* 🔧 Central toggle via env vars\n* 🧼 Cleaner, filterable output in browser console\n\n#### Limitations\n\n* No `console.group()`, `console.table()`, `console.trace()` support\n* No custom styles (`%c`)\n* Use native `console` directly for advanced cases\n\n#### Comparison\n\n| Feature             | `logger()` (Main Logger)          | `devLog()` etc (Dev-Only)         |\n| ------------------- | --------------------------------- | --------------------------------- |\n| Logging Mode        | Env-controlled (`ENABLE_LOGGING`) | Only in development               |\n| Interface           | Object with `.debug()` etc        | Function with `LogOptions` object |\n| Output Format       | Emoji-prefixed messages           | Emoji-prefixed messages           |\n| Performance in Prod | No-op unless explicitly enabled   | No-op always                      |\n| Use Case            | General app logging               | Dev debugging \u0026 warnings          |\n\n#### Main Logging\n\n| Function           | Description                                    | Returns      | Notes                                                                |\n| ------------------ | ---------------------------------------------- | ------------ | -------------------------------------------------------------------- |\n| `isLoggingEnabled` | Returns true if logging is enabled             | `boolean`    | Controlled via `VITE_ENABLE_LOGGING` or `NEXT_PUBLIC_ENABLE_LOGGING` |\n| `logger`           | Returns a logger object (`debug`, `info`, etc) | `LoggerType` | Each log prefixed with emoji (🐛, ⚠️, ❌, ℹ️)                            |\n\n#### Dev Logging Functions\n\n| Function   | Description                      | Parameters                            | Notes             |\n| ---------- | -------------------------------- | ------------------------------------- | ----------------- |\n| `devLog`   | Logs debug in development only   | `{ message: string, data?, prefix? }` | Default prefix: 🔧 |\n| `devError` | Logs error in development only   | `{ message: string, data?, prefix? }` | Default prefix: ❌ |\n| `devWarn`  | Logs warning in development only | `{ message: string, data?, prefix? }` | Default prefix: ⚠️ |\n| `devInfo`  | Logs info in development only    | `{ message: string, data?, prefix? }` | Default prefix: ℹ️ |\n\n#### Logger Methods\n\n| Method        | Emoji | Purpose        |\n| ------------- | ----- | -------------- |\n| `log.debug()` | 🐛     | Debugging info |\n| `log.info()`  | ℹ️     | General info   |\n| `log.warn()`  | ⚠️     | Warnings       |\n| `log.error()` | ❌     | Errors         |\n\n#### Type Exports\n\n| Type         | Description                       | Notes                                                  |        |           |                     |\n| ------------ | --------------------------------- | ------------------------------------------------------ | ------ | --------- | ------------------- |\n| `LogLevel`   | \\`'debug'                         | 'info'                                                 | 'warn' | 'error'\\` | Internal log levels |\n| `LogOptions` | Options for dev logging functions | `{ message: string, data?: unknown, prefix?: string }` |        |           |                     |\n\n#### Examples\n\n```ts\nimport { logger, devLog, devError } from '@technway/rvnjs';\n\nconst log = logger();\nlog.info('App started');\n// → ℹ️ INFO: App started\n\ndevLog({ message: 'User loaded', data: { id: 123 } });\n// → 🔧 User loaded { id: 123 }\n\ndevError({ message: 'Something failed', prefix: '🚫' });\n// → 🚫 Something failed\n```\n\n---\n\n### Environment Utilities\n\n| Function        | Description                                    | Parameters                                           | Returns   | Notes                                                                                                                      |\n| --------------- | ---------------------------------------------- | ---------------------------------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------- |\n| `isDevEnv`      | Returns `true` if running in development mode  | None                                                 | `boolean` | Checks `NODE_ENV === 'development'` or `import.meta.env.MODE === 'development'`                                            |\n| `getApiBaseUrl` | Returns base API URL from env or custom inputs | `{ customBaseUrl?: string, customApiPath?: string }` | `string`  | Reads from `VITE_API_BASE_URL` or `NEXT_PUBLIC_API_URL`. Appends path if provided. Trailing slashes removed automatically. |\n\n#### Environment Variable Priority\n\n1. `NEXT_PUBLIC_API_URL` (Next.js)\n2. `VITE_API_BASE_URL` (Vite)\n3. `API_URL` (fallback)\n\n#### Type Exports\n\n| Type                | Description                   | Notes                                                |\n| ------------------- | ----------------------------- | ---------------------------------------------------- |\n| `ApiBaseUrlOptions` | Options for `getApiBaseUrl()` | `{ customBaseUrl?: string, customApiPath?: string }` |\n\n---\n\n## License\n\nMIT License © [Technway Solutions](https://technway.biz)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnway%2Frvnjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechnway%2Frvnjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnway%2Frvnjs/lists"}