2.1.0 • Published 8 years ago
tmplinker v2.1.0
Since 2.0.0 version tmplinker is the middleware for the express.
var express = require('express');
var router = express.Router();
var tmplinker = require('tmplinker');
tmplinker.plugin(router, {
secureDir: 'secure',
secret: 'ewjr98456y4h5th',
algorithm: 'rc4',
expirationTime: '6h', // Use 'none' for unlimited links
route: '/files'
});
Installation
$ npm install tmplinker
API
Tmplinker's api have 2 methods plugin()
and createLink()
.
plugin()
plugin(router, {params})
router
(required) - express router, function
params:
secureDir
(required) - your secure directory in root folder, stringsecret
(optional) - your password, default: Just A Secret, stringalgorithm
(optional) - algorithm for encryption link, default: aes192, stringexpirationTime
(optional) - time life link. Use 'none' for unlimited links, default: 3h, integer or stringroute
(optional) - route for download like a http://localhost:3000/download/:hash, default: /download, string
expirationTime
You can use Integer value for seconds like a 3600 or 3600s. And pattern like a 45i (45 minutes), 3h (3 hours), 1d (1 day), etc.
s: 1, // seconds
i: 60, // minute
h: 3600, // hour
d: 43200, // day
w: 302400, // week
m: 9072000, // month (30 days)
y: 108864000 // year
createLink()
createLink(filename, callback)
filename
(required) - name of the file in secure directory, string
Example
router.post('/createlink', function(req, res, next) {
tmplinker.createLink(req.body.filename, (err, link) => {
if(err)
return next();
res.status(200).send(`Your personal link: ${link}`);
});
});