
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
URL Shortener by Melony Smith for Full Sail University: Deployment of Web Applications Online
URL Shortener is a NodeJS based RESTful API that allows you to provide a long, cumbersome link to be returned as a convenient six digit URL. The shortened URL will redirect to the page provided by the original link. This is especially useful for sharing links on social media sites that limit the number of characters you are allowed to post.
Clone or download this repository using the green "Clone or download" button for this repository. The button can be found up and to the right.
Once cloned, install using:
npm install
Start the server using:
node src/server.js
If you would like your server to watch for changes and run continuously you can use nodemon.
npm install nodemon
Start the server using:
nodemon src/server.js
[https://s29.postimg.org/r6ybuzc1j/localhost01.png]
CRUD for URLs
Method | Path | Result |
---|---|---|
POST | /api/v1/urls | Create a shortened URL |
GET | /api/v1/urls | Display all URLS |
GET | /api/v1/urls/:id | Displays URL based upon id |
POST | /api/v1/urls/:id | Update URL based upon id |
DELETE | /api/v1/urls/:id | Delete url based upon id |
Route | Result |
---|---|
/go/:shortURL | Redirect user to original URL based on the short URL |
There are various ways to work with the API but I recommend using Postman.
[https://s29.postimg.org/o1dq4rtfb/postman01.png]
[https://s29.postimg.org/yphh3m3ef/postman04.png]
[https://s29.postimg.org/5bqc1rq2f/postman05.png]
Installation:
npm install dotenv --save
Create and upload a .env (dotenv) file with the following information:
DB_NAME="your_db_name"
DB_USER="username"
DB_PASS="password"
DB_HOST="000.0.0.0"
DB_SCHEMA=mysql
DB_PORT=“0000”
Include and require .env:
require('dotenv').config()
Debugging = true (on; messages will appear within the console):
DEBUG=true node src/server.js
Debugging = false (off; messages will not appear within the console but will log to a file):
DEBUG=false node src/server.js
This API follows the coding style guide set by Airbnb.
You will first need to install mocha. In Terminal run the following command for unit testing:
mocha
For code coverage, check out istanbul.
FAQs
URL Shortener
The npm package link-short receives a total of 4 weekly downloads. As such, link-short popularity was classified as not popular.
We found that link-short demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.