Skip to content

Instantly share code, notes, and snippets.

@estiller
Created July 9, 2020 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save estiller/6a6b87334c4e66882c891daac0bee526 to your computer and use it in GitHub Desktop.
Save estiller/6a6b87334c4e66882c891daac0bee526 to your computer and use it in GitHub Desktop.
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: {
status: 204,
},
};
}
return {
res: {
status: 400,
body:
"Please pass a a request body containing a url, vanity url and a submitted by fields",
},
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment