-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
59 lines (45 loc) · 1.84 KB
/
index.js
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
50
51
52
53
54
55
56
57
58
59
var express = require('express');
const app = express();
const dotenv = require('dotenv');
dotenv.config();
const db = require('./db.js');
var PORT = process.env.PORT || 31918
//Konekcija na bazu
db.sequelize.sync()
.then(() => console.log("Modul Student uspješno konektovan"))
.catch((err) => console.log("Modul Stdudent nije konektovan! GRESKA:", err));
//Setovanje header-a
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header('Access-Control-Allow-Methods', 'GET,HEAD,OPTIONS,POST,PUT');
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
next();
});
//Importovanje dostupnih ruta
var predmeti = require('./Routes/predmeti.js');
var ag = require('./Routes/akademskegodine.js');
var studenti = require('./Routes/studenti.js');
var zavrsni = require('./Routes/temezavrsni.js');
var profesori = require('./Routes/profesori.js');
var ugovori = require('./Routes/ugovori.js');
var ispiti = require('./Routes/ispiti.js');
var ocjene = require('./Routes/ocjene.js');
var prosjek = require('./Routes/prosjek.js');
var odsjek = require('./Routes/odsjek.js');
var zadace = require('./Routes/zadace.js');
//Definisanje koristenja dostupnih ruta
app.use('/predmeti', predmeti);
app.use('/akademskegodine', ag);
app.use('/studenti', studenti);
app.use('/temezavrsni', zavrsni);
app.use('/profesori', profesori);
app.use('/ugovori', ugovori);
app.use('/ispiti', ispiti);
app.use('/ocjene', ocjene);
app.use('/prosjek', prosjek);
app.use('/odsjek', odsjek);
app.use('/zadace', zadace);
app.get('/', function (req, res) {
res.send('<img src="https://media.tenor.com/images/bda656ab43b34a34c95ee513db2707c0/tenor.gif" alt="Modul student" width="50%" height="50%">');
})
app.listen(PORT, function () { console.log('server successfully started on port ' + PORT); });