Skip to content

Commit

Permalink
feat: live check on file metadata microservice (#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
a2937 authored Nov 8, 2023
1 parent 1f5478f commit c33bca1
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions apps/file-metadata-microservice/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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;
module.exports = app;

0 comments on commit c33bca1

Please sign in to comment.