title: How to define max uploaded file size & allowed file types in NodeJs restify bodyParser?
body: <p>I'm a newbie in node.js. I have already done to upload image file to Rest server using Restify module. but now, I need to insure that my uploaded image file size &amp; allowed file types in bodyParser restify. </p>
  
  <p>my restify code is: </p>
  
  <pre><code>var restify = require('restify'),
      fsEx = require('fs-extra'),
      md5 = require("md5"),
      path = require("path");
  
  var server = restify.createServer({
      name: 'Photo Upload api server'
  });
  
  server.use(restify.bodyParser({
      maxBodySize: 2,
      mapParms: true,
      mapFiles: true,
      keepExtensions: true
  }));
  
  
  server.post('/resized', function(req, res, next) {
  
      var tempPath = req.files.photos.path;
      var getFileExt = path.extname(tempPath);
      var finalFileName = Date.now() + getFileExt;
      var finalImgPath = __dirname + "/uploads/" + finalFileName;
  
      fsEx.move(tempPath, finalImgPath, function(err) {
  
          if (err) {
              return console.error(err);
          }
  
  
      });
  
      console.log('result FinalImage = ', finalImgPath);
  
      res.end('image resized');
      next();
  });
  </code></pre>