open-index/open-npm huggingface dataset:
npm package: @serverless-stack/cli
Description: A CLI to help deploy SST apps.
Author: SST
Latest version: 1.18.4

# @serverless-stack/cli [![npm](https://img.shields.io/npm/v/@serverless-stack/cli.svg?style=flat-square)](https://www.npmjs.com/package/@serverless-stack/cli)

<img alt="Logo" align="right" src="https://raw.githubusercontent.com/serverless-stack/identity/main/sst.svg" width="20%" />

Part of the **[SST Framework](https://github.com/serverless-stack/sst)**. The `sst` CLI allows you to build, deploy, and test SST apps.

[View the @serverless-stack/cli docs here](https://docs.sst.dev/packages/cli).

## Quick Start

Create your first SST app.

```bash
# Create your app
$ npm init sst
$ cd my-sst-app
$ npm i

# Start Live Lambda Development
$ npm start

# Deploy to prod
$ npx sst deploy --stage prod
```

[![sst start](https://d1ne2nltv07ycv.cloudfront.net/SST/sst-start-demo/sst-start-demo-2.gif)](https://d1ne2nltv07ycv.cloudfront.net/SST/sst-start-demo/sst-start-demo-2.mp4)

## Live Lambda Development

The `sst start` command starts up a local development environment that opens a WebSocket connection to your deployed app and proxies any Lambda requests to your local machine. This allows you to:

- Work on your Lambda functions locally
- Supports all Lambda triggers, so there's no need to mock API Gateway, SQS, SNS, etc.
- Supports real Lambda environment variables and Lambda IAM permissions
- And it's fast. There's nothing to deploy when you make a change!

[Read more about Live Lambda Development](https://docs.sst.dev/live-lambda-development).

## Documentation

[**Check out the SST docs**](https://docs.sst.dev)
npm package: @serverless-stack/core
Description: Core of SST.
Author: Anomaly Innovations
Latest version: 1.18.4

# @serverless-stack/core [![npm](https://img.shields.io/npm/v/@serverless-stack/core.svg?style=flat-square)](https://www.npmjs.com/package/@serverless-stack/core)

Part of the **[SST Framework](https://github.com/serverless-stack/sst)**.

Uses [AWS CDK](https://github.com/aws/aws-cdk) internally to build and deploy SST apps.
npm package: @serverless-stack/nextjs-core
Description: Handles Next.js routing independent of provider
Author: Jan Varho
Latest version: 0.1.9

### Core library for running serverless Next.js

Decouples the core Next.js handing logic from a particular provider.
The types defined are meant to be abstract to use with any provider.

Code coverage relies on jest configuration:

    "moduleNameMapper": {
      "@sls-next/core": "<rootDir>/packages/libs/core/src/index.ts"
    },

Builds twice, both a commonjs module (dist/index.js) and an ES module (dist/module/index.js).
The former is used by the serverless component, while the latter allows rollup to optimize size.

## build/

Contains logic needed for building manifests.

# route/

Contains routing logic.

Entry functions take manifests and request details and return Route objects.

# handle/

Contains logic for handling routes.

Entry functions take manifests and Events containing request/response.
They return unhandled routes or resolve the route to resp object given.
npm package: @serverless-stack/nextjs-lambda
Description: Provides handlers that can be used in CloudFront Lambda@Edge to deploy next.js applications to the edge
Author: Daniel Conde Marin
Latest version: 0.1.9

### AWS Lambda@Edge library to help you deploy serverless next.js applications to CloudFront

This library was created to decouple the core logic of deploying serverless rendered next.js applications on the Cloud agnostic of a specific provider. In other words, this library could be used to deploy via serverles components, AWS CDK, or any other providers you'd like.

## Usage

```
const path = require('path');
const { Builder } = require("@sls-next/lambda-at-edge");

const nextConfigPath = '/path/to/my/nextapp';
const outputDir = path.join(nextConfigPath, ".serverless_nextjs");

const builder = new Builder(
  nextConfigPath,
  outputDir,
  {
    cmd: './node_modules/.bin/next',
    cwd: process.cwd(),
    env: {},
    args: ['build'],
    minifyHandlers: true,
    // it is recommended to let your CF distribution do the compression as per the docs - https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html
    // however there have been issues in the past where CF doesn't compress lambda@edge responses, so we provide our own implementation in case is needed
    enableHTTPCompression: false
  }
);

await builder.build()
    .then(() => {
      console.log("Application built successfully!");
    })
    .catch((e) => {
      console.log("Could not build app due the exception: ", e);
      process.exit(1);
    });
```

You can configure more options regarding building process. Configurable inputs you can find in 'build.ts' file ('packages/libs/lambda-at-edge/src/build.ts'). If you want to see debug logs during building, use 'await builder.build(true)' instead.
After running the above, the output directory will contain the Lambda@Edge handlers necessary to server side render at the edge.

```
/dir/to/my/next-app/.serverless_nextjs/

 > default-lambda
   > manifest.json
   > routes-manifest.json
   > prerender-manifest.json
   > pages/
   > index.js # handler

 > api-lambda
   > manifest.json
   > routes-manifest.json
   > pages/api/
   > index.js # handler

 > image-lambda
   > manifest.json
   > routes-manifest.json
   > images-manifest.json
   > node_modules/...
   > index.js # handler
```

The handlers need to be attached to the `origin-request` trigger of CloudFront.
The `api-lambda` edge function should be attached to a CloudFront behaviour that only triggers in the event of `/api/*` requests.
The `image-lambda` edge function should be attached to a CloudFront behaviour that only triggers in the event of `_next/image*` requests.

### TODO:

- Provisioning and configuration of the CloudFront distribution
- Create a separate utility to clean up unused Lambda@Edge functions that were previously attached to a CloudFront distribution
npm package: @serverless-stack/node
Description: The `@serverless-stack/node` package provides helper libraries used inside the Lambda function code.
Latest version: 1.18.4

# @serverless-stack/node [![npm](https://img.shields.io/npm/v/@serverless-stack/node.svg?style=flat-square)](https://www.npmjs.com/package/@serverless-stack/node)

The `@serverless-stack/node` package provides helper libraries used inside the Lambda function code.

[View the @serverless-stack/node docs here](https://docs.sst.dev/clients).

## Installation

```bash
# With npm
npm install @serverless-stack/node
# Or with Yarn
yarn add @serverless-stack/node
```

## Exports

The `@serverless-stack/node` package is made up of a collection of modules. Like the `@serverless-stack/node/api`, `@serverless-stack/node/bucket`, etc. Each of these modules has 3 types of exports:

### Properties

The properties in each module helps you access the resources that are bound to the function.

```ts
// Create an S3 bucket
const bucket = new Bucket(stack, "myFiles");

new Function(stack, "myFunction", {
  handler: "lambda.handler",
  // Bind to function
  bind: [bucket],
});
```

You can access the bucket name in your function by importing `Bucket` from the `@serverless-stack/node/bucket` module:

```ts
import { Bucket } from "@serverless-stack/node/bucket";

console.log(Bucket.myFiles.bucketName);
```

Due to the use of top-level await, your functions need to be bundled in the `esm` format.

### Handlers

The handlers in each module is a function that can wrap around Lambda function handlers.

```js
import { ApiHandler } from "@serverless-stack/node/api";

export const handler = ApiHandler((event) => {
  // ...
});
```

Each handler has a specific purpose but they share a couple of things in common:

1. Provide proper typesafety.
2. They also initialize SST's context system to power our [`Hooks`](#hooks).

### Hooks

The hooks in each module are functions that you can call anywhere in your application code. It has access to things that are specific to the current invocation. This avoids having to pass things through multiple function calls down to our domain code.

```ts
import { useSession } from "@serverless-stack/node/auth";

const session = useSession();

if (session.type === "user) {
  console.log(session.properties.userID);
}
```

Behind the scenes, Hooks are powered by a SST's context system.

### Others

Some of the modules also export types that can be used to define payloads for function calls. They also optionally export methods.

## Usage in tests

To access the [properties](#properties) in your tests, you'll need to wrap your tests with the `sst bind` CLI.

```bash
sst bind -- vitest run
```

This allows the `@serverless-stack/node` package to work as if it was running inside a Lambda function.
npm package: @serverless-stack/resources
Description: Helper AWS CDK constructs for SST apps.
Author: SST
Latest version: 1.18.4

# @serverless-stack/resources [![npm](https://img.shields.io/npm/v/@serverless-stack/resources.svg?style=flat-square)](https://www.npmjs.com/package/@serverless-stack/resources)

The `@serverless-stack/resources` package provides a set of additional CDK constructs necessary to build an SST app.

[View the @serverless-stack/resources docs here](https://docs.sst.dev/constructs).

## Installation

This package is usually installed together with [`@serverless-stack/cli`](https://www.npmjs.com/package/@serverless-stack/cli).

```bash
# With npm
$ npm install @serverless-stack/cli @serverless-stack/resources --save-exact
# Or with Yarn
$ yarn add @serverless-stack/cli @serverless-stack/resources --exact
```

Note that, the version of these packages should be kept in sync.

## Importing constructs

You can either import specific constructs in your app.

```js
import { Api } from "@serverless-stack/resources";
```

Or import them all.

```js
import * as sst from "@serverless-stack/resources";
```

## Types of constructs

SST comes with a two types of constructs.

### Low-level

These either extend or replace the native CDK constructs.

- [`App`](https://docs.sst.dev/constructs/App)
- [`Stack`](https://docs.sst.dev/constructs/Stack)
- [`Function`](https://docs.sst.dev/constructs/Function)

### Higher-level

These are higher level abstractions that wrap around multiple constructs to serve specific use cases.

- [`Api`](https://docs.sst.dev/constructs/Api)
- [`Auth`](https://docs.sst.dev/constructs/Auth)
- [`Cron`](https://docs.sst.dev/constructs/Cron)
- [`Table`](https://docs.sst.dev/constructs/Table)
- [`Topic`](https://docs.sst.dev/constructs/Topic)
- [`Queue`](https://docs.sst.dev/constructs/Queue)
- _And many more!_
npm package: @serverless-stack/static-site-env
Description: A simple CLI that allows your static site to load the environment variables from your SST app.
Author: SST
Latest version: 1.18.4

# @serverless-stack/static-site-env [![npm](https://img.shields.io/npm/v/@serverless-stack/static-site-env.svg?style=flat-square)](https://www.npmjs.com/package/@serverless-stack/static-site-env)

A simple CLI ([`@serverless-stack/static-site-env`](https://www.npmjs.com/package/@serverless-stack/static-site-env) that allows your static site or Next.js app to load the environment variables from your SST app. This means that you won't have to hard code the config from your backend. Supports [React.js](https://docs.sst.dev/constructs/ReactStaticSite#configuring-environment-variables), [Next.js](https://docs.sst.dev/constructs/NextjsSite#configuring-environment-variables), and [Svelte](https://docs.sst.dev/constructs/StaticSite#creating-a-svelte-site).

## Installation

Run the following in the root of your static site or Next.js app.

```bash
# With npm
npm install @serverless-stack/static-site-env --save-dev
# Or with Yarn
yarn add @serverless-stack/static-site-env --dev
```

## Usage

Once installed, tweak the start command in your `package.json` scripts.

Note that, you need to have `sst start` running for this to work.

### React.js

```json title="package.json" {2}
"scripts": {
  "start": "sst-env -- react-scripts start",
},
```

Start your local dev environment as usual.

```bash
npm run start
```

### Next.js

```json title="package.json" {2}
"scripts": {
  "dev": "sst-env -- next dev",
},
```

And run.

```bash
npm run dev
```

### Svelte

```json title="package.json" {2}
"scripts": {
  "dev": "sst-env -- vite",
},
```

And run.

```bash
npm run dev
```

## Options

### `--path`

A relative path to the directory containing the `sst.json` file.

Note that, the `sst-env` CLI will traverse up the directories to look for the root of your SST app. If the static site or Next.js app is located outside the SST app folder, for example:

```
/
  backend/
    sst.json
  frontend/
    package.json
```

Pass in `--path` to specify the relative path of the SST app.

```json title="package.json" {2}
"scripts": {
  "start": "sst-env --path ../backend -- react-scripts start",
},
```

## How it works

Here's what's going on behind the scenes.

1. The `sst start` command generates a file with the values specified by `StaticSite`, `ReactStaticSite`, `ViteStaticSite`, or `NextjsSite` construct's `environment` prop.
2. The `sst-env` CLI will traverse up the directories to look for the root of your SST app. If the static site or Next.js app is located outside the SST app folder, pass in [`--path`](#--path) to specify the relative path of the SST app.
3. It'll then find the file that's generated in step 1.
4. It'll load these as environment variables before running the start command.
npm package: @serverless-toolkit/cli
Description: Serverless application development runtime that deploys to your AWS account using the AWS-CDK.
Latest version: 3.0.83

# Serverless Toolkit (STK) CLI

### STK CLI

```
Usage: stk COMMAND

Kommandos:
  stk dev        Start development.
  stk test       Start local test execution.
  stk logs       Watch logs.
  stk sync       Sync code files.
  stk init       Prepare a local development environment.
  stk bootstrap  Bootstrap the runtime environment in AWS.
  stk destroy    Destroy the runtime environment in AWS.

Optionen:
  -v, --version  Version anzeigen                                      [boolean]
  -h, --help     Hilfe anzeigen                                        [boolean]
```

## Setup a new project

```
➜ npx @serverless-toolkit/cli@latest init
```

**or**

```
➜ npm create @serverless-toolkit/cli@latest
```

```
✔ Enter your project name: · api
✔ Do you wanna use Route53 domain? (y/N) · true
✔ Enter your Route53 domain name: · serverless-toolkit.com
✔ Do you wanna use GitHub actions for deployments? (y/N) · true

Project api initiated. Change to folder api and enter

stk bootstrap

to prepare the development in AWS.
```

### Bootstrap - prepare the serverless runtime in AWS

```
➜ cd api
➜ stk bootstrap
```

### Start local development

> File changes will be updated and deployed in the background.

```
➜ stk dev
```

### Manually deploy your file changes

```
➜ stk sync
```

### Manually run tests

```
➜ stk test
```

### Destroy the serverless runtime

```
➜ stk destroy
```

## API

### Key-Value Store

#### `get`

```typescript
context.store.get(id: string, type?: string);
```

#### `set`

```typescript
interface Item {
  id: string
}
context.store.set(item: Item, type?: string);
```

### Alarms

> Currently only supported in Sagas.

#### `inMinutes`

```typescript
context.alarm.inMintes(minutes: number);
```

#### `clear`

```typescript
context.alarm.clear();
```

## Run tests in local development

```
➜ yarn test
➜ yarn test workers
➜ yarn test pages
➜ yarn test sagas
```
npm package: @serverless/aws-cloudformation
Description: Easily Deploy AWS Cloudformation templates using [Serverless Components](https://github.com/serverless/components), and pass their outputs to other Serverless Components.
Author: Serverless, Inc.
Latest version: 1.0.0

# AWS Cloudformation

Easily Deploy AWS Cloudformation templates using [Serverless Components](https://github.com/serverless/components), and pass their outputs to other Serverless Components.

&nbsp;

- [AWS Cloudformation](#aws-cloudformation)
  - [1. Install](#1-install)
  - [2. Create](#2-create)
  - [3. Configure](#3-configure)
  - [4. Deploy](#4-deploy)
  - [New to Components?](#new-to-components)

&nbsp;

### 1. Install

```console
$ npm install -g serverless
```

### 2. Create

Just create a `serverless.yml` file

```shell
$ touch serverless.yml
$ touch .env      # your development AWS api keys
$ touch .env.prod # your production AWS api keys
```

the `.env` files are not required if you have the aws keys set globally and you want to use a single stage, but they should look like this.

```
AWS_ACCESS_KEY_ID=XXX
AWS_SECRET_ACCESS_KEY=XXX
```

### 3. Configure

```yml
# serverless.yml

name: my-service
stage: dev

myStack:
  component: '@serverless/aws-cloudformation'
  inputs:
    template:
      AWSTemplateFormatVersion: '2010-09-09'
      Description: Example stack 1
      Resources:
        LogGroup:
          Type: AWS::Logs::LogGroup
          Properties:
            LogGroupName: /log/group/one
            RetentionInDays: 14
      Outputs:
        LogGroupArn:
          Value:
            Fn::GetAtt:
              - LogGroup
              - Arn
```

Inputs can contain the following properties:

- `stackName` **[required]**. the name of the stack
- `template` **[required]**, the template to deploy, can also be a local path to the template, e.g. `./my-template.yml`
- `bucket`, the deployment bucket where the template is stored before deployment. If not set, the template is sent on request and 52100 bytes size limit applies.
- `capabilities`, possible values are `CAPABILITY_IAM`, `CAPABILITY_NAMED_IAM`, and `CAPABILITY_AUTO_EXPAND`.
- `enableTerminationProtection`, possible values are `true` and `false`. Default is `false`.
- `rollbackConfiguration`, see [RollbackConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_RollbackConfiguration.html)
- `role`, role arn for the role which CloudFormation assumes to create the stack.
- `disableRollback`, possible values are `true` and `false`. Cannot be updated.

See [Request Parameters](https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_CreateStack.html#API_CreateStack_RequestParameters) for more info about capabilities, enableTerminationProtection, and role.

### 4. Deploy

```console
$ serverless
```

### New to Components?

Checkout the [Serverless Components](https://github.com/serverless/components) repo for more information.