Showing
1 changed file
with
31 additions
and
0 deletions
server.js
0 → 100644
1 | +var express = require("express"); | ||
2 | +var login = require('./routes/loginroutes'); | ||
3 | +var bodyParser = require('body-parser'); | ||
4 | + | ||
5 | + | ||
6 | +var app = express(); | ||
7 | +app.use( bodyParser.urlencoded({ extended: true }) ); | ||
8 | +app.use( bodyParser.json() ); | ||
9 | + | ||
10 | + | ||
11 | +app.use(function(req, res, next) { | ||
12 | + res.header("Access-Control-Allow-Origin", "*"); | ||
13 | + res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); | ||
14 | + next(); | ||
15 | +}); | ||
16 | + | ||
17 | + | ||
18 | +var router = express.Router(); | ||
19 | + | ||
20 | + | ||
21 | +// test route | ||
22 | +router.get('/', function(req, res) { | ||
23 | + res.json({ message: 'welcome to our upload module apis' }); | ||
24 | +}); | ||
25 | + | ||
26 | + | ||
27 | +// route to handle user registration | ||
28 | +router.post('/register', login.register); | ||
29 | +router.post('/login', login.login) | ||
30 | +app.use('/api', router); | ||
31 | +app.listen(5000); |
-
Please register or login to post a comment