Skip to content

Commit

Permalink
Kompletna priprema za pisanje API-ja (instalacija potrebnih bibliotek…
Browse files Browse the repository at this point in the history
…a kreiranje tabela i njihovih veza )
  • Loading branch information
Peco231 committed Apr 20, 2019
1 parent b278d54 commit fc25dec
Show file tree
Hide file tree
Showing 2,347 changed files with 261,353 additions and 13 deletions.
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}\\index.js"
}
]
}
22 changes: 22 additions & 0 deletions dbComponents/db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const Sequelize = require("sequelize");
const sequelize = new Sequelize(
"TYQcLL35gV", // database
"TYQcLL35gV", // username
"BLysSj9ZrP", // password
{host:"37.59.55.185",dialect:"mysql"});

const db={};

db.Sequelize = Sequelize;
db.sequelize = sequelize;

//import modela
db.zadaca = sequelize.import(__dirname + '/zadaca.js');
db.zadatak = sequelize.import(__dirname + '/zadatak.js');
db.mimeTip = sequelize.import(__dirname + '/mimeTip.js');

//relacije
db.zadaca.hasMany(db.zadatak, {as: 'zadaci' , foreignKey: 'idZadaca' });
db.zadatak.hasMany(db.mimeTip, {as: 'mimeTipovi' , foreignKey: 'idZadatak' });

module.exports=db;
29 changes: 29 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const express = require('express');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const db = require('./dbComponents/db.js');
const app = express();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(morgan('dev'))

db.sequelize.sync({force:false}).then(() => {
console.log("Usao u bazu!");
}).catch((e) => {
console.log("greska");
console.log(e);
});


app.post('/addZadaca', function(req, res) {

var bodyReq = req.body;




res.end("test1");
});

app.listen(6001);
15 changes: 15 additions & 0 deletions node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions node_modules/.bin/semver.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions node_modules/.bin/uuid

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions node_modules/.bin/uuid.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions node_modules/@types/node/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions node_modules/@types/node/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions node_modules/@types/node/assert.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

144 changes: 144 additions & 0 deletions node_modules/@types/node/async_hooks.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions node_modules/@types/node/base.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fc25dec

Please sign in to comment.