Last active
July 16, 2018 20:19
-
-
Save IchrakMansour/22a9b86413ffcb04441070a29e1f03b6 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' }); | |
}); | |
//route to handle user registration | |
router.post('/register', login.register); | |
router.post('/login', login.login); | |
router.post('/ajouterclient', clients.ajouterclient); | |
router.get('/listeclients', clients.listeclients); | |
router.get('/viewclient/', clients.viewclient); | |
router.get('/viewclient/:Code', clients.viewclient); | |
router.get('/editclient', clients.editclient); | |
//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