{"id":19612512,"url":"https://github.com/murraco/node-url-shortener","last_synced_at":"2025-07-13T18:41:56.095Z","repository":{"id":42225687,"uuid":"112135688","full_name":"murraco/node-url-shortener","owner":"murraco","description":"URL Shortener in Base58 using Node.js, Express, Sequelize, Mocha and Bootstrap","archived":false,"fork":false,"pushed_at":"2025-02-19T14:41:11.000Z","size":337,"stargazers_count":34,"open_issues_count":0,"forks_count":28,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T04:31:50.271Z","etag":null,"topics":["bootstrap","es6","express","mocha","node","sequelize","url","url-shortener"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/murraco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":"murraco","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2017-11-27T02:09:28.000Z","updated_at":"2025-02-19T14:41:07.000Z","dependencies_parsed_at":"2024-04-24T00:26:18.829Z","dependency_job_id":"bafbdf58-919f-4a40-b9ee-2fccd220d6e6","html_url":"https://github.com/murraco/node-url-shortener","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murraco%2Fnode-url-shortener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murraco%2Fnode-url-shortener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murraco%2Fnode-url-shortener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murraco%2Fnode-url-shortener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/murraco","download_url":"https://codeload.github.com/murraco/node-url-shortener/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251219600,"owners_count":21554444,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bootstrap","es6","express","mocha","node","sequelize","url","url-shortener"],"created_at":"2024-11-11T10:46:57.785Z","updated_at":"2025-04-27T22:34:02.805Z","avatar_url":"https://github.com/murraco.png","language":"JavaScript","funding_links":["https://ko-fi.com/murraco"],"categories":[],"sub_categories":[],"readme":"# Node ES6 URL Shortener\n\n![](https://img.shields.io/badge/node-success-brightgreen.svg)\n![](https://img.shields.io/badge/test-success-brightgreen.svg)\n\n# Stack\n\n![](https://img.shields.io/badge/node_8-✓-blue.svg)\n![](https://img.shields.io/badge/ES6-✓-blue.svg)\n![](https://img.shields.io/badge/express-✓-blue.svg)\n![](https://img.shields.io/badge/sequelize-✓-blue.svg)\n\n# File structure\n\n```\nnode-es6-url-shortener/\n│\n├── api/\n│   ├── controllers/\n│   │   └── UrlController.js\n│   │\n│   ├── models/\n│   │   └── Url.js\n│   │\n│   └── helpers/\n│      └── base58.js\n│\n├── config/\n│   ├── env/\n│   │   ├── development.js\n│   │   ├── index.js\n│   │   ├── production.js\n│   │   └── test.js\n│   │\n│   ├── routes/\n│   │   ├── index.js\n│   │   └── url.js\n│   │\n│   ├── express.js\n│   └── sequelize.js\n│\n├── view/\n│   ├── css/\n│   │   └── styles.css\n│   │\n│   ├── javascript/\n│   │   └── shorten.js\n│   │\n│   └── index.html\n│\n├── test/\n│   └── url.test.js\n│\n├── .eslintrc                     * ESLint configuration file\n├── .gitignore                    * Example git ignore file\n├── index.mjs                     * Entry point of our Node's app\n├── LICENSE                       * MIT License\n├── package.json                  * Defines our JavaScript dependencies\n├── package-lock.json             * Defines our exact JavaScript dependencies tree\n└── README.md                     * This file\n```\n\n# Screenshot\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/murraco/node-es6-url-shortener/blob/master/screenshot.png\" width=\"90%\" /\u003e\n\u003c/p\u003e\n\n# Introduction\n\n## What's a URL Shortener?\n\n 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.\n\nFor example, the large version of this url:\nhttp://en.wikipedia.org/wiki/URL_shortening\n\nCan be shortened with bit.do service to this small address, that redirects to the previous longer address:\nhttp://bit.do/urlwiki\n\n## How does it work?\n\nEssentially, your database has 3 fields: `primaryKey`, `shortCode` and `targetURL`.\n\nNormally 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').\n\nThis 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.\n\nYou 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. \n\n## How to use this code?\n\n1. Make sure you have the latest stable version of Node.js installed\n\n```\n$ sudo npm cache clean -f\n$ sudo npm install -g n\n$ sudo n stable\n```\n\n2. Configure your database and jsonwebtoken in `config/env`. For example `config/env/development.js` would look like this:\n\n```js\nmodule.exports = {\n  mysql: {\n    host: 'localhost',\n    port: 3306,\n    database: 'shortener_dev',\n    username: 'root',\n    password: '',\n  }\n};\n```\n  \n3. Fork this repository and clone it\n  \n```\n$ git clone https://github.com/\u003cyour-user\u003e/node-es6-url-shortener\n```\n  \n4. Navigate into the folder  \n\n```\n$ cd node-es6-url-shortener\n```\n  \n5. Install NPM dependencies\n\n```\n$ npm install\n```\n  \n6. Make sure you have a MySQL DB up and running, if you don't, using docker is the easiest way\n\n```\n$ docker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -t mysql -d mysql\n```\nLogin into the container, update the root user and create databases\n\n```\n$ docker exec -it \u003cCONTAINER ID\u003e mysql -uroot\n$ ALTER USER root IDENTIFIED WITH mysql_native_password BY 'root';\n$ CREATE DATABASE shortener_dev;\n$ CREATE DATABASE shortener_dev_dev;\n$ CREATE DATABASE shortener_dev_test;\n```\n\n7. Run the project\n\n```\n$ node index.js\n```\n  \n8. Or use `nodemon` for live-reload\n  \n```\n$ npm start\n```\n\n\u003e `npm start` will run `nodemon index.js`.\n\n9. Navigate to `http://localhost:3000` in your browser to test it!\n\n10. If you want to execute the tests\n\n```\n$ npm test\n```\n\n\u003e `npm test` will run `mocha`.\n\n# Contribution\n\n- Report issues\n- Open pull request with improvements\n- Spread the word\n- Reach out to me directly at \u003cmauriurraco@gmail.com\u003e\n\n# Buy me a coffee to show your support!\n\n[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/murraco)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmurraco%2Fnode-url-shortener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmurraco%2Fnode-url-shortener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmurraco%2Fnode-url-shortener/lists"}