![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
mongoose-url-shortener
Advanced tools
###MongooseURLShortener
Please Share on Twitter if you like #MongooseURLShortener
A simple URL Shortening library for NodeJS using Promises/A+ results.
####Installation
npm install mongoose-url-shortener --save
####API
//Setup Mongoose
var connection = require('mongoose').connect('mongodb:testing');
//Initialize Shortener
var urlShotener = MongooseURLShortener(connection, options);
#####Options { seed:12345, schema: { customSchemaValue:Number, customSchemaObj:{} } } Seed Optional value to use for generating short url's. You must always use the same seed otherwise you will not be able to resolve short urls' back to their original url.
Schema Optional schema properties for the Mongoose object. You can then pass the extra values you define here to be saved along with the URL when shortening or resolving
#####Shorten Shorten will either create a new short url in your database or resolve to a previously shortened URL.
url = 'http://www.google.com';
data = { 'any data you want to record with the short url' : true }
var promise = urlShortener.shorten(url, data);
promise.then(function(url){
console.log(url.hash);
//aGasjn1Ho
}).fail(function(err){
console.error('Error creating short url', err);
});
#####Resolve Resolve will return the original URL before shortening if one is available in the database.
hash = 'aGasjn1Ho';
data = {ip:'127.0.0.1'};
var result = urlShotener.resolve(hash, data);
result.then(function(url){
console.log(url );
// {
// type: 'MongooseURLShortener',
// url: 'http://www.google.com',
// hash:'aGasjn1Ho',
// hits:{
// {ip:'127.0.0.1},
// {ip:'127.0.0.1},
// },
// totalHits: 2
//}
}).fail(function(err){});
data is an optional object you would like to be saved with each resolution of a URL and can be used for such things as analytics tracking.
Check out NodeTinyUrl for a working implementation
Please Share on Twitter if you like #MongooseURLShortener
FAQs
mongoose-url-shortener
The npm package mongoose-url-shortener receives a total of 0 weekly downloads. As such, mongoose-url-shortener popularity was classified as not popular.
We found that mongoose-url-shortener 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.