Nintex assignment code
Make sure NPM or Yarn is installed on your machine before running anything
yarn
npm install
yarn start
Or if you use NPM you can:
npm run start
This code contains:
-
Mongodb for storing data.
Make sure mondodb is installed on your local system and the server instance is running and create a document with the name 'url-shortner' in my case it was 'mongodb://localhost:27017/url-shortner'
-
API endpoints for url shortening service.
-
Swagger UI for testing the service endpoints.
-
Travis CI pipeline for solution building. Details could be found in
.travis.yml
It would require port 5000 from your end.
http://{baseurl}/docs/swagger/index.html
In my case the baseurl was localhost:5000
Following are sample input for endpoints
url:
http://localhost:5000/item
header:
Content-Type: application/json
body:
{
"originalUrl": "https://www.aliexpress.com/?src=google&albch=fbrnd&acnt=304-410-9721&isdl=y&aff_short_key=UneMJZVf&albcp=54095668&albag=1897140028&slnk=&trgt=kwd-464198394164&plac=&crea=257006900048&netw=g&device=c&mtctp=e&memo1=1t1&albbt=Google_7_fbrnd&aff_platform=google&albagn=888888&gclid=CjwKCAjwuqfoBRAEEiwAZErCsvlcwW7v5eX7avFWrZMO0cyNO-kwQC0-NhIjdVzurd25IvOhRBOD9hoCLNUQAvD_BwE",
"shortBaseUrl":"http://localhost:5000"
}
output:
{
"_id": "5d12f0c2d558db2b5ccfe9fd",
"originalUrl": "https://www.aliexpress.com/?src=google&albch=fbrnd&acnt=304-410-9721&isdl=y&aff_short_key=UneMJZVf&albcp=54095668&albag=1897140028&slnk=&trgt=kwd-464198394164&plac=&crea=257006900048&netw=g&device=c&mtctp=e&memo1=1t1&albbt=Google_7_fbrnd&aff_platform=google&albagn=888888&gclid=CjwKCAjwuqfoBRAEEiwAZErCsvlcwW7v5eX7avFWrZMO0cyNO-kwQC0-NhIjdVzurd25IvOhRBOD9hoCLNUQAvD_BwE",
"shortUrl": "http://localhost:5000/vvI1WDelA",
"urlCode": "vvI1WDelA",
"updatedAt": "2019-06-26T04:12:50.706Z",
"createdAt": "2019-06-26T04:12:50.726Z",
"__v": 0
}
url:
http://localhost:5000/orignal/vvI1WDelA
header:
Content-Type: application/json
output:
"https://www.aliexpress.com/?src=google&albch=fbrnd&acnt=304-410-9721&isdl=y&aff_short_key=UneMJZVf&albcp=54095668&albag=1897140028&slnk=&trgt=kwd-464198394164&plac=&crea=257006900048&netw=g&device=c&mtctp=e&memo1=1t1&albbt=Google_7_fbrnd&aff_platform=google&albagn=888888&gclid=CjwKCAjwuqfoBRAEEiwAZErCsvlcwW7v5eX7avFWrZMO0cyNO-kwQC0-NhIjdVzurd25IvOhRBOD9hoCLNUQAvD_BwE"
http://localhost:5000/vvI1WDelA
to redirect to orignal URL. The id in url is saved in post call, make sure you are giving the id which is generated in your databse.