Created
October 10, 2019 15:33
-
-
Save ramazankanbur/0cfd5c4d75a1a30644613d39c57207c0 to your computer and use it in GitHub Desktop.
sapmle
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 app = express(); | |
const bodyParser = require('body-parser'); //get post requestlerinin üzerinde ki bilgileri okuyabilmek için | |
const logger = require('morgan'); //log yapısı için kullanılan paket | |
const projectConfig = require('./config/projectConfig'); //proje için gereken global değişkenler | |
const mainRouter = require('./route/mainRouter'); //login olmadan kullanılacak url ler (nonapi) | |
const apiRuter = require('./route/apiRouter'); //api url leri | |
projectConfig.connectMongoDb(); | |
app.use(bodyParser.urlencoded({ extended: false })); | |
app.use(bodyParser.json()); | |
app.use(logger('dev')); | |
//authantice olduktan sonra kullanılabilen route | |
app.use('/api', apiRuter); | |
//authantice olmadan kullanılabilecek route | |
app.use('/', mainRouter); | |
app.use((err, req, res, next) => { | |
res.status(res.status).send({ "Hata": err }); | |
}); | |
app.listen(projectConfig.coreConfig.port, () => { | |
console.log(`${projectConfig.coreConfig.port} numaralı porttan dinleme başladı.`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment