Skip to content

Instantly share code, notes, and snippets.

View estiller's full-sized avatar

Eran Stiller estiller

View GitHub Profile
@estiller
estiller / test.sh
Created July 9, 2020 21:25
Building a Custom URL Shortener Using Azure Functions and Cosmos DB - Final Test
curl -v -X POST -H 'Content-Type: application/json' \
-d '{ "url": "http://mydomain.com", "vanity": "shortname" }' \
http://localhost:7071/register
curl -v -X GET http://localhost:7071/shortname
@estiller
estiller / test.sh
Created July 9, 2020 21:15
Building a Custom URL Shortener Using Azure Functions and Cosmos DB - Initial Test Curl
curl -X POST -d "@./register/sample.dat" http://localhost:7071/api/register
@estiller
estiller / host.json
Last active July 9, 2020 20:15
Building a Custom URL Shortener Using Azure Functions and Cosmos DB - Customizing the Route Prefix
{
"extensions": {
"http": {
"routePrefix": ""
}
}
}
@estiller
estiller / local.settings.json
Created July 9, 2020 20:14
Building a Custom URL Shortener Using Azure Functions and Cosmos DB - Configuring Cosmos DB
{
"Values": {
"RegistrationsDB": "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
}
}
@estiller
estiller / function.json
Last active July 9, 2020 20:13
Building a Custom URL Shortener Using Azure Functions and Cosmos DB - Adding the URL Redirect Endpoint
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": ["get"],
"route": "{vanity}"
},
@estiller
estiller / index.js
Created July 9, 2020 20:13
Building a Custom URL Shortener Using Azure Functions and Cosmos DB - Adding the URL Redirect Endpoint
module.exports = async function (context, req, registration) {
context.log("Url redirect triggered");
if (registration) {
return {
res: {
status: 302,
headers: {
Location: registration.url,
},
@estiller
estiller / index.js
Created July 9, 2020 20:12
Building a Custom URL Shortener Using Azure Functions and Cosmos DB - Authoring the URL Registration Endpoint
module.exports = async function (context, req) {
context.log("Url registration triggered");
if (req.body && req.body.url && req.body.vanity) {
return {
registration: {
id: req.body.vanity,
url: req.body.url,
},
res: {
@estiller
estiller / function.json
Last active July 9, 2020 20:11
Building a Custom URL Shortener Using Azure Functions and Cosmos DB - Authoring the URL Registration Endpoint
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": ["post"],
"route": "register"
},