-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (36 loc) · 1.4 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
const express = require('express');
const cors = require('cors');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const app = express();
const port = process.env.PORT || 3001;
const server = app.listen(port, () => console.log("Server Started!"));
const client = require('./server/db_connection');
const authRoutes = require('./server/authRoutes');
const movieRoutes = require('./server/movieRoutes');
const {User, MovieInteraction, V_Rating} = require('./server/models');
app.use(morgan('short'));
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.use(cors());
app.use(authRoutes);
app.use(movieRoutes);
app.get('/', async (req, res) => {
// const x = await MovieInteraction.query()
// // .findById(["abc", 63247, 'tv'])
// .where({username: "abc"})
// .delete();
// const x = await User.query();
// console.log(x);
// await V_Rating.query().insert({movie_id: 299534, rating: 3});
// await User.query().insert({username: "dragonbone81", email: "test", password: "test"})
// const user = await User.query()
// .eager('movies')
// .where("username", "dragonbone81");
// const x = await user[0]
// .$relatedQuery('movies')
// .insert({movie_id: 125});
// const user = await User.query().delete().where("username", "dragonbone81");
// res.json(user);
res.json({asd: "asd", db: "hi"});
});