npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lemoncloud/lemon-web-core

v1.2.3

Published

Core Web-based Library for signing request at LEMONCLOUD

Downloads

256

Readme

lemoncloud license version downloads


Table of Contents

Installation

You can install the LemonWebCore Library via npm:

npm install @lemoncloud/lemon-web-core

Usage

The LemonWebCore Library allows you to create and use instances for different cloud providers. Below are the usage examples for WebCoreFactory, AWSWebCore, and AzureWebCore. Please see documentation for more information.

WebCoreFactory

The WebCoreFactory is used to create instances of AWSWebCore or AzureWebCore based on the cloud provider configuration.

  • AWSWebCore
import { WebCoreFactory, WebCoreConfig } from '@lemoncloud/lemon-web-core';

const config: WebCoreConfig<'aws'> = {
    cloud: 'aws',
    project: 'my-aws-project',
    oAuthEndpoint: 'https://example.com/oauth',
    region: 'us-west-2',
};
const awsWebCore = WebCoreFactory.create(config);
await awsWebCore.init();
  • AzureWebCore
const azureConfig: WebCoreConfig<'azure'> = {
    cloud: 'azure',
    project: 'my-azure-project',
    oAuthEndpoint: 'https://example.com/oauth',
};

const azureWebCore = WebCoreFactory.create(azureConfig);
await azureWebCore.init();

AWSWebCore

The AWSWebCore class handles AWS-specific web core operations. Here is an example of how to use it:

import { AWSWebCore, WebCoreConfig } from '@lemoncloud/lemon-web-core';

const config: WebCoreConfig<'aws'> = {
    cloud: 'aws',
    project: 'my-aws-project',
    oAuthEndpoint: 'https://example.com/oauth',
    region: 'us-west-2',
};

const awsWebCore = new AWSWebCore(config);

// Initialize
await awsWebCore.init();

// Make a signed request
const response = await awsWebCore.signedRequest('GET', 'https://example.com/api/resource');
console.log(response.data);

// Make a signed request with Builder
const example = await awsWebCore
    .buildSignedRequest({
        method: 'GET',
        baseURL: `https://api.lemoncloud.io/v1/oauth`,
    })
    .setParams({ page: 0 })
    .setBody({ date: 'example' })
    .execute();

// Check authentication status
const isAuthenticated = await awsWebCore.isAuthenticated();
console.log(isAuthenticated);

AzureWebCore

The AzureWebCore class handles Azure-specific web core operations. Here is an example of how to use it:

import { AzureWebCore, WebCoreConfig } from '@lemoncloud/lemon-web-core';

const config: WebCoreConfig<'azure'> = {
    cloud: 'azure',
    project: 'my-azure-project',
    oAuthEndpoint: 'https://example.com/oauth',
};

const azureWebCore = new AzureWebCore(config);

// Initialize
await azureWebCore.init();

// Make a signed request
const response = await azureWebCore.signedRequest('GET', 'https://example.com/api/resource');
console.log(response.data);

// Make a signed request with Builder
const example = await azureWebCore
    .buildSignedRequest({
        method: 'GET',
        baseURL: `https://api.lemoncloud.io/v1/oauth`,
    })
    .setParams({ page: 0 })
    .setBody({ date: 'example' })
    .execute();

// Check authentication status
const isAuthenticated = await azureWebCore.isAuthenticated();
console.log(isAuthenticated);

API Reference

WebCoreFactory

  • create<T extends WebCoreService>(config: WebCoreConfig<CloudProvider>): T

Creates an instance of AWSWebCore or AzureWebCore based on the provided cloud provider configuration.

AWSWebCore

  • constructor(config: WebCoreConfig<'aws'>)

Creates an instance of AWSWebCore with the specified configuration.

  • init(): Promise<void>

Initializes the AWSWebCore instance.

  • signedRequest<T>(method: string, url: string, params?: Params, body?: Body, config?: AxiosRequestConfig): Promise<HttpResponse<T>>

Makes a signed HTTP request.

  • isAuthenticated(): Promise<boolean>

Checks if the user is authenticated.

  • saveOAuthToken(token: LemonOAuthToken): Promise<void>

Saves the OAuth token.

  • logout(): Promise<void>

Logs the user out by clearing the OAuth token.

  • setUseXLemonIdentity(use: boolean): Promise<void>

Sets whether to use the x-lemon-identity header.

AzureWebCore

  • constructor(config: WebCoreConfig<'azure'>)

Creates an instance of AzureWebCore with the specified configuration.

  • init(): Promise<void>

Initializes the AzureWebCore instance.

  • signedRequest<T>(method: string, url: string, params?: Params, body?: Body, config?: AxiosRequestConfig): Promise<HttpResponse<T>>

Makes a signed HTTP request.

  • isAuthenticated(): Promise<boolean>

Checks if the user is authenticated.

  • saveOAuthToken(token: LemonOAuthToken): Promise<void>

Saves the OAuth token.

  • logout(): Promise<void>

Logs the user out by clearing the OAuth token.

  • setUseXLemonIdentity(use: boolean): Promise<void>

Sets whether to use the x-lemon-identity header.

Troubleshooting

Please follow this guidelines when reporting bugs and feature requests:

  1. Use GitHub Issues board to report bugs and feature requests (not our email address)
  2. 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.

Thanks for understanding!

Please Star ⭐️

If this project has been helpful to you, I would greatly appreciate it if you could click the Star⭐️ button on this repository!

Maintainers