Created
July 11, 2018 21:56
-
-
Save IchrakMansour/9e6f300f4e0bc26792deff366abd05df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require("express"); | |
var login = require('./routes/loginroutes'); | |
var clients = require('./routes/clientroutes'); | |
var cors = require('cors'); | |
var bodyParser = require('body-parser'); | |
/* | |
Module:multer | |
multer is middleware used to handle multipart form data | |
*/ | |
var app = express(); | |
app.use(bodyParser.urlencoded({ extended: true })); | |
app.use(bodyParser.json()); | |
app.use(function(req, res, next) { | |
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000/'); | |
res.setHeader('Access-Control-Allow-Credentials', true); | |
res.setHeader('Access-Control-Allow-Methods', ['PATCH', 'POST', 'GET', 'DELETE', 'PUT']); | |
res.setHeader('Access-Control-Allow-Headers', ['Content-Type']); | |
res.setHeader('Access-Control-Expose-Headers', ['Content-Type']); | |
/* res.header("Access-Control-Allow-Origin", "*"); | |
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");*/ | |
next(); | |
}); | |
app.use(cors()); | |
var router = express.Router(); | |
// test route | |
router.get('/', function(req, res) { | |
res.json({ message: 'welcome to our upload module apis' }); | |
}); | |
router.post('/register', login.register); | |
router.post('/login', login.login); | |
router.post('/ajouterclient', clients.ajouterclient); | |
router.post('/listeclients', clients.listeclients); | |
//route to handle file printing and listing | |
app.use('/app', router); | |
app.listen(4000); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment