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",
"name": "project-3",
"homepage": "http://localhost:3000",
"name": "project-4",
"version": "0.1.0",
"private": true,
"dependencies": {
......@@ -27,7 +27,7 @@
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"proxy": "http://it2810-54.idi.ntnu.no:4000",
"proxy": "http://localhost:8080",
"eslintConfig": {
"extends": [
"react-app",
......
......@@ -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>
<span>Movie genre:</span>
<input type="text" placeholder="Filter on genre..." onChange={this.handleChange} id="textfield2"></input>
{/* Order by year: */}
{/* <input type="checkbox" id="checkbox1" onChange={this.handleChange}></input> */}
Order by year:
<input type="checkbox" id="checkbox1" onChange={this.handleChange}></input>
<button className="button button2" onClick={this.search} >Search</button>
</div>
)
......
// used to send all requests to backend
export function queryFetch(query: String) {
return fetch('http://it2810-54.idi.ntnu.no:4000/graphql', {
return fetch('/graphql', {
method: 'POST',
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
......
......@@ -5528,11 +5528,6 @@
"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": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-5.1.0.tgz",
......
{
"name": "project-3",
"name": "project-4",
"version": "0.1.0",
"private": true,
"dependencies": {
......@@ -27,7 +27,7 @@
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "nodemon src/server_local.ts --exec ts-node",
"start": "nodemon src/server.ts --exec ts-node",
"build": "tsc src/server.ts",
"test": "react-scripts test",
"eject": "react-scripts eject"
......
......@@ -4,7 +4,7 @@ var { graphqlHTTP } = require('express-graphql');
var { GraphQLObjectType, GraphQLSchema, GraphQLInt, GraphQLString, GraphQLList, GraphQLBoolean } = require('graphql');
import {sendQuery} from "./database"
import * as cors from 'cors';
// import * as cors from 'cors';
const MovieType = new GraphQLObjectType({
name: "Movie",
......@@ -76,7 +76,6 @@ const RootQuery = new GraphQLObjectType({
async resolve(parent: any, args: any) {
let query = '';
if(typeof args.title!='undefined' && typeof args.genre!='undefined'){
console.log("resolve")
query = getSearchQuery(args.title, args.genre, args.order)}
const response = await sendQuery(query);
return response[0];
......@@ -181,7 +180,7 @@ const schema = new GraphQLSchema({query: RootQuery, mutation: Mutation})
var app = express();
// Add headers
app.use(function (req, res, next) {
app.use(function (req: any, res: any, next: any) {
// Website you wish to allow to connect
res.setHeader('Access-Control-Allow-Origin', '*');
......@@ -201,11 +200,11 @@ app.use(function (req, res, next) {
});
app.use(cors());
// app.use(cors());
app.use('/graphql', graphqlHTTP({
schema: schema,
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