open-index/open-npm huggingface dataset:
npm package: @splashprotocol/backend
Description: Splash backend development kit
Latest version: 2.2.3

# Backend development kit

Package to create easy node.js services

## Install

Run the following command:

```sh
// npm
npm i @splashprotocol/backend
// yarn
yarn add @splashprotocol/backend
```

## Create backend route

Each route has 2 section: `info` and `handler`.

## Info explanation

info includes

### metadata
This refers to metadata or configuration associated with a specific route in your application.

It includes details such as:

The HTTP method (e.g., GET, POST).

The path (e.g., /users/{id}).

Parameters (query, path, headers, body).

Expected response type.

### Swagger Specification:

The route info is used to generate OpenAPI/Swagger documentation.

This documentation describes the API's structure, including:

Endpoints.

Input parameters (query, path, headers, body).

Expected responses.

### Zod Types for Validation:

Zod is a TypeScript library for schema validation.

The route info includes Zod schemas to validate:

1. Query parameters.
2. Path parameters.
3. Headers.
4. Request body.
5. Return type

This ensures that incoming data matches the expected format. 

## Handler explanation:
function that receives checked parameters and returns result

Example:
```typescript
export const launchRoute = Route.new({
    info: {
        route: '/launch',
        result: {
            status: 200,
            content: z.object({
                hello: z.string()
            })
        },
        body: {
            contentType: 'multipart/form-data',
            fileSizeLimit: 1024 * 1024,
            payload: z.object({
                image: zodFile( ['image/png', 'image/jpg', 'image/jpeg', 'image/gif']),
                info: z.string()
            })
        },
        tags: ['Launch'],
        summary: 'test',
        method: 'post'
    },
    handler: async ({ body, requestWorker }) => {
        return  await requestWorker<LaunchParams, LaunchResult>({
            type: 'launch',
            hello: '123'
        });
    }
})
```

## Create backend:

example:
```typescript
const backend = Backend.new({
    routes: [
        launchRoute
    ],
    settings: {
        maxBodyLength: 50 * 1024 * 1024,
        swaggerPath: __dirname,
    },
    info: {
        title: 'test',
        description: 'tes',
        version: '1.0.0',
    },
    environment: config
})
backend.run(3000);
```