Created
October 10, 2019 15:36
-
-
Save ramazankanbur/340a235d4ae7a3ee3cf6184a083b4194 to your computer and use it in GitHub Desktop.
sample
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
const express = require('express'); | |
const userModel = require('../model/user'); | |
const Port = require('../config/projectConfig').coreConfig.port; | |
const userController = require('../controller/userController'); | |
const router = express.Router(); | |
router.get('/', (req, res, next) => { | |
res.send(`api http://localhost:${Port}/api den yayın yapmaktadır. /login ve /register sayfalarından giriş yapablirsiniz.`); | |
}); | |
router.post('/register', (req, res, next) => { | |
var promise = userController.register(req.body); | |
promise.then((registerResult) => { | |
if (registerResult.success) { | |
res.send({ message: `${registerResult.user.name} kullanıcısı başarılı bir şekilde eklendi` }); | |
} | |
else { | |
res.send({ message: `Kullanıcı ekleme esnasında bir hata oluştu. ${registerResult.message}` }); | |
} | |
}); | |
}); | |
router.post('/login', (req, res, next) => { | |
var promise = userController.loginControl(req.body); | |
promise.then((loginControlResult) => { | |
if (loginControlResult.success) { | |
res.send({ token: loginControlResult.token, message: loginControlResult.message }); | |
} | |
else { | |
res.send({ message: loginControlResult.message }); | |
} | |
}); | |
}); | |
module.exports = router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment