31 lines
832 B
JavaScript
31 lines
832 B
JavaScript
var express = require('express');
|
|
var router = new express.Router();
|
|
var fs = require('fs');
|
|
var path = require('path');
|
|
|
|
// Mailer default page
|
|
router.get('/', function(request, response) {
|
|
response.json({});
|
|
});
|
|
|
|
// Notifications
|
|
router.use('/notification', require('./route/notification.js'));
|
|
|
|
// Serve static images
|
|
router.use('/static/:template/:image', function(request, response) {
|
|
let imagePath = path.join(__dirname, '/template/', request.params.template, '/image/', request.params.image);
|
|
|
|
fs.stat(imagePath, function(error) {
|
|
if (error)
|
|
return response.json({message: 'Image not found'});
|
|
|
|
let readStream = fs.createReadStream(imagePath);
|
|
|
|
readStream.on('open', function() {
|
|
readStream.pipe(response);
|
|
});
|
|
});
|
|
});
|
|
|
|
module.exports = router;
|