Api files no longer return router, exports usable functions.

This commit is contained in:
2020-08-27 00:31:01 +02:00
parent ec80aa8bcc
commit a6a84e4b29
4 changed files with 71 additions and 71 deletions

View File

@@ -1,15 +1,7 @@
const express = require("express");
const path = require("path");
const router = express.Router();
const fetch = require('node-fetch')
const path = require('path')
const mustBeAuthenticated = require(path.join(__dirname + "/../middleware/mustBeAuthenticated"))
router.use((req, res, next) => {
next();
});
router.route("/wineinfo/:ean").get(async (req, res) => {
const byEAN = async (req, res) => {
const vinmonopoletResponse = await fetch("https://app.vinmonopolet.no/vmpws/v2/vmp/products/barCodeSearch/" + req.params.ean)
.then(resp => resp.json())
@@ -25,7 +17,9 @@ router.route("/wineinfo/:ean").get(async (req, res) => {
})
}
res.send(vinmonopoletResponse);
});
return res.send(vinmonopoletResponse);
};
module.exports = router;
module.exports = {
byEAN
};