The official JavaScript SDK for integrating with the TimeTrackerX API.
To install dependencies:
npm install @timetrackerx/js-sdk
Import the SDK in your project and initialize it with either a base URL or a custom Axios instance.
const { Auth } = require('@timetrackerx/js-sdk');
// Initialize the SDK with a base URL
const ttWithBaseUrl = new Auth({ baseUrl: 'https://your-timetrackerx-api.com' });
// OR
// Initialize the SDK with a custom Axios instance
const axios = require('axios');
const customHttp = axios.create({
/* your custom configuration */
});
const ttWithCustomHttp = new Auth({ http: customHttp });
Authenticate with Google Code and receive an authentication result.
try {
const { auth, error } = await ttWithBaseUrl.authenticateWithGoogleCode('your-google-code');
if (auth) {
console.log('Authentication successful:', auth);
} else {
console.error('Authentication failed:', error);
}
} catch (err) {
console.error('Error during authentication:', err.message);
}
Specify the base URL for the TimeTrackerX API.
const tt = new Auth({ baseUrl: 'https://your-timetrackerx-api.com' });
Provide a custom Axios instance for making HTTP requests.
const axios = require('axios');
const customHttp = axios.create({
/* your custom configuration */
});
const tt = new Auth({ http: customHttp });
Contributions are welcome! Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.