open-index/open-npm huggingface dataset:
npm package: @reyronald/async-local-storage
Description: Utility wrappers around node:async_hooks
Author: Ronald Rey
Latest version: 1.1.0

# @reyronald/async-local-storage

Allows you to share data across a chain of asynchronous or synchronous function calls without having to prop drill it through function arguments.

Most often used with `express` or any HTTP Server to store values like user state, claims from a JWT, correlation IDs, etc.

Better alternative to https://npm.im/continuation-local-storage, https://npm.im/cls-hooked and https://npm.im/express-http-context because those use a deprecated experimental and unsafe legacy Node.js API ([https://nodejs.org/api/async_hooks.html](async_hooks)). This one uses [AsyncLocalStorage](https://nodejs.org/api/async_context.html#class-asynclocalstorage) which is already stable and the currently recommended best practice.

```sh
npm i @reyronald/async-local-storage
```

Usage:

```ts
import { getAsyncContext } from "@reyronald/async-local-storage"

type Store = { correlationId: string }

const { ctx, runWithAsyncContext } = getAsyncContext<Store>(
  "correlationId-context",
  { correlationId: "default-correlationId" },
  {
    onError: (error) => {
      console.error("Error occurred in async context:", error)
    },
  },
)

// Wrap the start of the function chain that needs to have access to the context
runWithAsyncContext(
  // Provide an initial store
  { correlationId: ":correlationId" },
  // Start of the chain
  () => {
    foo()
  },
)

// ...

// Now every function call in this chain will
// have access to `ctx` and its contents
function foo() {
  bar()
}
function bar() {
  baz()
}
function baz() {
  fn(ctx.correlationId) // ":correlationId"
}
```

Example with `express`:

```ts
const app = express()

app
  .use((req, _res, next) => {
    runWithAsyncContext({ correlationId: ":correlationId" }, () => next())
  })
  .get("/api/async-context-test", (_req, res) => {
    return res.send(ctx.correlationId)
  })
```

### TODO

- [ ] Setup prettier commit hooks
- [ ] Autogenerate definition files .d.ts
- [ ] eslint
npm package: @reyura/medusa-file-gcs
Description: GCS file connector for Medusa
Author: yura
Latest version: 0.0.3

# medusa-file-gcs

## Features

- Store product images on Google Cloud Storage.
- Support for importing and exporting data through CSV files, such as Products or Prices.
- Support for both private and public buckets.


## How to Install

1\. Run the following command in the directory of the Medusa backend:

  ```bash
  npm install @reyura/medusa-file-gcs
  ```

2\. Set the following environment variables in `.env`:

  ```bash
  GCS_PROJECT_ID=<GCS_PROJECT_ID>
  GCS_BUCKET=<GCS_BUCKET>
  GCS_PRIVATE_BUCKET=<GCS_PRIVATE_BUCKET>
  GCS_EMAIL=<GCS_EMAIL>
  GCS_PRIVATE_KEY=<GCS_PRIVATE_KEY>
  GCS_PRIVATE_EMAIL=<GCS_PRIVATE_EMAIL>
  GCS_PRIVATE_PRIVATE_KEY=<GCS_PRIVATE_PRIVATE_KEY>
  ```

3\. In `medusa-config.js` add the following at the end of the `plugins` array:

  ```js
  const plugins = [
    // ...
    {
      resolve: `@reyura/medusa-file-gcs`,
      options: {
        projectId: process.env.GCS_PROJECT_ID,
        bucketName: process.env.GCS_BUCKET,
        privatebucketName: process.env.GCS_PRIVATE_BUCKET,
        email: process.env.GCS_EMAIL,
        privateKey: process.env.GCS_PRIVATE_KEY.replace(/\\n/g, "\n"),
        privateEmail: process.env.GCS_PRIVATE_EMAIL,
        privatePrivateKey: process.env.GCS_PRIVATE_PRIVATE_KEY.replace(/\\n/g, "\n"),
      },
    },
  ]
  ```