open-index/open-npm huggingface dataset:
npm package: @prefab-cloud/prefab-cloud-language-server
Description: Language Server for Prefab Config, Feature flags, and Log Levels
Author: Jeffrey Chupp
Latest version: 0.1.22

# Prefab Language Server

Note: If you're using VS Code, please use the [extension][vscode] instead of using this language server directly.

## Installation

```
npm install -g @prefab-cloud/prefab-cloud-language-server
```

[vscode]: https://marketplace.visualstudio.com/items?itemName=Prefab.prefab-editor-tools
npm package: @prefabs.tech/eslint-config
Description: ESLint config
Latest version: 0.5.0

# @prefabs.tech/eslint-config
Custom ESLint configuration for streamlined linting across projects.

## Supported configurations:
- `@prefabs.tech/eslint-config/fastify` fastify apis and libraries
- `@prefabs.tech/eslint-config/react` for react libraries
- `@prefabs.tech/eslint-config/react-app` for react apps
- `@prefabs.tech/eslint-config/vue` for vue apps and libraries
- `@prefabs.tech/eslint-config` for general typescript projects

## Installation and usage

**Note:** For CommonJS projects, use `eslint.config.mjs` instead of `eslint.config.js`.

* ### For fastify apis and libraries:

  In the root directory of your app or package:

  Install dependencies:

  ```sh
  npm i -D @prefabs.tech/eslint-config eslint prettier typescript
  ```

  Create a `eslint.config.js` file:

  ```js
  import fastifyConfig from "@prefabs.tech/eslint-config/fastify.js";

  export default fastifyConfig;
  ```

* ### For react libraries:

  In the root directory of your the react package:

  Install dependencies:

  ```sh
  pnpm i -D @prefabs.tech/eslint-config eslint prettier typescript
  ```

  Create a `eslint.config.js` file:

  ```js
  import reactConfig from "@prefabs.tech/eslint-config/react.js";

  export default reactConfig;
  ```

* ### For react apps:

  In the root directory of the react app:

  Install dependencies:

  ```sh
  pnpm i -D @prefabs.tech/eslint-config eslint prettier typescript
  ```

  Create a `eslint.config.js` file:

    ```js
    import reactConfig from "@prefabs.tech/eslint-config/react-app.js";

    export default reactConfig;
    ```

* ### For vue apps and libraries:

  In the root directory of your app or package:

  Install dependencies:

  ```sh
  pnpm i -D @prefabs.tech/eslint-config eslint prettier typescript
  ```

  Create a `eslint.config.js` file:

  ```js
  import vueConfig from "@prefabs.tech/eslint-config/vue.js";

  export default vueConfig;
  ```

  **Note:** If you're using this configuration for a vue app, you may want to disable the `vue/no-reserved-component-names` rule, which prevents using reserved HTML tag names (e.g., Button, Input) as component names. You can do this by adding the following configuration:

  ```js
  import vueConfig from "@prefabs.tech/eslint-config/vue.js";

  export default [
    ...vueConfig,
    {
      rules: {
        "vue/no-reserved-component-names": "off",
      }
    }
  ];
  ```

* ### For general typescript projects:
  In the root directory of your app or package:

  Install dependencies:

  ```sh
  npm i -D @prefabs.tech/eslint-config eslint prettier typescript
  ```

  Create a `eslint.config.js` file:

  ```js
  import config from "@prefabs.tech/eslint-config";

  export default config;
  ```

## Adding linting scripts
In your `package.json`, add the following commands to the `scripts` section:

* For typescript or react projects:
  ```json
  "lint": "eslint .",
  "lint:fix": "eslint . --fix"
  ```

## Running linting
Run the following command to lint your code:

```bash
npm run lint
```

To automatically fix issues, run:

```bash
npm run lint:fix
```
npm package: @prefabs.tech/fastify-config
Description: Fastify config plugin
Latest version: 0.93.5

# @prefabs.tech/fastify-config

A [Fastify](https://github.com/fastify/fastify) plugin that defines an opinionated config for an API.

When registered on a Fastify instance, the plugin will:

* decorate the Fastify instance with the `config` object, available with the `config` attribute.
* decorate all requests with the `config` object, available with the `config` attribute; this can be used to construct a `buildContext` for mercurius resolvers, for example.
* decorate the Fastify instance with a `hostname` attribute.

## Installation

Install with npm:

```bash
npm install @prefabs.tech/fastify-config
```

Install with pnpm:

```bash
pnpm add --filter "@scope/project @prefabs.tech/fastify-config
```

## Usage

Somewhere in your code, create a `config.ts` file that looks like this:

```typescript
import { parse } from "@prefabs.tech/fastify-config";
import dotenv from "dotenv";

import type { ApiConfig } from "@prefabs.tech/fastify-config";

dotenv.config();

const config: ApiConfig = {
  appName: process.env.APP_NAME as string,
  appOrigin: (process.env.APP_ORIGIN as string).split(","),
  baseUrl: process.env.BASE_URL as string,
  env: parse(process.env.NODE_ENV, "development") as string,
  logger: {
    level: parse(process.env.LOG_LEVEL, "error") as string,
  },
  name: process.env.NAME as string,
  pagination: {
    default_limit: parse(process.env.PAGINATION_DEFAULT_LIMIT, 25) as number,
    max_limit: parse(process.env.PAGINATION_MAX_LIMIT, 50) as number,
  },
  port: parse(process.env.PORT, 20040) as number,
  protocol: parse(process.env.PROTOCOL, "http") as string,
  rest: {
    enabled: parse(process.env.REST_ENABLED, true) as boolean,
  },
  version: `${process.env.npm_package_version || process.env.API_VERSION}+${process.env.API_BUILD || "local"}` as string,
};

export default config;
```

Register the plugin with your Fastify instance:

```typescript
import configPlugin from "@prefabs.tech/fastify-config";
import Fastify from "fastify";

import config from "./config";

const start = async () => {
  // Create fastify instance
  const fastify = Fastify({
    logger: config.logger,
  });

  // Register fastify-config plugin
  await fastify.register(configPlugin, { config });

  await fastify.listen({
    port: config.port,
    host: "0.0.0.0",
  });
};

start();
```
npm package: @prefabs.tech/fastify-error-handler
Description: Fastify error-handler plugin
Latest version: 0.93.5

# @prefabs.tech/fastify-error-handler

A [Fastify](https://github.com/fastify/fastify) plugin that provides an easy integration of error handler in fastify API.

## Requirements

* [@prefabs.tech/fastify-config](../config/)
* [@fastify/sensible](https://github.com/fastify/fastify-sensible)

## Installation

Install with npm:

```bash
npm install @prefabs.tech/fastify-error-handler
```

Install with pnpm:

```bash
pnpm add --filter "@scope/project @prefabs.tech/fastify-error-handler
```

## Usage

### Register Plugin

Register @prefabs.tech/fastify-error-handler package with your Fastify instance:

Note: Register the errorHandler plugin as early as possible (Before all your routes and plugin registration).

```typescript
import errorHandlerPlugin from "@prefabs.tech/fastify-error-handler";
import Fastify from "fastify";

const start = async () => {
  // Create fastify instance
  const fastify = Fastify();
  
  // Register fastify-error-handler plugin
  await fastify.register(errorHandlerPlugin, {});
  
  await fastify.listen({
    port: config.port,
    host: "0.0.0.0",
  });
};

start();
```
### Options

#### stackTrace

When enabled, the error handler will include the error’s stack trace in the HTTP response body.

By default, it is set to false.

```ts
stackTrace?: boolean; // Default: false
```

#### preErrorHandler

preErrorHandler is an optional error handler that runs before the default error handler logic.
It allows you to intercept specific errors, handle them yourself, and prevent the default handler from running.

This is especially useful when you need to integrate with other libraries that have their own error formats — for example, handling SuperTokens errors before your API’s standard error response.

```ts
preErrorHandler?: (
  error: FastifyError,
  request: FastifyRequest,
  reply: FastifyReply,
) => void | Promise<void>;
```

## Error Handling Guidelines

### Controllers must not reply with non-200 responses

Do not manually send error responses from controllers.

Instead, always throw an error and let the global error handler handle formatting and response.

**Wrong**

```ts
fastify.get('/test', async (req, reply) => {
  return reply.code(401).send({ message: "Unauthorized" });
})
```

**Correct**

```ts
fastify.get('/test', async (req, reply) => {
  throw fastify.httpErrors.unauthorized("Unauthorized");
})
```

### Throw `CustomError` (or subclass)
- Modules **must throw** an instance of `CustomError` (or a class extending it).
- This ensures errors can be consistently caught and appropriate actions taken.

```ts
import { CustomError } from "@prefabs.tech/fastify-error-handler";

const file = fileService.findById(1);

if (!file) {
  throw new CustomError("File not found", "FILE_NOT_FOUND_ERROR");
}
```
npm package: @prefabs.tech/fastify-mailer
Description: Fastify mailer plugin
Latest version: 0.93.5

# @prefabs.tech/fastify-mailer

A [Fastify](https://github.com/fastify/fastify) plugin that when registered on a Fastify instance, will decorate it with a `mailer` object for email.

## Requirements

- [html-to-text](https://github.com/html-to-text/node-html-to-text)
- [mustache](https://github.com/janl/mustache.js)
- [nodemailer](https://github.com/nodemailer/nodemailer)
- [nodemailer-html-to-text](https://github.com/andris9/nodemailer-html-to-text)
- [nodemailer-mjml](https://github.com/Thomascogez/nodemailer-mjml)

## Installation

Install with npm:

```bash
npm install @prefabs.tech/fastify-mailer html-to-text mustache nodemailer nodemailer nodemailer-html-to-text nodemailer-mjml
```

Install with pnpm:

```bash
pnpm add --filter "@scope/project" @prefabs.tech/fastify-mailer html-to-text mustache nodemailer nodemailer nodemailer-html-to-text nodemailer-mjml
```

## Usage

### Register Plugin

Register @prefabs.tech/fastify-mailer package with your Fastify instance:

```typescript
import mailerPlugin from "@prefabs.tech/fastify-mailer";
import Fastify from "fastify";

import config from "./config";

const start = async () => {
  // Create fastify instance
  const fastify = Fastify({
    logger: config.logger,
  });
  
  // Register mailer plugin
  await fastify.register(mailerPlugin, config.mailer);
  
  await fastify.listen({
    port: config.port,
    host: "0.0.0.0",
  });
};

start();
```

## Configuration
To configure the mailer, add the following settings to your `config/mailer.ts` file:

```typescript
import type { MailerConfig } from "@prefabs.tech/fastify-mailer";

const mailerConfig: MailerConfig = {
  defaults: {
    from: {
      address: "test@example.com",
      name: "Test",
    },
  },
  test: {
    enabled: true,
    path: "/test/email",
    to: "user@example.com",
  },
  templating: {
    templateFolder: "mjml/templates",
  },
  templateData: {
    baseCDNUrl: "http://localhost:3000/",
  },
  transport: {
    auth: {
      pass: "pass",
      user: "user",
    },
    host: "localhost",
    port: 3001,
    requireTLS: true,
    secure: true,
  },
};

export default mailerConfig;
```
npm package: @prefabs.tech/fastify-swagger
Description: Fastify swagger plugin
Latest version: 0.93.5

# @prefabs.tech/fastify-swagger

A [Fastify](https://github.com/fastify/fastify) plugin that provides an easy integration of swagger in fastify API.


## Installation

Install with npm:

```bash
npm install @prefabs.tech/fastify-swagger
```

Install with pnpm:

```bash
pnpm add --filter "@scope/project @prefabs.tech/fastify-swagger
```

## Configuration
To configure the swagger, add the following settings to your `config/swagger.ts` file:

```typescript
import type { SwaggerOptions } from "@prefabs.tech/fastify-swagger";

const swaggerConfig: SwaggerOptions = {
  enabled: true,
  fastifySwaggerOptions: {
    openapi: {
      info: {
        title: "Test API",
        version: "1.0.0",
      },
      servers: [
      {
        url: 'http://localhost:3000',
        description: 'Development server'
      }
    ],
    },
  },
};

export default swaggerConfig;
```

## Usage

Register the plugin with your Fastify instance:

```typescript
import Fastify from "fastify";
import swaggerPlugin from "@prefabs.tech/fastify-swagger"

import swaggerConfig from "./config/swagger"

const start = async () => {
  // Create fastify instance
  const fastify = Fastify();

  await fastify.register(swaggerPlugin, swaggerOptions);

  await fastify.listen({
    port: 3000,
    host: "0.0.0.0",
  });
};

start();
```