https://github.com/simonaco/redditifier
Serverless Http endpoint that submits links to the reddit API
https://github.com/simonaco/redditifier
azure azure-functions nodejs reddit-api serverless
Last synced: about 1 year ago
JSON representation
Serverless Http endpoint that submits links to the reddit API
- Host: GitHub
- URL: https://github.com/simonaco/redditifier
- Owner: simonaco
- Created: 2019-04-06T12:30:07.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-06-05T05:02:21.000Z (almost 5 years ago)
- Last Synced: 2025-03-14T19:31:06.968Z (about 1 year ago)
- Topics: azure, azure-functions, nodejs, reddit-api, serverless
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Redditifier | [](https://dev.azure.com/sicotin/sicotin/_build/latest?definitionId=26&branchName=master&WT.mc_id=redditifier-github-sicotin)
## Deploy resources
[](https://portal.azure.com/?WT.mc_id=redditifier-github-sicotin#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fsimonaco%2Fredditifier%2Fmaster%2Fazuredeploy.json)
## Prerequisites
1. A recent version of Node (8+)
1. VS Code: [here](https://code.visualstudio.com/download/?WT.mc_id=redditfier-github-sicotin)
1. Azure Functions CLI: [here](https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local?WT.mc_id=redditfier-github-sicotin)
1. Azure Functions Extension for VS Code: [here](https://marketplace.visualstudio.com/items/?WT.mc_id=redditfier-github-sicotin&itemName=ms-azuretools.vscode-azurefunctions)
1. Azure account: [here](https://azure.microsoft.com/en-us/free/?wt.mc_id=redditfier-github-sicotin)
## How to run this
1. Clone this repository and cd into *serverless*
1. Create *local.settings.json* file and add:
```json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "node",
"REDDIT_KEY": "YOUR-TOKEN-HERE",
}
}
```
> Retrieve your Reddit access token by following steps in the *Get Reddit Authorisation token* section.
1. Run ```npm i``` and ```npm start```
1. To test your function, make a POST request to your function's URL [http://localhost:7071/api/submit-link](http://localhost:7071/api/submit-link) with a body that looks like this:
```json
{
"title":"Use this *checklist* to review your application architecture from a *resiliency* standpoint; Application Design, Data Management, Security, Testing & Deployment",
"url":"https://docs.microsoft.com/azure/architecture/checklist/resiliency?WT.mc_id=redditifier-github-sicotin",
"sr":"/r/AZURE/"
}
```
## Get Reddit Authorisation token
Before requesting an authorization toked you need to create an application. If you haven't done that already, make sure to follow steps in this [quick start example](https://github.com/reddit-archive/reddit/wiki/OAuth2-Quick-Start-Example).
Make request to [https://www.reddit.com/api/v1/access_token](https://www.reddit.com/api/v1/access_token)
Authorization: Basic Auth
Username:
Password:
Form Data:
grant_type: password
username:
password:
If all goes well, you should get a response that looks similar to this:
```json
{
"access_token": "1224568486-RCwzdKMP4zdSt6ASetZpYa80qr4",
"token_type": "bearer",
"expires_in": 3600,
"scope": "*"
}
```
🙋🏼 Happy coding! 🙋🏼