Browse Source

When you run out of ideas but you still want cleaner code

Brendan Abolivier 8 years ago
parent
commit
f7d1266480
Signed by: Brendan Abolivier <contact@brendanabolivier.com> GPG key ID: 8EF1500759F70623
1 changed files with 3 additions and 5 deletions
  1. 3
    5
      server.js

+ 3
- 5
server.js View File

39
 
39
 
40
 app.options('*', cors(corsOptions));
40
 app.options('*', cors(corsOptions));
41
 
41
 
42
-app.all('*', function(req, res, next) {
43
-    res.header('Access-Control-Allow-Headers', 'Content-Type')
44
-    next();
45
-});
46
-
47
 
42
 
48
 // A request on /register generates a token and store it, along the user's
43
 // A request on /register generates a token and store it, along the user's
49
 // address, on the tokens object
44
 // address, on the tokens object
69
 
64
 
70
 // A request on /send with user input = mail to be sent
65
 // A request on /send with user input = mail to be sent
71
 app.post('/send', function(req, res, next) {
66
 app.post('/send', function(req, res, next) {
67
+    // Response will be JSON
68
+    res.header('Access-Control-Allow-Headers', 'Content-Type');
69
+    
72
     if(!checkBody(req.body)) {
70
     if(!checkBody(req.body)) {
73
         return res.status(400).send();
71
         return res.status(400).send();
74
     }
72
     }