# serverless-apig-s3

This Serverless plugin automates the process of both configuring AWS to serve static front-end
content and deploying your client-side bundle.

It creates an S3 bucket to hold your front-end content, and adds two routes to API Gateway:

 * `GET / => bucket/index.html`
 * `GET /assets/* => bucket/*`

This allows your API and front-end assets to be served from the same domain, sidestepping
any CORS issues. CloudFront is also not used. The combination of these two properties
makes this plugin a good fit for a dev stage environment.

### Installation

```bash
npm i -D serverless-apig-s3
```

This plugin requires node > 7.6 because fuck callbacks.

### Configuration

serverless.yml:

```yaml
plugins:
 - serverless-apig-s3

custom:
  apigs3:
    dist: client/dist    # path within service to find content to upload (default: client/dist
```

### Usage

```bash
sls deploy    # ensure that sls deploy has been run so that this plugin's resources exist.
sls client deploy    # uploads client build artifacts to s3
```

### Options:

There are none! Seriously though, if you need any, just raise a PR or an Issue.

Something missing? More documentation? All PRs welcome at https://github.com/sdd/serverless-apig-s3

# serverless-apig-s3

This Serverless plugin automates the process of both configuring AWS to serve static front-end
content and deploying your client-side bundle.

It creates an S3 bucket to hold your front-end content, and adds two routes to API Gateway:

 * `GET / => bucket/index.html`
 * `GET /assets/* => bucket/*`

This allows your API and front-end assets to be served from the same domain, sidestepping
any CORS issues. CloudFront is also not used. The combination of these two properties
makes this plugin a good fit for a dev stage environment.

### Installation

```bash
npm i -D serverless-apig-s3
```

This plugin requires node > 7.6 because fuck callbacks.

### Configuration

serverless.yml:

```yaml
plugins:
 - serverless-apig-s3

custom:
  apigs3:
    dist: client/dist    # path within service to find content to upload (default: client/dist
    topFiles: true       # create routes for top-level files in dist folder (default: false)
```

### Usage

```bash
sls deploy    # ensure that sls deploy has been run so that this plugin's resources exist.
sls client deploy    # uploads client build artifacts to s3
```

### Options:

There are none! Seriously though, if you need any, just raise a PR or an Issue.

Something missing? More documentation? All PRs welcome at https://github.com/sdd/serverless-apig-s3

Add topFiles config to readme
Add topFiles config to readme
