typescripting
This commit is contained in:
parent
d4a140dde7
commit
850a3bf4d2
7 changed files with 2364 additions and 120 deletions
|
@ -57,6 +57,7 @@ router.post("/login/password", passport.authenticate("local", {
|
|||
}));
|
||||
|
||||
router.post("/logout", function(req, res, next) {
|
||||
// @ts-ignore, logout is already initalized in app.js
|
||||
req.logout(function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
|
|
|
@ -85,10 +85,12 @@ function fetchMedia(req, res, next) {
|
|||
let router = express.Router();
|
||||
|
||||
router.get("/", function (req, res, next) {
|
||||
// @ts-ignore, user is part of req header
|
||||
if (!req.user) { return res.render("home"); }
|
||||
next();
|
||||
}, fetchMedia, function(req, res) {
|
||||
res.locals.filter = null;
|
||||
// @ts-ignore, user is part of req header
|
||||
res.render("index", { user: req.user });
|
||||
});
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ function handleUpload(req, res, next) {
|
|||
|
||||
for (let file in req.files) {
|
||||
let currentdate = Date.now();
|
||||
let expireDate= "";
|
||||
let expireDate;
|
||||
if (req.body.expire) {
|
||||
expireDate = new Date(currentdate + (req.body.expire * 24 * 60 * 60 * 1000));
|
||||
console.log(req.body.expire);
|
||||
|
@ -113,10 +113,10 @@ function handleUpload(req, res, next) {
|
|||
return next(err);
|
||||
}
|
||||
console.log(`Uploaded ${req.files[file].filename} to database`);
|
||||
if (expireDate != null || expireDate != undefined || expireDate != "")
|
||||
console.log(`It will expire in ${expireDate} days`);
|
||||
else
|
||||
if (expireDate == null)
|
||||
console.log("It will not expire");
|
||||
else if (expireDate != null || expireDate != undefined || expireDate != "")
|
||||
console.log(`It will expire on ${expireDate}`);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue