open-index/open-npm huggingface dataset:
npm package: @lapc/aws-function-utils
Description: Utilities for working with AWS Functions (i.e. with Netlify, etc.).
Author: Cam Morrow
Latest version: 0.0.1

# @lapc/aws-function-utils

Utilities for working with AWS Functions (i.e. with Netlify, etc.).

## General notes
AWS functions (aka Handlers) look like:
`(Event, Context) => Promise<Response>`
- The `Event` object contains meta data about the incoming request (POST body, query string, etc.)
- The `Context` object contains additional contextual data. Higher order functions (see below) decorate this object with additional values.
- The `Response` object contains what to return to the client.

Most functions in this library are implemented as higher order functions, that take a Handler, and return a new Handler that receives additional fields in its context, is wrapped in a response decorator, or is otherwise given additional, generic abilities.

## Higher order functions

### `hofs/withConfigFactory`
Attaches a `config` object to handler context. A convenience wrapper around `hofs/withContextDecoratorFactory`.
```typescript

type Config = {
   helloMessage: string;
};

const decoratedHandler: ALBHandler<WithConfig<Config>> = async (event, context) => {
    const { config } = context;
    return success({
        message: `Hello message was ${config.helloMessage}`,
    });
};

// Creates a handler which automatically receives the config object in its context
export const handler = withConfig<Config>({
    helloMessage: "Hello, world!",
})(decoratedHandler);

```

### `hofs/withContextDecoratorFactory`

Attaches an arbitrary decoration, generated asynchronously, to the context.

```typescript

type Decoration = {
    decoratedValue: number;
}

// A handler that receives decorated context
const decoratedHandler: ALBHandler<ALBContext & Decoration> = async (event, context) => {
    const { decoratedValue } = context;
    return success({
        decoratedValue,
    });
};

// A function that takes an undecorated context and returns asynchronously a decorated one
const decorator = async (undecoratedContext: ALBContext): Promise<ALBContext & Decoration> => {
    return {
        ...undecoratedContext,
        decoratedValue: Math.random(),
    };
};

// Creates a handler which resolves the decorator function and passes the decorated context into the original handler
export const handler = withContextDecoratorFactory(decorator)(decoratedHandler);

```

## Todo
- [ ] More details in readme
- [ ] More tests
npm package: @lapc506/nestjs-inertia
Description: Unofficial NestJS (express platform) adapter for InertiaJS. Fork of nestjs-inertia with NestJS 11 and Express 5 support.
Author: lapc506
Latest version: 1.0.0

# @lapc506/nestjs-inertia

> Fork of [nestjs-inertia](https://github.com/harisfi/nestjs-inertia) with NestJS 11 and Express 5 support.

`nestjs-inertia` is a simple [NestJS](https://nestjs.com) adapter/middleware with `express-platform` for [Inertia.js](https://inertiajs.com) to create server-driven single page applications.

## Why this fork?

The original `nestjs-inertia` package has been unmaintained for 4+ years and has critical bugs:
- Broken entrypoint (`main` points to wrong path)
- Incompatible with NestJS 11.x
- Incompatible with Express 5.x

This fork fixes all issues.

## Installation

```bash
npm i @lapc506/nestjs-inertia
```

## Applying adapter

Based on official NestJS documentation of their middleware, you can apply `nestjs-inertia` middleware to global or module level like below:

1. Global Level
    ```ts
    import { NestFactory } from '@nestjs/core';
    import { AppModule } from './app.module';
    import { inertiaMiddleware } from '@lapc506/nestjs-inertia'

    const app = await NestFactory.create(AppModule);
    app.use(inertiaMiddleware);
    await app.listen(3000);
    ```
2. Module Level
    ```ts
    import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
    import { AppController } from './app.controller';
    import { AppService } from './app.service';
    import { InertiaMiddleware } from '@lapc506/nestjs-inertia'

    @Module({
      imports: [],
      controllers: [AppController],
      providers: [AppService],
    })
    export class AppModule implements NestModule {
      configure(consumer: MiddlewareConsumer) {
        consumer
          .apply(InertiaMiddleware)
          .forRoutes('*');
      }
    }
    ```

## Usage

You can use this adapter from express' `Response` api.

### Basic Usage

- Rendering a component
  ```ts
  res.inertia.render('Users/AllUser', {
    users: [
      {
        id: 1,
        name: 'John Doe'
      }
    ]
  });
  ```
- Share data
  ```ts
  res.inertia.share({
    isLoggedIn: true
  });
  ```
- Redirection
  ```ts
  res.inertia.redirect('/user');
  ```

### Example usage at controller
```ts
import { Controller, Get, Res } from '@nestjs/common';
import { Response } from 'express';

@Controller('users')
export class UserController {
  @Get()
  findAll(@Res() res: Response): Promise<void> {
    return res.inertia.render('Users/AllUser', {
      users: [
        {
          id: 1,
          name: 'John Doe'
        }
      ]
    });
  }
}
```

## Compatibility

| Package | Version |
|---------|---------|
| @nestjs/common | ^10.0.0 \|\| ^11.0.0 |
| @nestjs/core | ^10.0.0 \|\| ^11.0.0 |
| @nestjs/platform-express | ^10.0.0 \|\| ^11.0.0 |
| express | ^4.0.0 \|\| ^5.0.0 |

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

## License

[MIT](https://choosealicense.org/licenses/mit/)