[NJS] Creating a new post
Last post in the series is about creating a new post. This wasn't really needed, since the whole point of having my blog in Dropbox was to use any markdown editor I desire, save the file, run the sync command, and have it live, but for the sake of learning, I went ahead and added this feature too.
First, the routes:
router.get("/create/" + process.env.MY_SYNC_KEY, function(req, res) {
res.render("create-post", {
title: "Create",
metadata: "Create a post"
})
})
router.post("/create", function(req, res) {
if (req.params.token != process.env.MY_SYNC_KEY) { res.redirect("/"); return }
const body = req.body