diff --git a/apps/file-metadata-microservice/server.js b/apps/file-metadata-microservice/server.js index eeb9c8d4..33f91105 100644 --- a/apps/file-metadata-microservice/server.js +++ b/apps/file-metadata-microservice/server.js @@ -5,7 +5,7 @@ var express = require('express'); var cors = require('cors'); var multer = require('multer'); -// here on HyperDev the fs is read only, +// here on HyperDev the fs is read only, // You have to upload the file to memory var storage = multer.memoryStorage(); var upload = multer({ storage: storage }); @@ -16,29 +16,32 @@ app.use(cors()); app.use('/public', express.static(process.cwd() + '/public')); app.get('/', function (req, res) { - res.sendFile(process.cwd() + '/views/index.html'); + res.sendFile(process.cwd() + '/views/index.html'); +}); + +app.get('/status/ping', (req, res) => { + res.send({ msg: 'pong' }).status(200); +}); + +// using 'multer' middleware... +app.post('/api/fileanalyse', upload.single('upfile'), function (req, res) { + res.json({ + name: req.file.originalname, + type: req.file.mimetype, + size: req.file.size }); - - // using 'multer' middleware... -app.post('/api/fileanalyse',upload.single('upfile'), function(req, res){ - res.json({ - 'name' : req.file.originalname, - 'type' : req.file.mimetype, - 'size' : req.file.size - }); }); - - // 404-NOT FOUND Middleware - app.use(function(req, res){ - res.status(404); - res.type('txt').send('Not found'); - }); +// 404-NOT FOUND Middleware +app.use(function (req, res) { + res.status(404); + res.type('txt').send('Not found'); +}); const portNum = process.env.PORT || 3000; app.listen(portNum, function () { - console.log("Listening on port " + portNum); + console.log('Listening on port ' + portNum); }); -module.exports = app; \ No newline at end of file +module.exports = app;