shorterurl Introduction
install package:
npm i --save shorterurl
this package is useful when you need to make your string safer and shorter.
-
you can make your string shorter by method
getShorter
and this method give you a shorttoken
. -
for transfer your token to original string you should use method
getOriginal
and pass your token. -
for save the data in your memory instead database you should use method
type
and passMEMORY
as an argument in that. -
for remove your un necessary data you can use method
purge
and you should pass a timestamp and then purge method delete all data before that time.
shorterurl
is a Promise
base, so you only need to use it as an await
.
shorterurl
store a result in a SQLite Database at <your root project>/shorterurl-database/database.sqlite
Example:
get Short string/url :
const shorter = ;const LONG_URL = "https://www.npmjs.com/package/shorterurl" // make string/url Shorter async { const short = await shorter; console; }; // it's gave you a token like "1rfN5BOw3"
if you want to validate
getShorter
token, we have usedshortId
in our package, so you can use shortId for your token validation.
get Original string/url :
const shorter = ;const TOKEN = "1rfN5BOw3";// pass shorter url and get the original url async { const original_url = await shorter; console;}; // it's gave you somting like https://www.npmjs.com/package/shorterurl
purge data :
const shorter = ; async { await shorter; console;};
save in memory :
const shorter = ;const LONG_URL = "https://www.npmjs.com/package/shorterurl"; async { await shortertype"MEMORY"; const short = await shorter; console;};