Skip to content
Snippets Groups Projects
Commit 04b681aa authored by Trym Grande's avatar Trym Grande
Browse files

reverted to localhost

parent 538fea5f
No related branches found
No related tags found
No related merge requests found
{ {
"homepage": "http://it2810-54.idi.ntnu.no", "homepage": "http://localhost:3000",
"name": "project-3", "name": "project-4",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
"test": "react-scripts test", "test": "react-scripts test",
"eject": "react-scripts eject" "eject": "react-scripts eject"
}, },
"proxy": "http://it2810-54.idi.ntnu.no:4000", "proxy": "http://localhost:8080",
"eslintConfig": { "eslintConfig": {
"extends": [ "extends": [
"react-app", "react-app",
......
...@@ -34,8 +34,8 @@ class Header extends React.Component<MoviesProps, MyState> { ...@@ -34,8 +34,8 @@ class Header extends React.Component<MoviesProps, MyState> {
<input type="text" placeholder="Search for movie titles..." onChange={this.handleChange} id="textfield1"></input> <input type="text" placeholder="Search for movie titles..." onChange={this.handleChange} id="textfield1"></input>
<span>Movie genre:</span> <span>Movie genre:</span>
<input type="text" placeholder="Filter on genre..." onChange={this.handleChange} id="textfield2"></input> <input type="text" placeholder="Filter on genre..." onChange={this.handleChange} id="textfield2"></input>
{/* Order by year: */} Order by year:
{/* <input type="checkbox" id="checkbox1" onChange={this.handleChange}></input> */} <input type="checkbox" id="checkbox1" onChange={this.handleChange}></input>
<button className="button button2" onClick={this.search} >Search</button> <button className="button button2" onClick={this.search} >Search</button>
</div> </div>
) )
......
// used to send all requests to backend // used to send all requests to backend
export function queryFetch(query: String) { export function queryFetch(query: String) {
return fetch('http://it2810-54.idi.ntnu.no:4000/graphql', { return fetch('/graphql', {
method: 'POST', method: 'POST',
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ body: JSON.stringify({
......
...@@ -5528,11 +5528,6 @@ ...@@ -5528,11 +5528,6 @@
"is-obj": "^2.0.0" "is-obj": "^2.0.0"
} }
}, },
"dotenv": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
"integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q=="
},
"dotenv-expand": { "dotenv-expand": {
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-5.1.0.tgz", "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-5.1.0.tgz",
......
{ {
"name": "project-3", "name": "project-4",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
"web-vitals": "^1.1.2" "web-vitals": "^1.1.2"
}, },
"scripts": { "scripts": {
"start": "nodemon src/server_local.ts --exec ts-node", "start": "nodemon src/server.ts --exec ts-node",
"build": "tsc src/server.ts", "build": "tsc src/server.ts",
"test": "react-scripts test", "test": "react-scripts test",
"eject": "react-scripts eject" "eject": "react-scripts eject"
......
...@@ -4,7 +4,7 @@ var { graphqlHTTP } = require('express-graphql'); ...@@ -4,7 +4,7 @@ var { graphqlHTTP } = require('express-graphql');
var { GraphQLObjectType, GraphQLSchema, GraphQLInt, GraphQLString, GraphQLList, GraphQLBoolean } = require('graphql'); var { GraphQLObjectType, GraphQLSchema, GraphQLInt, GraphQLString, GraphQLList, GraphQLBoolean } = require('graphql');
import {sendQuery} from "./database" import {sendQuery} from "./database"
import * as cors from 'cors'; // import * as cors from 'cors';
const MovieType = new GraphQLObjectType({ const MovieType = new GraphQLObjectType({
name: "Movie", name: "Movie",
...@@ -76,7 +76,6 @@ const RootQuery = new GraphQLObjectType({ ...@@ -76,7 +76,6 @@ const RootQuery = new GraphQLObjectType({
async resolve(parent: any, args: any) { async resolve(parent: any, args: any) {
let query = ''; let query = '';
if(typeof args.title!='undefined' && typeof args.genre!='undefined'){ if(typeof args.title!='undefined' && typeof args.genre!='undefined'){
console.log("resolve")
query = getSearchQuery(args.title, args.genre, args.order)} query = getSearchQuery(args.title, args.genre, args.order)}
const response = await sendQuery(query); const response = await sendQuery(query);
return response[0]; return response[0];
...@@ -181,7 +180,7 @@ const schema = new GraphQLSchema({query: RootQuery, mutation: Mutation}) ...@@ -181,7 +180,7 @@ const schema = new GraphQLSchema({query: RootQuery, mutation: Mutation})
var app = express(); var app = express();
// Add headers // Add headers
app.use(function (req, res, next) { app.use(function (req: any, res: any, next: any) {
// Website you wish to allow to connect // Website you wish to allow to connect
res.setHeader('Access-Control-Allow-Origin', '*'); res.setHeader('Access-Control-Allow-Origin', '*');
...@@ -201,11 +200,11 @@ app.use(function (req, res, next) { ...@@ -201,11 +200,11 @@ app.use(function (req, res, next) {
}); });
app.use(cors()); // app.use(cors());
app.use('/graphql', graphqlHTTP({ app.use('/graphql', graphqlHTTP({
schema: schema, schema: schema,
graphiql: true, graphiql: true,
})); }));
app.listen(4000, () => console.log('Server running on port 4000')); app.listen(8080, () => console.log('Server running on port 8080'));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment