Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Conversation

@Cut0x
Copy link
Contributor

@Cut0x Cut0x commented Aug 19, 2025

No description provided.

Cut0x added 6 commits August 19, 2025 23:00
Add core SDK files including client, logger, error handling, statistics, and TypeScript definitions. Provide example usage, comprehensive README, and package metadata for publishing. This release enables logging, retrieval, analytics, error handling, and advanced features for CheckLogs.dev.
This update introduces full ES module support by adding .mjs entry points and refactoring source files to provide both CommonJS and ES module versions. The main entry points are now index.js (CommonJS) and index.mjs (ESM), with updated exports in package.json. The README and a new TROOBLESHOOTING.md provide detailed usage and troubleshooting for both module types. Example scripts and a quick-start script are added for easier onboarding. Internal imports and exports are updated for compatibility, and the .gitignore now excludes package-lock.json.
@Cut0x Cut0x requested a review from Copilot August 19, 2025 21:45
@Cut0x Cut0x self-assigned this Aug 19, 2025
@Cut0x Cut0x merged commit 3a8ea20 into main Aug 19, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces the v1.0 release of the CheckLogs Node.js SDK, providing a comprehensive logging solution with dual module support (CommonJS and ES Modules). The SDK offers enhanced logging capabilities, statistics gathering, error handling, and automatic retry mechanisms.

Key changes:

  • Complete SDK implementation with client, logger, and statistics modules
  • Dual package support for both CommonJS and ES Modules environments
  • Comprehensive error handling system with custom error classes
  • Automated quick-start script for easy project setup

Reviewed Changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
package.json Package configuration with dual module exports and dependencies
index.js / index.mjs Main entry points for CommonJS and ES Module environments
lib/client.mjs Core API client with HTTP communication and validation
lib/logger.mjs Enhanced logger with retry logic and metadata enrichment
lib/stats.mjs Statistics and analytics functionality
lib/errors.mjs Custom error classes for different failure scenarios
script/quick-start.js Automated setup script for new users
README.md Comprehensive documentation with examples
TROOBLESHOOTING.md User guide for common setup and usage issues
exemple/ Example files demonstrating usage patterns

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"quick-start": "node scripts/quick-start.js"
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script path references 'scripts/quick-start.js' but the actual file is located at 'script/quick-start.js' (without 's'). This will cause the npm script to fail.

Suggested change
"quick-start": "node scripts/quick-start.js"
"quick-start": "node script/quick-start.js"

Copilot uses AI. Check for mistakes.
* @param {Object} options - Optional configuration
* @returns {CheckLogsClient} CheckLogs client instance
*/
function createClient(apiKey, options = {}) {
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attempting to require an ES module (.mjs) with CommonJS require() syntax will fail. ES modules cannot be synchronously required in Node.js. Consider using dynamic import() or restructuring the module system.

Suggested change
function createClient(apiKey, options = {}) {
// Dynamic import functions for ES modules
async function getCheckLogsClient() {
const mod = await import('./lib/client.mjs');
return mod.default;
}
async function getCheckLogsLogger() {
const mod = await import('./lib/logger.mjs');
return mod.default;
}
async function getCheckLogsStats() {
const mod = await import('./lib/stats.mjs');
return mod.default;
}
async function getErrors() {
const mod = await import('./lib/errors.mjs');
return {
CheckLogsError: mod.CheckLogsError,
ValidationError: mod.ValidationError,
ApiError: mod.ApiError,
NetworkError: mod.NetworkError
};
}
/**
* Create a new CheckLogs client instance
* @param {string} apiKey - Your application API key
* @param {Object} options - Optional configuration
* @returns {CheckLogsClient} CheckLogs client instance
*/
async function createClient(apiKey, options = {}) {
const CheckLogsClient = await getCheckLogsClient();

Copilot uses AI. Check for mistakes.
const CheckLogsStats = require('./lib/stats.mjs').default;

// Named exports from errors.mjs
const { CheckLogsError, ValidationError, ApiError, NetworkError } = require('./lib/errors.mjs');
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attempting to require an ES module (.mjs) with CommonJS require() syntax will fail. ES modules cannot be synchronously required in Node.js.

Suggested change
const { CheckLogsError, ValidationError, ApiError, NetworkError } = require('./lib/errors.mjs');
const CheckLogsClient = require('./lib/client.js');
const CheckLogsLogger = require('./lib/logger.js');
const CheckLogsStats = require('./lib/stats.js');
// Named exports from errors.js
const { CheckLogsError, ValidationError, ApiError, NetworkError } = require('./lib/errors.js');

Copilot uses AI. Check for mistakes.
* @param {Object} options - Optional configuration
* @returns {CheckLogsClient} CheckLogs client instance
*/
function createClient(apiKey, options = {}) {
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attempting to require an ES module (.mjs) with CommonJS require() syntax will fail. ES modules cannot be synchronously required in Node.js.

Suggested change
function createClient(apiKey, options = {}) {
// Use dynamic import for ES modules (.mjs)
// Classes and errors will be loaded asynchronously in factory functions below.
// Error classes will be loaded asynchronously in factory functions below.
/**
* Create a new CheckLogs client instance
* @param {string} apiKey - Your application API key
* @param {Object} options - Optional configuration
* @returns {CheckLogsClient} CheckLogs client instance
*/
async function createClient(apiKey, options = {}) {
const module = await import('./lib/client.mjs');
const CheckLogsClient = module.default;

Copilot uses AI. Check for mistakes.

// Default export for convenience
default: createClient
}; No newline at end of file
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attempting to require an ES module (.mjs) with CommonJS require() syntax will fail. ES modules cannot be synchronously required in Node.js.

Suggested change
};
// Dynamic import for ES modules
async function loadModules() {
const { default: CheckLogsClient } = await import('./lib/client.mjs');
const { default: CheckLogsLogger } = await import('./lib/logger.mjs');
const { default: CheckLogsStats } = await import('./lib/stats.mjs');
const { CheckLogsError, ValidationError, ApiError, NetworkError } = await import('./lib/errors.mjs');
/**
* Create a new CheckLogs client instance
* @param {string} apiKey - Your application API key
* @param {Object} options - Optional configuration
* @returns {CheckLogsClient} CheckLogs client instance
*/
function createClient(apiKey, options = {}) {
return new CheckLogsClient(apiKey, options);
}
/**
* Create a new CheckLogs logger instance
* @param {string} apiKey - Your application API key
* @param {Object} options - Optional configuration
* @returns {CheckLogsLogger} CheckLogs logger instance
*/
function createLogger(apiKey, options = {}) {
return new CheckLogsLogger(apiKey, options);
}
return {
// Main classes
CheckLogsClient,
CheckLogsLogger,
CheckLogsStats,
// Error classes
CheckLogsError,
ValidationError,
ApiError,
NetworkError,
// Factory functions
createClient,
createLogger,
// Default export for convenience
default: createClient
};
}
module.exports = loadModules();

Copilot uses AI. Check for mistakes.
}

this.apiKey = apiKey;
this.baseURL = 'http://localhost/checklogs/webiste/api/logs.php';
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The URL contains a typo: 'webiste' should be 'website'.

Suggested change
this.baseURL = 'http://localhost/checklogs/webiste/api/logs.php';
this.baseURL = 'http://localhost/checklogs/website/api/logs.php';

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,202 @@
# Troubleshooting Guide
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filename 'TROOBLESHOOTING.md' contains a typo - it should be 'TROUBLESHOOTING.md' (missing 'U').

Copilot uses AI. Check for mistakes.

async function testLogger() {
// Create a logger instance
const logger = createLogger('0e78815d69603a88d111c02e03143cf2e4dc5d4aaf9821d9cec41fe738ce7d56');
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A hardcoded API key is exposed in the example file. This should be replaced with a placeholder or environment variable reference to avoid accidentally committing real credentials.

Suggested change
const logger = createLogger('0e78815d69603a88d111c02e03143cf2e4dc5d4aaf9821d9cec41fe738ce7d56');
// Replace 'YOUR_API_KEY_HERE' with your actual API key or set the LOGGER_API_KEY environment variable.
const logger = createLogger(process.env.LOGGER_API_KEY || 'YOUR_API_KEY_HERE');

Copilot uses AI. Check for mistakes.

async function testLogger() {
// Create a logger instance
const logger = createLogger('0e78815d69603a88d111c02e03143cf2e4dc5d4aaf9821d9cec41fe738ce7d56');
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A hardcoded API key is exposed in the example file. This should be replaced with a placeholder or environment variable reference to avoid accidentally committing real credentials.

Suggested change
const logger = createLogger('0e78815d69603a88d111c02e03143cf2e4dc5d4aaf9821d9cec41fe738ce7d56');
const apiKey = process.env.LOGGER_API_KEY;
if (!apiKey) {
throw new Error('LOGGER_API_KEY environment variable is not set. Please set it to your API key.');
}
const logger = createLogger(apiKey);

Copilot uses AI. Check for mistakes.
console.log('\nNext steps:');
console.log('1. Replace "your-api-key-here" with your actual CheckLogs API key');
console.log('2. Install dependencies: npm install');
console.log(`3. Run the test: ${isESModules ? 'node test.mjs' : 'node test.js'}`);
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The directory name in the path should be 'examples' instead of using the French 'exemple' to maintain consistency with English naming conventions.

Copilot uses AI. Check for mistakes.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant