Router.js
const express = require("express");
const mongoose = require("mongoose");
const router = express.Router();
const multer = require("multer");
const path = require("path");
const File = require("../models/Files");
const mail = require("../handlers/mailer");
// Set storage engine
const storage = multer.memoryStorage();
// Init upload
const upload = multer({
storage: storage
}).single("file");
router.get("/", (req, res) => {
res.render("index");
});
router.post("/send", async (req, res, next) => {
await upload(req, res, async err => {
if (err) {
console.log("error by uploading file:", err);
} else {
console.log(`File is uploaded to the memoryStorage: ${req.file.originalname} `);
}
// Create a model to save in the database
const fileUpload = new File({
fromEmail: "<dk@bigbrother.nl>",
fromName: '"Dennis Klarenbeek 👻"',
email: req.body.email,
subject: req.body.subject,
msg: req.body.msg,
filename: req.file.originalname
});
await fileUpload.save((err, file, rows) => {
if (err) {
console.log("error on saving in the db");
} else {
console.log(`database item has been created: ${file.filename}`);
}
});
// Mail the uploaded attachment
await mail.send({
fromEmail: "dennis.klarenbeek@icloud.com",
fromName: '"Dennis Klarenbeek 👻"',
toEmail: req.body.email,
toName: req.body.name,
subject: req.body.subject,
msg: req.body.msg,
template: "attachment",
attachments: [
{
filename: req.file.filename,
contentType: req.file.mimetype,
content: req.file.buffer
}
]
});
});
res.redirect("/");
});
module.exports = router;
Logs2018-07-12T15:29:46.104415+00:00 heroku[router]: at=info method=GET path="/css/style.css" host=stormy-ocean-50061.herokuapp.com request_id=57113d1c-9730-40ca-9f41-0d5111854175 fwd="87.251.40.140" dyno=web.1 connect=1ms service=10ms status=304 bytes=237 protocol=https
2018-07-12T15:29:46.103429+00:00 heroku[router]: at=info method=GET path="/css/normalize.css" host=stormy-ocean-50061.herokuapp.com request_id=44a0f90b-1973-4daf-9f40-1e5e5398b9e4 fwd="87.251.40.140" dyno=web.1 connect=1ms service=7ms status=304 bytes=238 protocol=https
2018-07-12T15:29:46.487118+00:00 app[web.1]: [0mGET /webfonts/fa-light-300.woff2 [36m304 [0m0.353 ms - -[0m
2018-07-12T15:29:46.489183+00:00 heroku[router]: at=info method=GET path="/webfonts/fa-light-300.woff2" host=stormy-ocean-50061.herokuapp.com request_id=885eae11-3e4c-4efa-9b60-b3950d9f256d fwd="87.251.40.140" dyno=web.1 connect=1ms service=2ms status=304 bytes=239 protocol=https
2018-07-12T15:29:56.919861+00:00 app[web.1]: [0mPOST /send [36m302 [0m9.041 ms - 46[0m
2018-07-12T15:29:57.100559+00:00 heroku[router]: sock=backend at=error code=H18 desc="Server Request Interrupted" method=POST path="/send" host=stormy-ocean-50061.herokuapp.com request_id=aaafb074-b538-4983-bef1-fa1abf1f2413 fwd="87.251.40.140" dyno=web.1 connect=1ms service=191ms status=503 bytes=234 protocol=https
Does somebody know what this could be?from Heroku crash over and over by POST request, multer or nodemailer H=18
Travel and Tips
ReplyDeleteNZeTA for New Zealand
ReplyDeleteOn August 2019, the Government of New Zealand implemented the NZeTA to facilitate obtaining an authorization to visit the country for Tourism and Transit purposes. The new online process is valid for 2 years and allows multiple entries to New Zealand.
NZeTa can be easily obtained online, simplifying the process to enter New Zealand by offering travelers the option to apply directly online for a travel authorization.
The eTA for New Zealand grants its holder multiple entries to the country during its 2-year validity. Holders of the NZeTA are generally allowed to stay in the country for stays of up to 90 days from their date of arrival in New Zealand. Passports must have a minimum validity of at least three (3) months from the expected date of departure from New Zealand.
Visitors traveling to New Zealand for short-term stays can apply to have a NZeTA to travel to and within the country. To be able to obtain a valid eTA travel authority to visit New Zealand, travelers should complete an NZeTA online application. The online New Zealand eTA application is straightforward and simple to complete. To get the New Zealand eTA, citizens of eligible countries are required to carefully fill out an online application form.
The majority of foreign citizens who wish to enjoy a stay in the Russian Federation are required to apply for a eVisa for Russia, although the type of travel document required will depend on nationality, as well as the purpose and duration of the stay. Tourists intending to visit Russia for a short term stay can now apply for Russia eVisas, a much faster and more practical way to obtain a Russian travel authorization than the traditional Russian tourist visa.
ReplyDeleteeVisas allow visitors to apply for their Russian visa entirely online in minutes, from.
anywhere in the world. Passport copies, online application form, and other documents required for the visa can be submitted online. Currently, eVisas are available for specific Russian regions. In order to visit the regions of the Far East, Kaliningrad, and St Petersburg, it’s no longer necessary to present supporting documentation at a Russian embassy or consulate.
E-visas can be of the following categories only: ordinary business visa,ordinary tourist visa, and ordinary humanitarian visa. If the purpose of your journey to the Russian Federation does not correspond to any of the above, you should apply for a traditional visa at a diplomatic mission or consular office of the Russian Federation