open-index/open-npm huggingface dataset:
npm package: @platformatic/acme-base
Description: The base to all Acme Inc. microservices
Author: Matteo Collina
Latest version: 0.2.0

# @platformatic/acme-base

This is foundation piece for all Acme development.
All microservices developed in Acme use this tool.

## Install

```bash
npm install platformatic @platformatic/acme-base
```

## Usage

Create a file `platformatic.json` in your root folder:

```json
{
  "$schema": "https://raw.githubusercontent.com/platformatic/acme-base/main/schemas/1.json",
  "module": "../index.js",
  "server": {
    "hostname": "{{HOSTNAME}}",
    "port": "{{PORT}}"
  },
  "dynamite": true,
  "watch": "{{WATCH}}"
}
```

`HOSTNAME`, `PORT` and `WATCH` are environment variables that are automatically loaded from a `.env` file
in the folder, like so:

```
WATCH=true
HOSTNAME=127.0.0.1
PORT=8080
```

Utilities should be placed inside the `plugins/` folder, while [routes](https://fastify.dev/docs/latest/Reference/Routes/#routes) should be defined in `routes/` .
Both should be defined as Fastify [plugins](https://fastify.dev/docs/latest/Reference/Plugins).


## License

Apache-2.0
npm package: @platformatic/authenticate
Description: Generate a Platformatic login api key.
Author: Platformatic.dev
Latest version: 1.50.0

# @platformatic/authenticate

Generate a Platformatic login api key.

``` bash
 $ platformatic deploy
```

Options:

* `-c, --config FILE` - Specify a path to a global platformatic config file. Defaults to `~/.platformatic/config.json`.
* `--browser` - Automatically open default browser. Defaults to `false`.
npm package: @platformatic/basic
Description: Check out the full documentation for Platformatic on [our website](https://docs.platformatic.dev).
Author: Platformatic Inc.
Latest version: 3.52.0

# @platformatic/basic

Check out the full documentation for Platformatic on [our website](https://docs.platformatic.dev).

## Install

```sh
npm install @platformatic/basic
```

## License

Apache 2.0
npm package: @platformatic/bus
Description: A simple Bus implementation for inter-thread communication.
Author: Paolo Insogna
Latest version: 1.53.4

# @platformatic/bus

A simple Bus implementation for inter-thread communication.

Check out the full documentation for Platformatic DB on [our website](https://docs.platformatic.dev/docs/getting-started/quick-start-guide).

## Install

```sh
npm install @platformatic/bus
```

## Usage

**main.js**

```js
import { Bus } from '@platformatic/bus'

const bus = new Bus('root')
bus.send('worker', 'message')
```

**worker.js**

```js
import { Bus } from '@platformatic/bus'

const bus = new Bus('worker')
bus.on('message', message => console.log(message))
```

## License

Apache 2.0
npm package: @platformatic/client
Description: A client for all platformatic backends
Author: Platformatic Inc.
Latest version: 2.75.2

# @platformatic/client

Check out the full documentation for Platformatic Client on [our website](https://docs.platformatic.dev/docs/reference/client/overview).

## Install

```sh
npm install @platformatic/client
```

## License

Apache 2.0
npm package: @platformatic/client-cli
Description: A client for all platformatic backends
Author: Platformatic Inc.
Latest version: 2.75.2

# @platformatic/client

Check out the full documentation for Platformatic Client on [our website](https://docs.platformatic.dev/docs/reference/client/overview).

## Install

```sh
npm install @platformatic/client
```

## Useful links

* [ts-morph](https://www.npmjs.com/package/ts-morph)
* [amplify-codegen](https://github.com/aws-amplify/amplify-codegen/tree/main/packages/graphql-types-generator)


## License

Apache 2.0
npm package: @platformatic/composer
Description: Platformatic Composer provides API composition capabilities for aggregating multiple services. See [@platformatic/gateway](../gateway) for the full API gateway package.
Author: Platformatic Inc.
Latest version: 3.52.0

# @platformatic/composer

Platformatic Composer provides API composition capabilities for aggregating multiple services. See [@platformatic/gateway](../gateway) for the full API gateway package.

Check out the full documentation on [our website](https://docs.platformatic.dev/docs/reference/gateway/overview).

## Install

```sh
npm install @platformatic/composer
```

## License

Apache 2.0
npm package: @platformatic/db
Description: Check out the full documentation for Platformatic DB on [our website](https://docs.platformatic.dev/docs/reference/db/overview).
Author: Platformatic Inc.
Latest version: 3.52.0

# @platformatic/db

Check out the full documentation for Platformatic DB on [our website](https://docs.platformatic.dev/docs/reference/db/overview).

## Install

```sh
npm install @platformatic/db
```

## License

Apache 2.0
npm package: @platformatic/db-authorization
Description: Fastify plugin that adds role-based authorization hooks to [`@platformatic/sql-mapper`](https://www.npmjs.com/package/@platformatic/sql-mapper).
Author: Platformatic Inc.
Latest version: 3.52.0

# @platformatic/db-authorization

Fastify plugin that adds role-based authorization hooks to [`@platformatic/sql-mapper`](https://www.npmjs.com/package/@platformatic/sql-mapper).

Check out the full documentation on [our website](https://docs.platformatic.dev/docs/reference/db/authorization/overview).

## Install

```sh
npm install @platformatic/db-authorization
```

## License

Apache 2.0
npm package: @platformatic/db-core
Description: This modules wraps [`@platformatic/sql-mapper`](https://www.npmjs.com/package/@platformatic/sql-mapper), [`@platformatic/sql-graphql`](https://www.npmjs.com/package/@platformatic/sql-graphql) and [`@platformatic/sql-openapi`](https://www.npmjs.com/package
Author: Platformatic Inc.
Latest version: 3.52.0

# @platformatic/db-core

This modules wraps [`@platformatic/sql-mapper`](https://www.npmjs.com/package/@platformatic/sql-mapper),
[`@platformatic/sql-graphql`](https://www.npmjs.com/package/@platformatic/sql-graphql) and
[`@platformatic/sql-openapi`](https://www.npmjs.com/package/@platformatic/sql-openapi) in a convenient [Fastify](https://www.fastify.io/)
plugin.

Check out the full documentation for Platformatic DB on [our website](https://docs.platformatic.dev/docs/getting-started/quick-start).

## Install

```sh
npm install @platformatic/db-core
```

## Usage

```js
import fastify from 'fastify'
import db from '@platformatic/db-core'

const app = Fastify()
app.register(db, {
  // connectionString: 'postgres://postgres:postgres@127.0.0.1/postgres'
  // connectionString: 'mysql://root@127.0.0.1:3307/graph'
  connectionString: 'sqlite://:memory:'
})
```

## License

Apache 2.0
npm package: @platformatic/db-ra-data-rest
Description: Platformatic DB React-Admin REST data provider
Latest version: 0.41.0

# @platformatic/db-ra-data-rest

React Admin's data-provider that uses Platformatic DB REST API.

## Install

```sh
npm install @platformatic/db-ra-data-rest
```

## Usage

```js
// in src/App.js
import * as React from "react";
import { Admin, Resource } from 'react-admin';
import platformaticDBRestDataProvider from '@platformatic/db-ra-data-rest';
import { PostList } from './posts';

const dataProvider = platformaticDBRestDataProvider();

const App = () => (
    <Admin dataProvider={dataProvider}>
        <Resource name="posts" list={PostList} />
    </Admin>
);

export default App;
```

## License

Apache 2.0
npm package: @platformatic/deploy-client
Description: Deploy code to the Platformatic cloud
Author: Ivan Tymoshenko
Latest version: 1.49.1

Deploys code to the Platformatic cloud.

### Install
  
```bash
npm install @platformatic/deploy-client
```

### API

#### deploy(options)

**Options:** 
- **deployServiceHost** - The host of the Platformatic cloud deploy service. Use `'https://plt-production-deploy-service.fly.dev'`.

- **workspaceId** - The id of the workspace to deploy to.

- **workspaceKey** - The key of the workspace to deploy to.

- **label** - The label of the deployment. Use it if you want to deploy application to the dynamic workspace.

- **pathToProject** - The path to the root of the project to deploy.

- **pathToConfig** - The path to the Platformatic app config file.

- **pathToEnvFile** - The path to the .env file.

- **pathToSecretsFile** - The path to the .secrets.env file.

- **secrets** - The secrets to pass to the Platformatic app. If there is a .secrets.env file

- **variables** - The variables to pass to the Platformatic app. If there is a .env file

- **githubMetadata** - The metadata about the github repository, branch, commit and PR (if it's a dynamic workspace).

- **logger** - The logger to use. Use pino or other logger with the same interface.
npm package: @platformatic/fastify-http-metrics
Description: The `fastify-http-metrics` package provides a simple way to collect prometheus metrics for your Fastify application.
Author: Ivan Tymoshenko
Latest version: 0.3.0

# @platformatic/fastify-http-metrics

The `fastify-http-metrics` package provides a simple way to collect prometheus metrics for your Fastify application.

## Installation

```bash
npm install @platformatic/fastify-http-metrics
```

## Usage

```javascript
const { Registry } = require('prom-client')
const fastify = require('fastify')
const httpMetrics = require('@platformatic/fastify-http-metrics')

const app = fastify()

const registry = new Registry()
app.register(httpMetrics, { registry })

app.get('/metrics', async () => {
  const metrics = await registry.metrics()
  return metrics
})

app.get('/', async () => {
  return 'Hello World'
})

app.listen({ port: 0 }, (err, address) => {
  if (err) {
    console.error(err)
    process.exit(1)
  }
  console.log(`Server listening on ${address}`)
})
```

## API

#### httpMetrics plugin options

- __`options`__ `<object>` Options for configuring the metrics collection.
  - __`registry`__ `<Registry>` The prom-client registry to use for collecting metrics.
  - __`customLabels`__ `<array>` A list of custom labels names to add to the metrics.
  - __`getCustomLabels(req, res, server)`__ `<function>` A function that returns an object of custom labels to add to the metrics. The function receives the request object as a first argument and a response object as a second argument.
  - __`ignoreMethods`__ `<array>` A list of HTTP methods to ignore when collecting metrics. Default: `['OPTIONS', 'HEAD', 'CONNECT', 'TRACE']`.
  - __`ignoreRoutes`__ `<array>` A list of fastify routes to ignore when collecting metrics. Default: `[]`.
  - __`ignore(req, res, server)`__ `<function>` A function that returns a boolean indicating whether to ignore the request when collecting metrics. The function receives the request object as a first argument and a response object as a second argument.
  - __`histogram`__ `<object>` prom-client [histogram options](https://github.com/siimon/prom-client?tab=readme-ov-file#histogram). Use it if you want to customize the histogram.
  - __`summary`__ `<object>` prom-client [summary options](https://github.com/siimon/prom-client?tab=readme-ov-file#summary). Use it if you want to customize the summary.
  - __`zeroFill`__ `<boolean>` Whether to zero-fill the histogram and summary buckets. Default: `false`.

## License

Apache-2.0
npm package: @platformatic/gateway
Description: Platformatic Gateway is an API gateway that aggregates and exposes multiple services as a single API, with support for OpenAPI composition and GraphQL federation.
Author: Platformatic Inc.
Latest version: 3.52.0

# @platformatic/gateway

Platformatic Gateway is an API gateway that aggregates and exposes multiple services as a single API, with support for OpenAPI composition and GraphQL federation.

Check out the full documentation on [our website](https://docs.platformatic.dev/docs/reference/gateway/overview).

## Install

```sh
npm install @platformatic/gateway
```

## License

Apache 2.0
npm package: @platformatic/generate-errors-doc
Description: This is a tool to generate errors documentation (`ERROR.md`in the root of the Platofmratic monorepo) automatically from packages.
Author: Platformatic Inc.
Latest version: 2.75.2

# @platformatic/generate-errors-doc

This is a tool to generate errors documentation (`ERROR.md`in the root of the Platofmratic monorepo) automatically from packages.

## License

Apache 2.0
npm package: @platformatic/generators
Description: Main classes and utils for generators.
Author: Platformatic Inc.
Latest version: 3.52.0

# @platformatic/generators

Generators for scaffolding Platformatic applications programmatically.

Check out the full documentation on [our website](https://docs.platformatic.dev).

## Install

```sh
npm install @platformatic/generators
```

## License

Apache 2.0
npm package: @platformatic/globals
Description: Platformatic Global Object Getter
Author: Platformatic Inc.
Latest version: 3.52.0

# @platformatic/globals

Platformatic Globals exports a single function to get the Platformatic Global object inside a runtime with full typings experience

## Install

```sh
npm install @platformatic/globals
```

## Usage

```ts
import { getGlobal } from '@platformatic/globals'

const platformatic = getGlobal()
```

## License

Apache 2.0
npm package: @platformatic/image-optimizer
Description: Detect, fetch, and optimize images with sharp, with optional queue-backed processing via @platformatic/job-queue.
Author: Platformatic Inc.
Latest version: 0.2.1

# @platformatic/image-optimizer

Detect, fetch, and optimize images with [`sharp`](https://sharp.pixelplumbing.com/), with optional queue-backed processing via [`@platformatic/job-queue`](https://github.com/platformatic/job-queue).

## Features

- Detects image type from file signatures (magic bytes)
- Optimizes raster images (`jpeg`, `png`, `webp`, `avif`)
- Prevents animated image optimization
- Supports optional SVG passthrough
- Provides `fetchAndOptimize()` for URL-based workflows (via `undici.request()`)
- Provides queue APIs (`Queue`, `createQueue`) powered by [`@platformatic/job-queue`](https://www.npmjs.com/package/@platformatic/job-queue) for distributed work
- Throws structured `ImageError` objects

## Installation

```bash
npm i @platformatic/image-optimizer
```

## API

### `optimize(buffer, width, quality, allowSVG = false)`

Optimizes an input image buffer.

- `width`: target max width (`withoutEnlargement` is enabled)
- `quality`: output quality used by format-specific encoders
- `allowSVG`: when `false` (default), SVG images are not optimized and it throws an error

### `fetchAndOptimize(url, width, quality, allowSVG = false)`

Fetches an image and then runs `optimize()`.
Returns:

- `buffer`: optimized image buffer
- `contentType`: upstream `content-type` response header (or `null`)
- `cacheControl`: upstream `cache-control` response header (or `null`)

### `detectImageType(buffer)`

Returns the detected image type (for example `jpeg`, `png`, `webp`) or `null`.

### `Queue`

Queue-backed optimizer powered by [`@platformatic/job-queue`](https://www.npmjs.com/package/@platformatic/job-queue).

Methods:

- `start()`
- `stop()`
- `fetchAndOptimize(url, width, quality, allowSVG?, enqueueOptions?)` (auto-starts on first use)

Notes:

- Queue processing is URL-based (`fetchAndOptimize`) and returns `{ buffer, contentType, cacheControl }`.
- `enqueueOptions` is forwarded to `@platformatic/job-queue` `enqueueAndWait()` (for example: `timeout`, `maxAttempts`, `resultTTL`).

### `createQueue(options?)`

Creates and starts a `Queue` instance.

## Example

```ts
import { createQueue } from '@platformatic/image-optimizer'

const queue = await createQueue({ concurrency: 2 })
const { buffer, contentType, cacheControl } = await queue.fetchAndOptimize('https://example.com/image.jpg', 800, 75)
await queue.stop()
```

## License

Apache-2.0 - See [LICENSE](LICENSE) for more information.
npm package: @platformatic/itc
Description: Inter-Thread Communication (ITC) is a library for managing communication between threads in a multi-threaded application.
Author: Platformatic Inc.
Latest version: 3.52.0

# @platformatic/itc

Inter-Thread Communication (ITC) is a library for managing communication between threads in a multi-threaded application.

## Install

```sh
npm install @platformatic/itc
```

## Usage

```js
const { MessageChannel } = require('node:worker_threads')
const { ITC } = require('@platformatic/itc')
const { port1, port2 } = new MessageChannel()


// thread 1
const itc1 = new ITC({ port: port1, name: 'thread-1' })

itc1.handle('get-users', async (request) => {
  return [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]
})

itc1.listen()

// thread 2
const itc2 = new ITC({ port: port2, name: 'thread-2' })
itc2.listen()

const users = await itc2.send('get-users')
console.log(users)
```

## License

Apache 2.0
npm package: @platformatic/metaconfig
Description: Manage mulitple configuration versions at the same time
Latest version: 1.27.0

# @platformatic/metaconfig

Utility module to migrate between one version of Platformatic to another.

## Install

```sh
npm install @platformatic/metaconfig
```

## Usage

```javascript
import { analyze, write, upgrade } from '@platformatic/metaconfig'

const meta = await analyze({ file: 'path/to/platformatic.db.json' }))

console.log(meta.version)
console.log(meta.kind)
console.log(meta.config)
console.log(meta.path)

// Bring it to the latest version
const metaNext = upgrade(meta)

console.log(metaNext.version)
console.log(metaNext.kind)
console.log(metaNext.config)
console.log(metaNext.path)

// this will override the old config
await write(metaNext)
```

## License

Apache 2.0
npm package: @platformatic/mistral-client
Description: This javascript client is inspired from [cohere-typescript](https://github.com/cohere-ai/cohere-typescript) Forked from https://github.com/mistralai/client-js because the original monkey-patched `fetch()`.
Author: bam4d@mistral.ai
Latest version: 0.1.0

This javascript client is inspired from [cohere-typescript](https://github.com/cohere-ai/cohere-typescript)
Forked from https://github.com/mistralai/client-js because the original monkey-patched `fetch()`.

# Mistral Javascript Client

You can use the Mistral Javascript client to interact with the Mistral AI API.

## Installing

You can install the library in your project using:

`npm install @platformatic/mistral-client`

## Usage

### Set up

```typescript
import MistralClient from '@platformatic/mistral-client';

const apiKey = process.env.MISTRAL_API_KEY || 'your_api_key';

const client = new MistralClient(apiKey);
```

### List models

```typescript
const listModelsResponse = await client.listModels();
const listModels = listModelsResponse.data;
listModels.forEach((model) => {
  console.log('Model:', model);
});
```

### Chat with streaming

```typescript
const chatStreamResponse = await client.chatStream({
  model: 'mistral-tiny',
  messages: [{role: 'user', content: 'What is the best French cheese?'}],
});

console.log('Chat Stream:');
for await (const chunk of chatStreamResponse) {
  if (chunk.choices[0].delta.content !== undefined) {
    const streamText = chunk.choices[0].delta.content;
    process.stdout.write(streamText);
  }
}
```

### Chat without streaming

```typescript
const chatResponse = await client.chat({
  model: 'mistral-tiny',
  messages: [{role: 'user', content: 'What is the best French cheese?'}],
});

console.log('Chat:', chatResponse.choices[0].message.content);
```

### Embeddings

```typescript
const input = [];
for (let i = 0; i < 1; i++) {
  input.push('What is the best French cheese?');
}

const embeddingsBatchResponse = await client.embeddings({
  model: 'mistral-embed',
  input: input,
});

console.log('Embeddings Batch:', embeddingsBatchResponse.data);
```

## Run examples

You can run the examples in the examples directory by installing them locally:

```bash
cd examples
npm install .
```

### API key setup

Running the examples requires a Mistral AI API key.

Get your own Mistral API Key: <https://docs.mistral.ai/#api-access>

### Run the examples

```bash
MISTRAL_API_KEY='your_api_key' node chat_with_streaming.js
```

### Persisting the API key in environment

Set your Mistral API Key as an environment variable. You only need to do this once.

```bash
# set Mistral API Key (using zsh for example)
$ echo 'export MISTRAL_API_KEY=[your_api_key]' >> ~/.zshenv

# reload the environment (or just quit and open a new terminal)
$ source ~/.zshenv
```

You can then run the examples without appending the API key:

```bash
node chat_with_streaming.js
```
After the env variable setup the client will find the `MISTRAL_API_KEY` by itself

```typescript
import MistralClient from '@platformatic/mistral-client';

const client = new MistralClient();
```
npm package: @platformatic/mtls-auth
Description: Plugin for Platformatic cloud mtls auth
Author: Ivan Tymoshenko
Latest version: 1.2.1

### mtls-auth

Plugin to extract authentication information from mTLS certificate common name.

__Example:__

Common name: `payments.test.com`

```js
const app = fastify(/* tls certs */)

app.register(mtlsAuthPlugin, {
  mtlsDomain: 'test.com'
})

app.get('/test', async (request) => {
  const session = request.getMtlsAuth()
  console.log(session['X-PLATFORMATIC-ROLE']) // payments
})
```

Common name: `e4a123f8-1f12-11ee-be56-0242ac120002.clients.test.com`

```js
const app = fastify(/* tls certs */)

app.register(mtlsAuthPlugin, {
  mtlsClientsRole: 'clients',
  mtlsDomain: 'test.com'
})

app.get('/test', async (request) => {
  const session = request.getMtlsAuth()
  console.log(session['X-PLATFORMATIC-ROLE']) // clients
  console.log(session['X-PLATFORMATIC-WORKSPACE-ID']) // e4a123f8-1f12-11ee-be56-0242ac120002
})
```
npm package: @platformatic/pnpm-api
Description: Small wrapper around pnpm internal modules for programmatic add/install/remove operations
Author: Platformatic Inc.
Latest version: 0.1.0

# @platformatic/pnpm-api

A small wrapper around pnpm's internal modules for programmatic package operations.

It exposes three high-level functions:

- `pnpmAdd(dir, specs, options)`
- `pnpmInstall(dir, options)`
- `pnpmRemove(dir, names, options)`

## Why this exists

pnpm does not currently provide a stable top-level JavaScript API like `pnpm.install('lodash')`.
The practical route is to compose internal packages such as:

- `@pnpm/core`
- `@pnpm/config`
- `@pnpm/read-project-manifest`
- `@pnpm/store-connection-manager`

This package wraps that composition into a smaller, reusable surface.

## Scope

This wrapper is intentionally focused on **single-project** operations.
It forces lockfile output on by default and isolates lockfile writes to the target project unless you override `lockfileDir`.

Because this is built on pnpm internals, you should pin versions carefully.

## Install

```bash
pnpm install
```

## Usage

```ts
import { pnpmAdd, pnpmInstall, pnpmRemove } from '@platformatic/pnpm-api'

await pnpmAdd('/tmp/example-app', ['is-odd@3.0.1'])
await pnpmInstall('/tmp/example-app')
await pnpmRemove('/tmp/example-app', ['is-odd'])
```

## API

### `pnpmAdd(projectDir, dependencySelectors, options?)`

Adds one or more dependency selectors to a project and writes:

- the project manifest
- `pnpm-lock.yaml`
- `node_modules/.pnpm/lock.yaml`

### `pnpmInstall(projectDir, options?)`

Installs dependencies from the project's existing manifest.

### `pnpmRemove(projectDir, dependencyNames, options?)`

Removes one or more dependencies from the project's manifest and installation.

## Options

Shared options:

- `cliOptions`: extra options forwarded to `@pnpm/config#getConfig()`
- `storeDir`: set the store directory used by pnpm. Set to `false` to use a temporary directory that is deleted after each operation.
- `nodeLinker`: set the pnpm node linker (`'hoisted' | 'isolated' | 'pnp'`)
- `configOverrides`: shallow overrides applied after config resolution
- `lockfileDir`: where `pnpm-lock.yaml` should be written
- `packageManager`: package-manager identity used for config resolution
- `useLockfile`: defaults to `true` (set to `false` automatically when `writeManifest` is `false`, unless explicitly provided)
- `saveLockfile`: defaults to `true`
- `writeManifest`: when `false`, operations return updated manifests without writing `package.json` (default `true`).
  If `useLockfile` is not explicitly set, lockfile output is also disabled when `writeManifest` is `false`.

Add-only options:

- `allowNew`
- `peer`
- `pinnedVersion`
- `targetDependenciesField`

Install-only options:

- `pruneDirectDependencies`
- `update`
- `updateToLatest`

Remove-only options:

- `targetDependenciesField`

## Development

```bash
pnpm install
pnpm run typecheck
pnpm test
pnpm run build
```