Article
· Feb 5, 2023 2m read

COS Url Shortener

Hi Community!

I want to share with you mi first Open Exchange application.

It's a tool to made our developments easier. It's a micro service in a IRIS docker that help us in our new features giving us a way to add short links in our SMS, Email campaigns and for links of the different stores for our apps.

It's very easy to use it.

Simply clone this repo:

https://github.com/daniel-aguilar-garcia/cos-url-shortener.git

 

Open the folder in VSCode and start the docker.

 

 

After that you can create short link version of any link via api request. For example with Postman:

Body: Long url that you want make short

Campaign: Your campaign name

Length: Length of the postfix for the short url

ExpirationDays: How many days the link will be stored before be deleted.

 

The request returns all the values associated to the link entity you have to copy ShortUrl.

 

After get the short url you can use it simply adding it to the base url (in my case localhost)

 

And the user will be automatically redirected to the long url:

 

 

To request the data for a particular record provide the id in GET request like 'localhost:52773/info/id' . E.g.:

localhost:52773/info/RPLMMG

This will return JSON data for the url associated to the short link RPLMMG, something like that:

{"ShortUrl":"RPLMMG","LongUrl":"https://www.google.es","Campaing":"TEST","Length":6,"Clicked":false,"ExpirationDays":7,"ExpirationDate":66517}

 

If you want to delete request this REST API expects only the id of the record to delete. E.g. if the id=5 the following DELETE call will delete the record:

localhost:52773/delete/5

 

If you want enable the task cleaner for the expired links you only have to create a task in the portal and call this class method:

##class(dc.Sample.Url).DeleteExpiredUrl()

 

I hope you enjoy with this project and thanks for reading!

 

You can find this app in the Open Exchange here.

Discussion (0)1
Log in or sign up to continue