javascript - Unexpected token ) in line that does not exist -


i'll rather post images code present issue better, these of last lines of file:

enter image description here

it clear code ends withing 237th line. when type "npm start" terminal keep getting:

enter image description here looks syntax error in nonexistent line of code.

i tripple checked file, try introducing syntax errors , checked if catches them. i'm sure file npm tries use. how come? maybe sublime text? has of ever experienced such weird issue?

edit:

 var express = require('express'),     router = express.router(),     mongoose = require('mongoose'), //mongo connection     bodyparser = require('body-parser'), //parses information post     me  thodoverride = require('method-override'); //used manipulate post  router.use(bodyparser.urlencoded({ extended: true })) router.use(methodoverride(function(req, res){       if (req.body && typeof req.body === 'object' && '_method' in req.body) {         // in urlencoded post bodies , delete         var method = req.body._method         delete req.body._method         return method       } }))  //build rest operations @ base blobs //this accessible http://127.0.0.1:3000/blobs if default route / left unchanged router.route('/')     //get blobs     .get(function(req, res, next) {         //retrieve blobs monogo         mongoose.model('blob').find({}, function (err, blobs) {               if (err) {                   return console.error(err);               } else {                   //respond both html , json. json responses require 'accept: application/json;' in request header                   res.format({                       //html response render index.jade file in views/blobs folder. setting "blobs" accessible variable in our jade view                     html: function(){                         res.render('blobs/index', {                               title: 'all blobs',                               "blobs" : blobs                           });                     },                     //json response show blobs in json format                     json: function(){                         res.json(infophotos);                     }                 });               }              });     })     //post new blob     .post(function(req, res) {         // values post request. these can done through forms or rest calls. these rely on "name" attributes forms         var name = req.body.name;         var badge = req.body.badge;         var dob = req.body.dob;         var company = req.body.company;         var isloved = req.body.isloved;         //call create function our database         mongoose.model('blob').create({             name : name,             badge : badge,             dob : dob,             isloved : isloved         }, function (err, blob) {               if (err) {                   res.send("there problem adding information database.");               } else {                   //blob has been created                   console.log('post creating new blob: ' + blob);                   res.format({                       //html response set location , redirect home page. create 'success' page if that's thing                     html: function(){                         // if worked, set header address bar doesn't still /adduser                         res.location("blobs");                         // , forward success page                         res.redirect("/blobs");                     },                     //json response show newly created blob                     json: function(){                         res.json(blob);                     }                 });               }         })     });      /* new blob page. */ router.get('/new', function(req, res) {     res.render('blobs/new', { title: 'add new blob' }); });    // route middleware validate :id router.param('id', function(req, res, next, id) {     //console.log('validating ' + id + ' exists');     //find id in database     mongoose.model('blob').findbyid(id, function (err, blob) {         //if isn't found, going repond 404         if (err) {             console.log(id + ' not found');             res.status(404)             var err = new error('not found');             err.status = 404;             res.format({                 html: function(){                     next(err);                  },                 json: function(){                        res.json({message : err.status  + ' ' + err});                  }             });                 router.route('/:id')   .get(function(req, res) {     mongoose.model('blob').findbyid(req.id, function (err, blob) {       if (err) {         console.log('get error: there problem retrieving: ' + err);       } else {         console.log('get retrieving id: ' + blob._id);         var blobdob = blob.dob.toisostring();         blobdob = blobdob.substring(0, blobdob.indexof('t'))         res.format({           html: function(){               res.render('blobs/show', {                 "blobdob" : blobdob,                 "blob" : blob               });           },           json: function(){               res.json(blob);           }         });       }     });   });    //get individual blob mongo id router.get('/:id/edit', function(req, res) {     //search blob within mongo     mongoose.model('blob').findbyid(req.id, function (err, blob) {         if (err) {             console.log('get error: there problem retrieving: ' + err);         } else {             //return blob             console.log('get retrieving id: ' + blob._id);             //format date value show correctly in our edit form           var blobdob = blob.dob.toisostring();           blobdob = blobdob.substring(0, blobdob.indexof('t'))             res.format({                 //html response render 'edit.jade' template                 html: function(){                        res.render('blobs/edit', {                           title: 'blob' + blob._id,                         "blobdob" : blobdob,                           "blob" : blob                       });                  },                  //json response return json output                 json: function(){                        res.json(blob);                  }             });         }     }); });   router.put('/:id/edit', function(req, res) {     // our rest or form values. these rely on "name" attributes     var name = req.body.name;     var badge = req.body.badge;     var dob = req.body.dob;     var company = req.body.company;     var isloved = req.body.isloved;     //find document id         mongoose.model('blob').findbyid(req.id, function (err, blob) {             //update             blob.update({                 name : name,                 badge : badge,                 dob : dob,                 isloved : isloved             }, function (err, blobid) {               if (err) {                   res.send("there problem updating information database: " + err);               }                else {                       //html responds going page or can fancy , create new view shows success page.                       res.format({                           html: function(){                                res.redirect("/blobs/" + blob._id);                          },                          //json responds showing updated values                         json: function(){                                res.json(blob);                          }                       });                }             })         }); });   //delete blob id router.delete('/:id/edit', function (req, res){     //find blob id     mongoose.model('blob').findbyid(req.id, function (err, blob) {         if (err) {             return console.error(err);         } else {             //remove mongo             blob.remove(function (err, blob) {                 if (err) {                     return console.error(err);                 } else {                     //returning success messages saying deleted                     console.log('delete removing id: ' + blob._id);                     res.format({                         //html returns main page, or can create success page                           html: function(){                                res.redirect("/blobs");                          },                          //json returns item message has been deleted                         json: function(){                                res.json({message : 'deleted',                                    item : blob                                });                          }                       });                 }             });         }     }); });  module.exports = router; 

you open:

// route middleware validate :id router.param('id', function(req, res, next, id) { 

and don't close it.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -