{"_id":"@cabysis/candy-client","_rev":"5-d2108c3973daf89d312fb552ec211139","name":"@cabysis/candy-client","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.0":{"name":"@cabysis/candy-client","version":"1.0.0","keywords":["http","requests","fetch","ts","typescript","client","web"],"author":{"name":"CabySis"},"license":"MIT","_id":"@cabysis/candy-client@1.0.0","maintainers":[{"name":"dev-cabysis","email":"dev@cabysis.com"}],"homepage":"https://github.com/cabysis/candy-client#readme","bugs":{"url":"https://github.com/cabysis/candy-client/issues"},"dist":{"shasum":"c36ad81126ed211a60aa68aef019d3bf506e1771","tarball":"https://registry.npmjs.org/@cabysis/candy-client/-/candy-client-1.0.0.tgz","fileCount":17,"integrity":"sha512-klX0BZmlQv91PJVeRzO3I6sDB0i/YD9MiW/qg83VDGr8I5g6sa2nOsmT2CJ7s8UeBYxV5Bv9jOL3Lvqa3qtRWA==","signatures":[{"sig":"MEQCIHmUYMUhjW39aUXiXcFlnP46y9jHOFZKCDVWXyNDVn6HAiBRPZCmu5z2F4EVhdORorrIjqTDyUNMY2oxkAioRxkTuA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16297},"main":"dist/client/index.js","types":"dist/client/index.d.ts","gitHead":"918282d3bbe3ff4a0fa73968b94089e789c9faa3","scripts":{"dev":"npm run build && node dist/local-runner.js","test":"jest","build":"tsc"},"_npmUser":{"name":"dev-cabysis","email":"dev@cabysis.com"},"repository":{"url":"git+https://github.com/cabysis/candy-client.git","type":"git"},"_npmVersion":"10.5.0","description":"HTTP Client for making request with native fetch library","directories":{},"_nodeVersion":"21.7.3","dependencies":{"reflect-metadata":"^0.2.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.2.2","prettier":"^3.3.3","typescript":"^5.5.3","@types/jest":"^29.5.12"},"_npmOperationalInternal":{"tmp":"tmp/candy-client_1.0.0_1721195640134_0.030553965341016287","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@cabysis/candy-client","version":"1.0.1","keywords":["http","requests","fetch","ts","typescript","client","web"],"author":{"name":"CabySis"},"license":"MIT","_id":"@cabysis/candy-client@1.0.1","maintainers":[{"name":"dev-cabysis","email":"dev@cabysis.com"}],"homepage":"https://github.com/cabysis/candy-client#readme","bugs":{"url":"https://github.com/cabysis/candy-client/issues"},"dist":{"shasum":"8f9189b27ec90b29edf576e168f9dbc83d5e36bf","tarball":"https://registry.npmjs.org/@cabysis/candy-client/-/candy-client-1.0.1.tgz","fileCount":17,"integrity":"sha512-YWaR/mzdMzF3gvv7ppexQVK1G5U3rWsk26YomwbNf3EeP3422GPURFHTxY7ZD2e7BTduaFhykk90AQHvC/HDzA==","signatures":[{"sig":"MEUCIF+/0C1JQQRphh6tNQ5WMP98XJyWtX7rEYcj/7hj8NbdAiEA84XlkNYTBG+F4/S5laIR7OqLmAxwMuWUa/+AHq32H7A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16239},"main":"dist/client/index.js","types":"dist/client/index.d.ts","gitHead":"c905f6d568b1228fd772bd6833099a9970523cec","scripts":{"dev":"npm run build && node dist/local-runner.js","test":"jest","build":"tsc"},"_npmUser":{"name":"dev-cabysis","email":"dev@cabysis.com"},"repository":{"url":"git+https://github.com/cabysis/candy-client.git","type":"git"},"_npmVersion":"10.5.0","description":"HTTP Client for making request with native fetch library","directories":{},"_nodeVersion":"21.7.3","dependencies":{"reflect-metadata":"^0.2.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.2.2","prettier":"^3.3.3","typescript":"^5.5.3","@types/jest":"^29.5.12"},"_npmOperationalInternal":{"tmp":"tmp/candy-client_1.0.1_1721225800027_0.6580034966455608","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@cabysis/candy-client","version":"1.0.2","keywords":["http","requests","fetch","ts","typescript","client","web"],"author":{"name":"CabySis"},"license":"MIT","_id":"@cabysis/candy-client@1.0.2","maintainers":[{"name":"dev-cabysis","email":"dev@cabysis.com"}],"homepage":"https://github.com/cabysis/candy-client#readme","bugs":{"url":"https://github.com/cabysis/candy-client/issues"},"dist":{"shasum":"3d96eb5c55a57ef44cfb9dd98005761c3dadffcc","tarball":"https://registry.npmjs.org/@cabysis/candy-client/-/candy-client-1.0.2.tgz","fileCount":17,"integrity":"sha512-gEJF05JjI9Aubu4TQg24EmxvMYh0U1vMkMjPzeBsYBW/RlWux8Ds1Ft5MLDmZPIaBv6oVqTd6NNv7eWmpDO3/Q==","signatures":[{"sig":"MEYCIQCQGrGYlhXMvwcAv0rvAaYPj4wxqWLlsyy08tXtzBJGIQIhAMoZ9d3grcAREZ5RnCUDouLJcHmOwqnWebHxRAVUkxGu","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16227},"main":"dist/client/index.js","types":"dist/client/index.d.ts","gitHead":"13099e3ebe69f9fb05838855e23bf1f458ebb7c1","scripts":{"dev":"npm run build && node dist/local-runner.js","test":"jest","build":"tsc"},"_npmUser":{"name":"dev-cabysis","email":"dev@cabysis.com"},"repository":{"url":"git+https://github.com/cabysis/candy-client.git","type":"git"},"_npmVersion":"10.5.0","description":"HTTP Client for making request with native fetch library","directories":{},"_nodeVersion":"21.7.3","dependencies":{"reflect-metadata":"^0.2.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.2.2","prettier":"^3.3.3","typescript":"^5.5.3","@types/jest":"^29.5.12"},"_npmOperationalInternal":{"tmp":"tmp/candy-client_1.0.2_1722534050878_0.5595299632100648","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"@cabysis/candy-client","version":"1.0.3","keywords":["http","requests","fetch","ts","typescript","client","web"],"author":{"name":"CabySis"},"license":"MIT","_id":"@cabysis/candy-client@1.0.3","maintainers":[{"name":"dev-cabysis","email":"dev@cabysis.com"}],"homepage":"https://github.com/cabysis/candy-client#readme","bugs":{"url":"https://github.com/cabysis/candy-client/issues"},"dist":{"shasum":"1cae7bc2def9c864c1cd51db75bcd93416f5b401","tarball":"https://registry.npmjs.org/@cabysis/candy-client/-/candy-client-1.0.3.tgz","fileCount":17,"integrity":"sha512-O+V6SZ79aDeKABQd6OmS6j3EkL/XODFUtOvpRZlE0R2TRfQmSTTLFHwn6CK5m+BGI3E3f7dHfrARlH+qJRyEuA==","signatures":[{"sig":"MEQCIDBOR0kCVQoILg5j7n0QIELk2UIqdAfWJeXidsG9b4hfAiAUgIKyi76RNGkqe7vYvwV/7CYe0zBq0GpVAm/OO1si7g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16686},"main":"dist/client/index.js","types":"dist/client/index.d.ts","gitHead":"bcbc106905b5c1229bda526a723d9198ec6b00a6","scripts":{"dev":"npm run build && node dist/local-runner.js","test":"jest","build":"tsc"},"_npmUser":{"name":"dev-cabysis","email":"dev@cabysis.com"},"repository":{"url":"git+https://github.com/cabysis/candy-client.git","type":"git"},"_npmVersion":"10.5.0","description":"HTTP Client for making request with native fetch library","directories":{},"_nodeVersion":"21.7.3","dependencies":{"reflect-metadata":"^0.2.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.2.2","prettier":"^3.3.3","typescript":"^5.5.3","@types/jest":"^29.5.12"},"_npmOperationalInternal":{"tmp":"tmp/candy-client_1.0.3_1723521878694_0.2727413860274166","host":"s3://npm-registry-packages"}},"1.0.4":{"name":"@cabysis/candy-client","version":"1.0.4","keywords":["http","requests","fetch","ts","typescript","client","web"],"author":{"name":"CabySis"},"license":"MIT","_id":"@cabysis/candy-client@1.0.4","maintainers":[{"name":"dev-cabysis","email":"dev@cabysis.com"}],"homepage":"https://github.com/cabysis/candy-client#readme","bugs":{"url":"https://github.com/cabysis/candy-client/issues"},"dist":{"shasum":"7fb1a806d3ee9a2aa9c4b779b95de274747abb7a","tarball":"https://registry.npmjs.org/@cabysis/candy-client/-/candy-client-1.0.4.tgz","fileCount":17,"integrity":"sha512-uyHC6CYL4KyIjcNPYeJql4uxhXNr7j0WB7ycmQmw6iWwyrkqYf9VfFKW/vMM6dy6PZ/wrDspxE1DmoRk4KkITA==","signatures":[{"sig":"MEUCIQDHr1wsQjL58gNnQTlAmvHZyd0gBhfDv8xXTO1gLpHVRAIgdmCFDild9EtMOLWPyPsZyMSCKOBWFD22wWBhHVjb/P8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16709},"main":"dist/client/index.js","types":"dist/client/index.d.ts","gitHead":"b358e7d44dc5a2e5f5a2dc0ca9fd1a9c00bee22a","scripts":{"dev":"npm run build && node dist/local-runner.js","test":"jest","build":"tsc"},"_npmUser":{"name":"dev-cabysis","email":"dev@cabysis.com"},"repository":{"url":"git+https://github.com/cabysis/candy-client.git","type":"git"},"_npmVersion":"10.5.0","description":"HTTP Client for making request with native fetch library","directories":{},"_nodeVersion":"21.7.3","dependencies":{"reflect-metadata":"^0.2.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.2.2","prettier":"^3.3.3","typescript":"^5.5.3","@types/jest":"^29.5.12"},"_npmOperationalInternal":{"tmp":"tmp/candy-client_1.0.4_1723657203035_0.5830204651846214","host":"s3://npm-registry-packages"}},"1.0.5":{"devDependencies":{"@types/jest":"^29.5.12","jest":"^29.7.0","prettier":"^3.3.3","ts-jest":"^29.2.2","typescript":"^5.5.3"},"name":"@cabysis/candy-client","version":"1.0.5","description":"HTTP Client for making request with native fetch library","main":"dist/client/index.js","types":"dist/client/index.d.ts","scripts":{"build":"tsc","dev":"npm run build && node dist/local-runner.js","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/cabysis/candy-client.git"},"keywords":["http","requests","fetch","ts","typescript","client","web"],"author":{"name":"CabySis"},"license":"MIT","bugs":{"url":"https://github.com/cabysis/candy-client/issues"},"homepage":"https://github.com/cabysis/candy-client#readme","dependencies":{"reflect-metadata":"^0.2.2"},"_id":"@cabysis/candy-client@1.0.5","gitHead":"2fa9627c8745df58e8e161c9c0133e9cbcc9fa94","_nodeVersion":"21.7.3","_npmVersion":"10.5.0","dist":{"integrity":"sha512-Fy9qbz8kVxfEsaRHfC+hCgRYfcidY7fRhvx75aiF17Da230PYCpUZA0kuGtu8lj3SI4Y3Y0sg+Y70+BX5qAPlg==","shasum":"90d135aa4bc6031fae2718abb7f975e64e0ce400","tarball":"https://registry.npmjs.org/@cabysis/candy-client/-/candy-client-1.0.5.tgz","fileCount":17,"unpackedSize":36010,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDFRUKlssM1NVTNIVtDH1Jshu+w7Wb16U3l4sAEP9wEDwIhAKqTH6MNAikP2I+C5KD2LyFZd2UwflaNl+ViQhOkG3O/"}]},"_npmUser":{"name":"arturotphx","email":"arturo.garcia@cabysis.com"},"directories":{},"maintainers":[{"name":"dev-cabysis","email":"dev@cabysis.com"},{"name":"arturotphx","email":"arturo.garcia@cabysis.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/candy-client_1.0.5_1734110504275_0.8252687691780578"},"_hasShrinkwrap":false}},"time":{"created":"2024-07-17T05:54:00.008Z","modified":"2024-12-13T17:21:44.715Z","1.0.0":"2024-07-17T05:54:00.278Z","1.0.1":"2024-07-17T14:16:40.204Z","1.0.2":"2024-08-01T17:40:51.063Z","1.0.3":"2024-08-13T04:04:38.868Z","1.0.4":"2024-08-14T17:40:03.205Z","1.0.5":"2024-12-13T17:21:44.482Z"},"bugs":{"url":"https://github.com/cabysis/candy-client/issues"},"author":{"name":"CabySis"},"license":"MIT","homepage":"https://github.com/cabysis/candy-client#readme","keywords":["http","requests","fetch","ts","typescript","client","web"],"repository":{"type":"git","url":"git+https://github.com/cabysis/candy-client.git"},"description":"HTTP Client for making request with native fetch library","maintainers":[{"name":"dev-cabysis","email":"dev@cabysis.com"},{"name":"arturotphx","email":"arturo.garcia@cabysis.com"}],"readme":"# HTTP Client\n\nMake HTTP Requests in a pretty easy way!\nConfigure all your microservices endpoints in different modules and send requests!\n\n## Usage\n\nYou can use this library after installation as this example:\n\n```typescript\nimport { CandyClient, CandyClientOptions } from \"./client\";\n\n// Example static function to retrieve a JWT token\n// This function simulates retrieving a token for authorization purposes.\nfunction getToken(): string {\n  return \"generic-jwt-token\"; // Replace with actual logic to retrieve JWT token dynamically.\n}\n\n// Shared configuration options for CandyClient\n// These options are applied to all client instances by default.\nconst sharedOptions: CandyClientOptions = {\n  baseUrl: \"http://localhost:8080/\", // Base URL for the API endpoints\n  headers: {\n    Accept: \"application/json\", // Indicate that JSON is expected in responses\n    \"Content-Type\": \"application/json\", // Specify that JSON is sent in requests\n    \"Access-Control-Allow-Origin\": \"*\", // Allow cross-origin requests (CORS)\n  },\n  getToken: getToken, // Reference to the function that retrieves the JWT token\n};\n\n// Representation of a User entity\n// Defines the structure of user data expected from the API.\nclass User {\n  id: number; // Unique identifier for the user\n  name: string; // Name of the user\n  email: string; // Email address of the user\n}\n\n// Example client class for interacting with the authentication service\n// Extends the generic CandyClient to include specific auth-related methods.\nclass AuthClient extends CandyClient {\n  constructor() {\n    super(sharedOptions); // Initialize the client with shared configuration options\n  }\n\n  // Method to sign in a user using email and password\n  // Sends a POST request to the /auth/sign-in endpoint.\n  async signIn(email: string, password: string): Promise<void> {\n    return this.post<void>(\"/auth/sign-in\", { email, password });\n  }\n\n  // Method to retrieve a list of all users\n  // Sends a GET request to the /auth/users endpoint and returns a list of User objects.\n  async getUsers(): Promise<User[]> {\n    return this.get<User[]>(\"/auth/users\");\n  }\n\n  // Method to retrieve credentials with custom headers\n  // Sends a GET request to the /auth/credentials endpoint and overrides default headers.\n  async getCredentials(): Promise<{ password: string; token: string }> {\n    return this.get<{ password: string; token: string }>(\"/auth/credentials\", {\n      headers: {\n        Authorization: \"<Custom credential>\", // Example of a custom Authorization header\n        \"Content-Type\": \"application/json\",\n      },\n    });\n  }\n\n  // Method to upload a profile photo using multipart form data\n  // Sends a POST request to the /auth/profile/photo endpoint with a file in FormData format.\n  async uploadProfilePhoto(file: File): Promise<void> {\n    const formData = new FormData();\n    formData.append(\"file\", file); // Append the file to the FormData object\n    return this.post<void>(\"/auth/profile/photo\", formData, {\n      isMultipart: true, // Flag to indicate multipart form data is being used\n    });\n  }\n\n  // Method to retrieve a profile photo as a Blob object\n  // Sends a GET request to the /auth/profile/photo endpoint with Blob parsing enabled.\n  async getProfilePhoto(): Promise<Blob> {\n    return this.get<Blob>(\"/auth/profile/photo\", {\n      parseBlob: true, // Flag to parse the response as a Blob\n    });\n  }\n\n  // Method to retrieve raw profile data as a Response object\n  // Sends a GET request to the /auth/profile endpoint without parsing the response.\n  async getProfileData(): Promise<Response> {\n    return this.get<Response>(\"/auth/profile\", {\n      parseResponse: false, // Flag to return the raw response object\n    });\n  }\n}\n\n// Example use case for the sign-in request\n// Demonstrates how to use the AuthClient to sign in a user.\nasync function signIn(email: string, password: string): Promise<void> {\n  try {\n    const authClient = new AuthClient(); // Create an instance of the AuthClient\n    await authClient.signIn(email, password); // Attempt to sign in with the provided credentials\n    console.log(\"Sign-in successful\"); // Log success message if sign-in is successful\n  } catch (error) {\n    console.error(\"Sign-in failed:\", error); // Log an error message if sign-in fails\n  }\n}\n\n```\n\n","readmeFilename":"Readme.md"}