Skip to content

Instantly share code, notes, and snippets.

Avatar

Eran Stiller estiller

View GitHub Profile
@estiller
estiller / test.sh
Created Jul 9, 2020
Building a Custom URL Shortener Using Azure Functions and Cosmos DB - Final Test
View test.sh
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 Jul 9, 2020
Building a Custom URL Shortener Using Azure Functions and Cosmos DB - Initial Test Curl
View test.sh
curl -X POST -d "@./register/sample.dat" http://localhost:7071/api/register
@estiller
estiller / host.json
Last active Jul 9, 2020
Building a Custom URL Shortener Using Azure Functions and Cosmos DB - Customizing the Route Prefix
View host.json
{
"extensions": {
"http": {
"routePrefix": ""
}
}
}
@estiller
estiller / local.settings.json
Created Jul 9, 2020
Building a Custom URL Shortener Using Azure Functions and Cosmos DB - Configuring Cosmos DB
View local.settings.json
{
"Values": {
"RegistrationsDB": "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
}
}
@estiller
estiller / function.json
Last active Jul 9, 2020
Building a Custom URL Shortener Using Azure Functions and Cosmos DB - Adding the URL Redirect Endpoint
View function.json
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": ["get"],
"route": "{vanity}"
},
@estiller
estiller / index.js
Created Jul 9, 2020
Building a Custom URL Shortener Using Azure Functions and Cosmos DB - Adding the URL Redirect Endpoint
View index.js
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 Jul 9, 2020
Building a Custom URL Shortener Using Azure Functions and Cosmos DB - Authoring the URL Registration Endpoint
View index.js
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 Jul 9, 2020
Building a Custom URL Shortener Using Azure Functions and Cosmos DB - Authoring the URL Registration Endpoint
View function.json
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": ["post"],
"route": "register"
},