{"id":19693895,"url":"https://github.com/lemoncloud-io/lemon-web-core","last_synced_at":"2025-04-29T10:30:41.223Z","repository":{"id":241892936,"uuid":"806890856","full_name":"lemoncloud-io/lemon-web-core","owner":"lemoncloud-io","description":"Core Web-based Library for signing request at LEMONCLOUD ","archived":false,"fork":false,"pushed_at":"2024-10-18T04:27:35.000Z","size":776,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-10-18T07:12:10.020Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://tech.lemoncloud.io/lemon-web-core/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lemoncloud-io.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2024-05-28T05:36:12.000Z","updated_at":"2024-10-18T04:27:17.000Z","dependencies_parsed_at":"2024-10-20T20:10:50.698Z","dependency_job_id":null,"html_url":"https://github.com/lemoncloud-io/lemon-web-core","commit_stats":null,"previous_names":["lemoncloud-io/lemon-web-core"],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemoncloud-io%2Flemon-web-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemoncloud-io%2Flemon-web-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemoncloud-io%2Flemon-web-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemoncloud-io%2Flemon-web-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lemoncloud-io","download_url":"https://codeload.github.com/lemoncloud-io/lemon-web-core/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251483640,"owners_count":21596576,"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":"2024-11-11T19:18:52.298Z","updated_at":"2025-04-29T10:30:41.212Z","avatar_url":"https://github.com/lemoncloud-io.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cdiv\u003e\n    \u003ch1 align=\"center\"\u003eLemonWebCore\u003c/h1\u003e\n  \u003c/div\u003e\n  \u003cp\u003e\n    LemonWebCore is a library designed for API requests and user authentication management in web-based projects for different cloud providers such as AWS, Azure, and GCP at LemonCloud.\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\" markdown=\"1\"\u003e\n\n[![lemoncloud](https://img.shields.io/badge/by-LEMONCLOUD-ED6F31?logo=github)](https://github.com/lemoncloud-io)\n[![license](https://img.shields.io/badge/license-MIT-151515.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHN0cm9rZT0iI0ZGRiIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZS13aWR0aD0iMiIgZD0ibTMgNiAzIDFtMCAwLTMgOWE1IDUgMCAwIDAgNi4wMDEgME02IDdsMyA5TTYgN2w2LTJtNiAyIDMtMW0tMyAxLTMgOWE1IDUgMCAwIDAgNi4wMDEgME0xOCA3bDMgOW0tMy05LTYtMm0wLTJ2Mm0wIDE2VjVtMCAxNkg5bTMgMGgzIi8+PC9zdmc+)](https://github.com/lemoncloud-io/lemon-web-core/blob/main/LICENSE)\n[![version](https://img.shields.io/npm/v/@lemoncloud/lemon-web-core?logo=semanticrelease\u0026label=release\u0026color=C73659)](https://www.npmjs.com/package/@lemoncloud/lemon-web-core)\n[![downloads](https://img.shields.io/npm/dt/@lemoncloud/lemon-web-core?color=A91D3A\u0026logo=npm)](https://www.npmjs.com/package/@lemoncloud/lemon-web-core)\n\n\u003c/div\u003e\n\n---\n\n## Table of Contents\n\n-   [Installation](#installation)\n-   [Usage](#usage)\n    -   [WebCoreFactory](#webcorefactory)\n    -   [AWSWebCore](#awswebcore)\n    -   [AzureWebCore](#azurewebcore)\n-   [API Reference](#api-reference)\n-   [Troubleshooting](#troubleshooting)\n\n## Installation\n\nYou can install the LemonWebCore Library via npm:\n\n```bash\nnpm install @lemoncloud/lemon-web-core\n```\n\n## Usage\n\nThe LemonWebCore Library allows you to create and use instances for different cloud providers. Below are the usage examples for WebCoreFactory, AWSWebCore, and AzureWebCore.\nPlease see [documentation](https://tech.lemoncloud.io/lemon-web-core/) for more information.\n\n### WebCoreFactory\n\nThe `WebCoreFactory` is used to create instances of `AWSWebCore` or `AzureWebCore` based on the cloud provider configuration.\n\n-   AWSWebCore\n\n```typescript\nimport { WebCoreFactory, WebCoreConfig } from '@lemoncloud/lemon-web-core';\n\nconst config: WebCoreConfig\u003c'aws'\u003e = {\n    cloud: 'aws',\n    project: 'my-aws-project',\n    oAuthEndpoint: 'https://example.com/oauth',\n    region: 'us-west-2',\n};\nconst awsWebCore = WebCoreFactory.create(config);\nawait awsWebCore.init();\n```\n\n-   AzureWebCore\n\n```typescript\nconst azureConfig: WebCoreConfig\u003c'azure'\u003e = {\n    cloud: 'azure',\n    project: 'my-azure-project',\n    oAuthEndpoint: 'https://example.com/oauth',\n};\n\nconst azureWebCore = WebCoreFactory.create(azureConfig);\nawait azureWebCore.init();\n```\n\n### AWSWebCore\n\nThe `AWSWebCore` class handles AWS-specific web core operations. Here is an example of how to use it:\n\n```typescript\nimport { AWSWebCore, WebCoreConfig } from '@lemoncloud/lemon-web-core';\n\nconst config: WebCoreConfig\u003c'aws'\u003e = {\n    cloud: 'aws',\n    project: 'my-aws-project',\n    oAuthEndpoint: 'https://example.com/oauth',\n    region: 'us-west-2',\n};\n\nconst awsWebCore = new AWSWebCore(config);\n\n// Initialize\nawait awsWebCore.init();\n\n// Make a signed request\nconst response = await awsWebCore.signedRequest('GET', 'https://example.com/api/resource');\nconsole.log(response.data);\n\n// Make a signed request with Builder\nconst example = await awsWebCore\n    .buildSignedRequest({\n        method: 'GET',\n        baseURL: `https://api.lemoncloud.io/v1/oauth`,\n    })\n    .setParams({ page: 0 })\n    .setBody({ date: 'example' })\n    .execute();\n\n// Check authentication status\nconst isAuthenticated = await awsWebCore.isAuthenticated();\nconsole.log(isAuthenticated);\n```\n\n### AzureWebCore\n\nThe `AzureWebCore` class handles Azure-specific web core operations. Here is an example of how to use it:\n\n```typescript\nimport { AzureWebCore, WebCoreConfig } from '@lemoncloud/lemon-web-core';\n\nconst config: WebCoreConfig\u003c'azure'\u003e = {\n    cloud: 'azure',\n    project: 'my-azure-project',\n    oAuthEndpoint: 'https://example.com/oauth',\n};\n\nconst azureWebCore = new AzureWebCore(config);\n\n// Initialize\nawait azureWebCore.init();\n\n// Make a signed request\nconst response = await azureWebCore.signedRequest('GET', 'https://example.com/api/resource');\nconsole.log(response.data);\n\n// Make a signed request with Builder\nconst example = await azureWebCore\n    .buildSignedRequest({\n        method: 'GET',\n        baseURL: `https://api.lemoncloud.io/v1/oauth`,\n    })\n    .setParams({ page: 0 })\n    .setBody({ date: 'example' })\n    .execute();\n\n// Check authentication status\nconst isAuthenticated = await azureWebCore.isAuthenticated();\nconsole.log(isAuthenticated);\n```\n\n## API Reference\n\n### WebCoreFactory\n\n-   `create\u003cT extends WebCoreService\u003e(config: WebCoreConfig\u003cCloudProvider\u003e): T`\n\nCreates an instance of `AWSWebCore` or `AzureWebCore` based on the provided cloud provider configuration.\n\n### AWSWebCore\n\n-   `constructor(config: WebCoreConfig\u003c'aws'\u003e)`\n\nCreates an instance of `AWSWebCore` with the specified configuration.\n\n-   `init(): Promise\u003cvoid\u003e`\n\nInitializes the AWSWebCore instance.\n\n-   `signedRequest\u003cT\u003e(method: string, url: string, params?: Params, body?: Body, config?: AxiosRequestConfig): Promise\u003cHttpResponse\u003cT\u003e\u003e`\n\nMakes a signed HTTP request.\n\n-   `isAuthenticated(): Promise\u003cboolean\u003e`\n\nChecks if the user is authenticated.\n\n-   `saveOAuthToken(token: LemonOAuthToken): Promise\u003cvoid\u003e`\n\nSaves the OAuth token.\n\n-   `logout(): Promise\u003cvoid\u003e`\n\nLogs the user out by clearing the OAuth token.\n\n-   `setUseXLemonIdentity(use: boolean): Promise\u003cvoid\u003e`\n\nSets whether to use the x-lemon-identity header.\n\n### AzureWebCore\n\n-   `constructor(config: WebCoreConfig\u003c'azure'\u003e)`\n\nCreates an instance of `AzureWebCore` with the specified configuration.\n\n-   `init(): Promise\u003cvoid\u003e`\n\nInitializes the AzureWebCore instance.\n\n-   `signedRequest\u003cT\u003e(method: string, url: string, params?: Params, body?: Body, config?: AxiosRequestConfig): Promise\u003cHttpResponse\u003cT\u003e\u003e`\n\nMakes a signed HTTP request.\n\n-   `isAuthenticated(): Promise\u003cboolean\u003e`\n\nChecks if the user is authenticated.\n\n-   `saveOAuthToken(token: LemonOAuthToken): Promise\u003cvoid\u003e`\n\nSaves the OAuth token.\n\n-   `logout(): Promise\u003cvoid\u003e`\n\nLogs the user out by clearing the OAuth token.\n\n-   `setUseXLemonIdentity(use: boolean): Promise\u003cvoid\u003e`\n\nSets whether to use the x-lemon-identity header.\n\n## Axios Instance Management\n\nThe WebCore provides a shared Axios instance management feature. This allows you to configure a single Axios instance that can be reused across multiple requests, which is particularly useful for setting up global interceptors or common configurations.\n\n### Getting the Shared Axios Instance\n\n```typescript\nconst webCore = WebCoreFactory.create({ cloud: 'aws', ... });\nconst axiosInstance = webCore.getSharedAxiosInstance();\n```\n\n### Setting Up Interceptors\n\n```typescript\n// Request Interceptor\nwebCore.getSharedAxiosInstance().interceptors.request.use(config =\u003e {\n    // Add custom headers or modify request config\n    return config;\n});\n\n// Response Interceptor\nwebCore.getSharedAxiosInstance().interceptors.response.use(response =\u003e {\n    // Process response data\n    return response;\n});\n```\n\n### Usage with Builders\n\nThe shared Axios instance is automatically used when creating request builders:\n\n```typescript\n// Using with regular request builder\nconst request = webCore.buildRequest({\n    method: 'GET',\n    baseURL: 'https://api.example.com',\n});\n\n// Using with AWS signed request builder\nconst signedRequest = webCore.buildSignedRequest({\n    method: 'GET',\n    baseURL: 'https://api.example.com',\n});\n```\n\nBoth builders will use the same shared Axios instance, ensuring that any global configurations or interceptors are consistently applied across all requests.\n\n## Troubleshooting\n\nPlease follow this guidelines when reporting bugs and feature requests:\n\n1. Use [GitHub Issues](https://github.com/lemoncloud-io/lemon-web-core/issues) board to report bugs and feature requests (not our email address)\n2. Please **always** write steps to reproduce the error. That way we can focus on fixing the bug, not scratching our heads trying to reproduce it.\n\nThanks for understanding!\n\n## Please Star ⭐️\n\nIf this project has been helpful to you, I would greatly appreciate it if you could click the Star⭐️ button on this repository!\n\n## Maintainers\n\n-   [Hyungtak Jin](https://github.com/louis-lemon)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemoncloud-io%2Flemon-web-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemoncloud-io%2Flemon-web-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemoncloud-io%2Flemon-web-core/lists"}