-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
49 lines (30 loc) · 1.17 KB
/
Copy pathapp.js
File metadata and controls
49 lines (30 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// config methodu bu paketi çağır demek .env(static const şeyler tanımlıyoruz sol tarafta görüceksin <--- ) dosyası için <--
const dotenv = require('dotenv').config();
const express = require('express');
const app = express();
//db bağlantısı
require('./src/config/database');
//routerlar include edilir.... <---
const authRouter = require('./src/routers/auth_router.js');
//Formdan gelen değerleri okuyabilmemiz için middlewarelar kullanmalıyız..
app.use(express.urlencoded({
extended: true,
}));
//public klasöründe css kodlar felan oluyor normalde senin işin değilde işlemlere odaklanman için bir el at
const ejs = require('ejs');
const expressLayouts = require('express-ejs-layouts');
const path = require('path');
app.use(expressLayouts);
app.use(express.static('public'));
app.use('/', authRouter);
app.set('view engine', 'ejs');
//default engine için bunu yazıyoruz. yazmasakta olurmuş ama <-----
app.set('views', path.resolve(__dirname, './src/views'));
app.get('/', (req, res) => {
res.send({
mesaj: 'merhaba'
})
});
app.listen(process.env.PORT, () => {
console.log('Server ${process.env.PORT} portundan ayaklandı');
});