Serviço de encurtamento de URLs feito em NodeJS e Express.
Encurtar a URL - https://url-shortener-unyleya.herokuapp.com/shorten?url=http://www.google.com
Obtem lista de urls através da data de cadastro - https://url-shortener-unyleya.herokuapp.com/shortenedList?date=2022-01-30
Obtem URL encurtada através pelo Id - https://url-shortener-unyleya.herokuapp.com/shortenedId?id=2
Vistar URL encurtada - http://url-shortener-unyleya.herokuapp.com/v/
Certifique-se de ter os Node.js e Heroku Toolbelt instalados.
$ git clone https://github.com/adrianogba/node-url-shortening-service.git # or clone your own fork
$ cd node-url-shortening-service
$ npm install
$ npm start
O app irá rodar em localhost:5000.
$ heroku create
$ git push heroku master
$ heroku open
SQL exemplo da base:
CREATE TABLE shorturls (
id SERIAL PRIMARY KEY,
long_url varchar(255) NOT NULL,
created_date date NOT NULL,
creator_ip char(15) NOT NULL,
created_by int NOT NULL,
referrals int NOT NULL default '0'
);
Exemplo da estrutura das tabelas
id | long_url | created_date | creator_ip | creator_user_id | referrals
----+-----------------------------+---------------+-----------------+-----------------+-----------
1 | http://www.unyleya.edu.br | 1484139363025 | 222.111.222.111 | 1 | 0
2 | http://www.google.com | 1484141076745 | 222.111.222.111 | 1 | 1
3 | http://www.facebook.com | 1484552390269 | 222.111.222.111 | 1 | 0
Para mais informações sobre o Node.js no Heroku, seguem os artigos: