Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: live check on file metadata microservice #499

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading