Skip to content

Commit

Permalink
PR review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Meldiron committed Jan 22, 2023
1 parent 7f06ba8 commit 15d5680
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 151 deletions.
149 changes: 0 additions & 149 deletions deno/generate_short_url/.gitignore

This file was deleted.

20 changes: 20 additions & 0 deletions deno/generate_short_url/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ _Example input:_
}
```

```json
{
"provider": "tinyurl",
"url": "https://google.com/"
}
```

_Example output:_

```json
Expand All @@ -20,6 +27,13 @@ _Example output:_
}
```

```json
{
"success": false,
"message": "provider is required"
}
```

## 📝 Variables

List of variables used by this cloud function:
Expand Down Expand Up @@ -52,6 +66,12 @@ docker run -p 3000:3000 -e INTERNAL_RUNTIME_ENTRYPOINT=src/mod.ts -e INTERNAL_RU

Your function is now listening on port `3000`, and you can execute it by sending `POST` request with appropriate authorization headers. To learn more about runtime, you can visit Deno runtime [README](https://github.com/open-runtimes/open-runtimes/tree/main/runtimes/deno-1.24).

4. Execute function:

```
curl http:https://localhost:3000/ -d '{"variables":{"BITLY_TOKEN":"[YOUR_API_KEY]"},"payload": "{\"url\":\"https://appwrite.io/\",\"provider\":\"bitly\"}"}' -H "X-Internal-Challenge: secret-key" -H "Content-Type: application/json"
```

## 📝 Notes

- This function is designed for use with Appwrite Cloud Functions. You can learn more about it in [Appwrite docs](https://appwrite.io/docs/functions).
Expand Down
4 changes: 2 additions & 2 deletions deno/generate_short_url/src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export default async function (req: any, res: any) {
}),
});

if (response.status !== 201) {
res.json({ success: false, message: `${await response.text()}` });
if (response.status >= 400) {
res.json({ success: false, code: response.status, message: `${await response.text()}` });
return;
}

Expand Down

0 comments on commit 15d5680

Please sign in to comment.