All Projects → murraco → node-url-shortener

murraco / node-url-shortener

Licence: MIT license
URL Shortener in Base58 using Node.js, Express, Sequelize, Mocha and Bootstrap

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to node-url-shortener

tall
Promise-based, No-dependency URL unshortner (expander) module for Node.js
Stars: ✭ 56 (+166.67%)
Mutual labels:  url, url-shortener
Prestashop Clean Urls
Prestashop module. This override module allows to remove IDs from URLs
Stars: ✭ 87 (+314.29%)
Mutual labels:  url, url-shortener
Mnmlurl
🔗 Minimal URL - Modern URL shortener with support for custom alias & can be hosted even in GitHub pages [DEPRECATED]
Stars: ✭ 311 (+1380.95%)
Mutual labels:  url, url-shortener
nodejs-application-architecture
👨‍🔧 A discussion on how Node.js projects can be organized.
Stars: ✭ 81 (+285.71%)
Mutual labels:  mocha, sequelize
Breviare
Small URL shortener made with the MERN Stack
Stars: ✭ 16 (-23.81%)
Mutual labels:  url, url-shortener
Typescript Restful Starter
Node.js + ExpressJS + Joi + Typeorm + Typescript + JWT + ES2015 + Clustering + Tslint + Mocha + Chai
Stars: ✭ 97 (+361.9%)
Mutual labels:  mocha, sequelize
Url Shortener
Web application that will help you in shortening your url
Stars: ✭ 65 (+209.52%)
Mutual labels:  url, url-shortener
template-server-nodejs
No description or website provided.
Stars: ✭ 20 (-4.76%)
Mutual labels:  mocha, sequelize
Urlhub
URL shortener web application based on the Laravel PHP Framework.
Stars: ✭ 217 (+933.33%)
Mutual labels:  url, url-shortener
Urlshorting
A simple but powerful URL shortener
Stars: ✭ 150 (+614.29%)
Mutual labels:  url, url-shortener
express-mysql-rest
Building the simple api with sequelize, mysql and express js. this repository contains the code about how to use sequelize with mysql at express js. for example i have provide the crud operation to this repository. You can also testing the api with chai and mocha with chai-http by this repository
Stars: ✭ 25 (+19.05%)
Mutual labels:  mocha, sequelize
seedpress-cms
A headless CMS built in Express for PostgresQL using Sequelize. Generally follows the Wordpress post and term schema.
Stars: ✭ 71 (+238.1%)
Mutual labels:  mocha, sequelize
wily
Build Node.js APIs from the command line (Dead Project 😵)
Stars: ✭ 14 (-33.33%)
Mutual labels:  mocha, sequelize
trym
🔗 A modern URL shortener
Stars: ✭ 29 (+38.1%)
Mutual labels:  url, url-shortener
nodejs-integration-testing
Integration testing of a Node.js / Express.js / Sequelize app
Stars: ✭ 23 (+9.52%)
Mutual labels:  mocha, sequelize
Longurl
ℹ️ Small R package for no-API-required URL expansion
Stars: ✭ 30 (+42.86%)
Mutual labels:  url, url-shortener
Laravel Short Url
A Laravel package to shorten urls
Stars: ✭ 127 (+504.76%)
Mutual labels:  url, url-shortener
mnmlurl-extension
[DEPRECATED] 💁 Browser extension for Minimal URL - Modern URL shortener with support for custom alias & can be hosted even in GitHub pages
Stars: ✭ 21 (+0%)
Mutual labels:  url, url-shortener
node-server-template
This is Node.js server tidy template / boilerplate with Express (with asyncified handlers, custom error handler) framework and MongoDb. The server use ES6 and above. On different branches you can see different techniques' and technologies' usage, such as Kafka, nodemailer, file download... You also can find postman collections.
Stars: ✭ 116 (+452.38%)
Mutual labels:  mocha, sequelize
gravatar-url-generator
A fun and friendly generator of Gravatar urls.
Stars: ✭ 44 (+109.52%)
Mutual labels:  url

Node ES6 URL Shortener

Stack


Please help this repo with a if you find it useful! 😊


File structure

node-es6-url-shortener/
│
├── api/
│   ├── controllers/
│   │   └── UrlController.js
│   │
│   ├── models/
│   │   └── Url.js
│   │
│   └── helpers/
│      └── base58.js
│
├── config/
│   ├── env/
│   │   ├── development.js
│   │   ├── index.js
│   │   ├── production.js
│   │   └── test.js
│   │
│   ├── routes/
│   │   ├── index.js
│   │   └── url.js
│   │
│   ├── express.js
│   └── sequelize.js
│
├── view/
│   ├── css/
│   │   └── styles.css
│   │
│   ├── javascript/
│   │   └── shorten.js
│   │
│   └── index.html
│
├── test/
│   └── url.test.js
│
├── .eslintrc                     * ESLint configuration file
├── .gitignore                    * Example git ignore file
├── index.mjs                     * Entry point of our Node's app
├── LICENSE                       * MIT License
├── package.json                  * Defines our JavaScript dependencies
├── package-lock.json             * Defines our exact JavaScript dependencies tree
└── README.md                     * This file

Screenshot

Introduction

What's a URL Shortener?

URL shortening is a technique to convert a long URL (site or page address) to a shorter version. This shorter version of the URL is usually cleaner and easier to share or remember. When someone accesses the shortened address, the browser redirects to the original (large) url address. It is also called URL redirection or URL redirect.

For example, the large version of this url: http://en.wikipedia.org/wiki/URL_shortening

Can be shortened with bit.do service to this small address, that redirects to the previous longer address: http://bit.do/urlwiki

How does it work?

Essentially, your database has 3 fields: primaryKey, shortCode and targetURL.

Normally the shortCode is simply the primaryKey (which is an int) converted to another base. So for instance base 36 (so 0 through 9, and then 'a' through 'z').

This makes it easy to look up the targetURL in the database, since you can just decode it to base 10 and find the primary key.

You will also have short URLs since the number of URLs you can have is 36^n where n is the number of characters in the shortened URL. So you can see that just with 4 letters you can have a possible of 2,313,441 different URLs. If you use capital letters (a larger base), this gets even larger.

How to use this code?

  1. Make sure you have the latest stable version of Node.js installed
$ sudo npm cache clean -f
$ sudo npm install -g n
$ sudo n stable
  1. Configure your database and jsonwebtoken in config/env. For example config/env/development.js would look like this:
module.exports = {
  mysql: {
    host: 'localhost',
    port: 3306,
    database: 'shortener_dev',
    username: 'root',
    password: '',
  }
};
  1. Fork this repository and clone it
$ git clone https://github.com/<your-user>/node-es6-url-shortener
  1. Navigate into the folder
$ cd node-es6-url-shortener
  1. Install NPM dependencies
$ npm install
  1. Make sure you have a MySQL DB up and running, if you don't, using docker is the easiest way
$ docker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -t mysql -d mysql

Login into the container, update the root user and create databases

$ docker exec -it <CONTAINER ID> mysql -uroot
$ ALTER USER root IDENTIFIED WITH mysql_native_password BY 'root';
$ CREATE DATABASE shortener_dev;
$ CREATE DATABASE shortener_dev_dev;
$ CREATE DATABASE shortener_dev_test;
  1. Run the project
$ node index.js
  1. Or use nodemon for live-reload
$ npm start

npm start will run nodemon index.js.

  1. Navigate to http://localhost:3000 in your browser to test it!

  2. If you want to execute the tests

$ npm test

npm test will run mocha.

Contribution

  • Report issues
  • Open pull request with improvements
  • Spread the word
  • Reach out to me directly at [email protected]
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].