# Running Locally

After building, Scaffoldly created new repositories in your GitHub Organization. It's easy to run and debug them locally.

### Clone the Repository

```
➜  ~ git clone git@github.com:scaffoldly-demo/auth-sls-rest-api.git
Cloning into 'auth-sls-rest-api'...
remote: Enumerating objects: 98, done.
remote: Counting objects: 100% (98/98), done.
remote: Compressing objects: 100% (80/80), done.
remote: Total 98 (delta 20), reused 79 (delta 11), pack-reused 0
Receiving objects: 100% (98/98), 252.23 KiB | 1.24 MiB/s, done.
Resolving deltas: 100% (20/20), done.
```

### Download Dependencies

Run the `yarn` command

```
➜  ~ cd auth-sls-rest-api
➜  auth-sls-rest-api git:(main) yarn
yarn install v1.22.11
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
...
yarn run v1.22.11
$ tsc
✨  Done in 16.64s.
✨  Done in 135.47s.
```

This will take a minute or so...

### Starting the Application

#### Command Line

Run `yarn start` to launch the Application

```
➜  auth-sls-rest-api git:(main) ✗ yarn start
yarn run v1.22.11
$ SLS_DEBUG=* serverless offline start
Serverless: Load command interactiveCli
Serverless: Load command config
...
   ┌─────────────────────────────────────────────────────────────────────────────────────┐
   │                                                                                     │
   │   ANY     | http://localhost:3000/auth                                              │
   │   POST    | http://localhost:3000/2015-03-31/functions/lambda-handler/invocations   │
   │   OPTIONS | http://localhost:3000/auth                                              │
   │   POST    | http://localhost:3000/2015-03-31/functions/lambda-handler/invocations   │
   │   ANY     | http://localhost:3000/auth/{proxy*}                                     │
   │   POST    | http://localhost:3000/2015-03-31/functions/lambda-handler/invocations   │
   │   OPTIONS | http://localhost:3000/auth/{proxy*}                                     │
   │   POST    | http://localhost:3000/2015-03-31/functions/lambda-handler/invocations   │
   │                                                                                     │
   └─────────────────────────────────────────────────────────────────────────────────────┘

offline: [HTTP] server ready: http://localhost:3000 🚀
offline:
offline: Enter "rp" to replay the last request
```

This should take 20-30 seconds to start...

#### Within VSCode

Open the Repository in VSCode, and in the **Debug** menu, click the **Play** icon next to **Local Debug**

![](https://968799697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MKLlfWGgG_lqg_w6lw2%2Fuploads%2FwsGSlMor9WLPY1HubLQ3%2FScreen%20Shot%202021-10-20%20at%205.55.24%20PM.png?alt=media\&token=e20540e3-d644-4ef7-99c5-ff1bcafb169c) ![](https://968799697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MKLlfWGgG_lqg_w6lw2%2Fuploads%2FVd8O0RYPKaIGJUPNJdjI%2FScreen%20Shot%202021-10-20%20at%205.55.45%20PM.png?alt=media\&token=3b8dbf22-930b-45f3-8447-860d47aa5613)

![](https://968799697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MKLlfWGgG_lqg_w6lw2%2Fuploads%2F7S7U8vAU1ORrsQiV6Hwa%2FScreen%20Shot%202021-10-20%20at%205.58.25%20PM.png?alt=media\&token=5c1474f7-1eda-4ef1-a175-109986f087b3)

You'll see the output in the VSCode Terminal and Debug Console.

### Use the Application

Here's a couple examples:

```
➜  ~ curl http://localhost:3000/auth/version
{"version":"1.0.0-2"}%
```

```
➜  auth-sls-rest-api git:(main) ✗ curl http://localhost:3000/auth/api/health
{"name":"auth-sls-rest-api","healty":true,"now":"2021-10-21T00:59:48.627Z","version":"1.0.0-2"}%
```

#### Swagger UI

> <https://localhost:3000/auth/swagger.html>

### Debug The Application

If you ran the project with VSCode, you can set breakpoints.

![](https://968799697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MKLlfWGgG_lqg_w6lw2%2Fuploads%2FyfWdAC3NZP8yObUUly5j%2FScreen%20Shot%202021-10-20%20at%206.02.14%20PM.png?alt=media\&token=cbb37e75-46a4-4441-8250-b65bcc9c7506) ![](https://968799697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MKLlfWGgG_lqg_w6lw2%2Fuploads%2FpQScdlkKSesirb6Px7BN%2FScreen%20Shot%202021-10-20%20at%206.02.39%20PM.png?alt=media\&token=59bc8273-144c-42f7-aa6d-77dca4e6cab5)
