# Serverless Framework Node REST API on AWS

This template generates a Cloudformation script that will deploy the getTokon function 
This function executes all four authentication and calls

Endpoint: GET - https://a1g3kc8ch2.execute-api.eu-west-1.amazonaws.com/DEV/
Functions : getToken

Invoke GET : https://a1g3kc8ch2.execute-api.eu-west-1.amazonaws.com/DEV/getToken   

Functions : getTransactions (Sanlam)

Invoke GET : https://a1g3kc8ch2.execute-api.eu-west-1.amazonaws.com/DEV/getTransactions   

Functions : getTokenCheck

Invoke GET : https://a1g3kc8ch2.execute-api.eu-west-1.amazonaws.com/DEV/getTokenCheck

## Usage

### Deployment

```bash
serverless deploy --aws-profile xxxxxxxxx --verbose
```


### Local development

You can invoke your function locally by using the following command:

Functions : getToken
```bash
serverless invoke local --function getToken --aws-profile xxxxxxx --verbose
```

Functions : getTransactions
```bash
serverless invoke local --function getTransactions --aws-profile xxxxxxx --verbose
```

Functions : getTokenCheck
```bash
serverless invoke local --function getTokenCheck --path test/token_check.json --aws-profile xxxxxxx --verbose
```

Which should result in response similar to the following:

```
{
  "statusCode": 200,
  "body": "Success"
}
```

Alternatively, it is also possible to emulate API Gateway and Lambda locally by using `serverless-offline` plugin. In order to do that, execute the following command:

```bash
serverless plugin install -n serverless-offline
```

It will add the `serverless-offline` plugin to `devDependencies` in `package.json` file as well as will add it to `plugins` in `serverless.yml`.

After installation, you can start local emulation with:

```
serverless offline
```

To learn more about the capabilities of `serverless-offline`, please refer to its [GitHub repository](https://github.com/dherault/serverless-offline).
