first exchange between front and back no database
This commit is contained in:
parent
e77b99c31e
commit
9c9d855722
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
#.env
|
#.env
|
||||||
|
backend/node_modules/
|
||||||
48
backend/package-lock.json
generated
48
backend/package-lock.json
generated
@ -19,12 +19,12 @@
|
|||||||
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
|
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
|
||||||
},
|
},
|
||||||
"body-parser": {
|
"body-parser": {
|
||||||
"version": "1.20.1",
|
"version": "1.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
|
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz",
|
||||||
"integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==",
|
"integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"bytes": "3.1.2",
|
"bytes": "3.1.2",
|
||||||
"content-type": "~1.0.4",
|
"content-type": "~1.0.5",
|
||||||
"debug": "2.6.9",
|
"debug": "2.6.9",
|
||||||
"depd": "2.0.0",
|
"depd": "2.0.0",
|
||||||
"destroy": "1.2.0",
|
"destroy": "1.2.0",
|
||||||
@ -32,7 +32,7 @@
|
|||||||
"iconv-lite": "0.4.24",
|
"iconv-lite": "0.4.24",
|
||||||
"on-finished": "2.4.1",
|
"on-finished": "2.4.1",
|
||||||
"qs": "6.11.0",
|
"qs": "6.11.0",
|
||||||
"raw-body": "2.5.1",
|
"raw-body": "2.5.2",
|
||||||
"type-is": "~1.6.18",
|
"type-is": "~1.6.18",
|
||||||
"unpipe": "1.0.0"
|
"unpipe": "1.0.0"
|
||||||
}
|
}
|
||||||
@ -148,6 +148,38 @@
|
|||||||
"type-is": "~1.6.18",
|
"type-is": "~1.6.18",
|
||||||
"utils-merge": "1.0.1",
|
"utils-merge": "1.0.1",
|
||||||
"vary": "~1.1.2"
|
"vary": "~1.1.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"body-parser": {
|
||||||
|
"version": "1.20.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
|
||||||
|
"integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==",
|
||||||
|
"requires": {
|
||||||
|
"bytes": "3.1.2",
|
||||||
|
"content-type": "~1.0.4",
|
||||||
|
"debug": "2.6.9",
|
||||||
|
"depd": "2.0.0",
|
||||||
|
"destroy": "1.2.0",
|
||||||
|
"http-errors": "2.0.0",
|
||||||
|
"iconv-lite": "0.4.24",
|
||||||
|
"on-finished": "2.4.1",
|
||||||
|
"qs": "6.11.0",
|
||||||
|
"raw-body": "2.5.1",
|
||||||
|
"type-is": "~1.6.18",
|
||||||
|
"unpipe": "1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"raw-body": {
|
||||||
|
"version": "2.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz",
|
||||||
|
"integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==",
|
||||||
|
"requires": {
|
||||||
|
"bytes": "3.1.2",
|
||||||
|
"http-errors": "2.0.0",
|
||||||
|
"iconv-lite": "0.4.24",
|
||||||
|
"unpipe": "1.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"finalhandler": {
|
"finalhandler": {
|
||||||
@ -321,9 +353,9 @@
|
|||||||
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="
|
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="
|
||||||
},
|
},
|
||||||
"raw-body": {
|
"raw-body": {
|
||||||
"version": "2.5.1",
|
"version": "2.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz",
|
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
|
||||||
"integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==",
|
"integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"bytes": "3.1.2",
|
"bytes": "3.1.2",
|
||||||
"http-errors": "2.0.0",
|
"http-errors": "2.0.0",
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
"start": "node server.js"
|
"start": "node server.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"body-parser": "^1.20.2",
|
||||||
"express": "^4.18.2"
|
"express": "^4.18.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {},
|
"devDependencies": {},
|
||||||
|
|||||||
@ -1,46 +1,22 @@
|
|||||||
// const http = require('https');
|
|
||||||
// const host = 'localhost';
|
|
||||||
// const port = 443;
|
|
||||||
|
|
||||||
|
|
||||||
// // const server = http.createServer((req, res) => {
|
|
||||||
// // res.end('Voilà la réponse du serveur !');
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// const requestListener = function (req, res) {
|
|
||||||
// res.writeHead(200);
|
|
||||||
// res.end("My first server!");
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const server = http.createServer(requestListener);
|
|
||||||
// server.listen(port, host, () => {
|
|
||||||
// console.log(`Server is running on http://${host}:${port}`);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// 'use strict';
|
|
||||||
|
|
||||||
// const express = require('express');
|
|
||||||
// const app = express();
|
|
||||||
// app.get('/', (req, res) => {
|
|
||||||
// res.send('Hello World!')
|
|
||||||
// })
|
|
||||||
// app.listen(5000, () => console.log('Server is up and running'));
|
|
||||||
|
|
||||||
// const express = require('express')
|
|
||||||
// const app = express()
|
|
||||||
// const port = 5000
|
|
||||||
// const name = process.env.name || "World"
|
|
||||||
|
|
||||||
// app.get('/', (req, res) => {
|
|
||||||
// res.send(`Hello ${name} !`)
|
|
||||||
// })
|
|
||||||
// app.listen(port, () => {
|
|
||||||
// console.log(`Server Started on Port ${port}`)
|
|
||||||
// })
|
|
||||||
|
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
|
const bodyParser = require('body-parser');
|
||||||
const app = express();
|
const app = express();
|
||||||
app.get('/', (req, res) => {
|
// app.use(express.json());
|
||||||
res.sendfile('/var/www/html')
|
|
||||||
|
app.use(bodyParser.urlencoded({ extended: false }));
|
||||||
|
app.use(bodyParser.json());
|
||||||
|
|
||||||
|
app.get('/api/test', (req, res) => {
|
||||||
|
res.send('Hello World!')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.post('/api/login', (req, res) => {
|
||||||
|
|
||||||
|
// const formData = req.body;
|
||||||
|
// console.log(formData);
|
||||||
|
console.log('get request');
|
||||||
|
console.log(req.body);
|
||||||
|
res.status(201).json(req.body);
|
||||||
|
});
|
||||||
|
|
||||||
app.listen(5000, () => console.log('Server is up and running'));
|
app.listen(5000, () => console.log('Server is up and running'));
|
||||||
@ -10,23 +10,28 @@
|
|||||||
# }
|
# }
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 443 ssl;
|
|
||||||
listen 80 ssl;
|
|
||||||
# listen 443 ssl;
|
# listen 443 ssl;
|
||||||
#listen 80;
|
# listen 80 ssl;
|
||||||
|
# listen 443 ssl;
|
||||||
|
listen 80;
|
||||||
|
|
||||||
# server_name homemadePong.42.fr;
|
# server_name homemadePong.42.fr;
|
||||||
|
|
||||||
ssl_protocols TLSv1.3;
|
# ssl_protocols TLSv1.3;
|
||||||
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
|
# ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
|
||||||
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
|
# ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
|
||||||
|
|
||||||
# root /var/www/html;
|
# root /var/www/html;
|
||||||
# index index.html;
|
# index index.html;
|
||||||
|
|
||||||
# autoindex on;
|
# autoindex on;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
|
root /var/www/html;
|
||||||
|
index index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
location /api/login {
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
@ -34,6 +39,8 @@ server {
|
|||||||
|
|
||||||
proxy_pass http://backend:5000;
|
proxy_pass http://backend:5000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#proxy_pass http://localhost:5000
|
#proxy_pass http://localhost:5000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,8 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 80:80
|
- 80:80
|
||||||
# - 443:443
|
# - 443:443
|
||||||
|
volumes:
|
||||||
|
- ./frontend:/var/www/html
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
- pongNetwork
|
- pongNetwork
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
# By: apommier <apommier@student.42.fr> +#+ +:+ +#+ #
|
# By: apommier <apommier@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2023/03/19 09:28:33 by apommier #+# #+# #
|
# Created: 2023/03/19 09:28:33 by apommier #+# #+# #
|
||||||
# Updated: 2023/03/20 21:24:40 by apommier ### ########.fr #
|
# Updated: 2023/03/22 12:14:35 by apommier ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -27,7 +27,8 @@ FROM node:latest
|
|||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
COPY /backend/package*.json ./
|
COPY /backend/package*.json ./
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
#npm install body-parser
|
||||||
COPY /backend/ .
|
COPY /backend/ .
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
CMD ["npm", "start"]
|
# CMD ["npm", "start"]
|
||||||
# CMD ["node", "server.js"]
|
CMD ["node", "server.js"]
|
||||||
|
|||||||
@ -6,17 +6,17 @@
|
|||||||
# By: apommier <apommier@student.42.fr> +#+ +:+ +#+ #
|
# By: apommier <apommier@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2023/03/19 09:28:32 by apommier #+# #+# #
|
# Created: 2023/03/19 09:28:32 by apommier #+# #+# #
|
||||||
# Updated: 2023/03/20 19:48:53 by apommier ### ########.fr #
|
# Updated: 2023/03/21 11:08:16 by apommier ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
FROM nginx:latest
|
FROM nginx:latest
|
||||||
|
|
||||||
RUN apt update -y
|
# RUN apt update -y
|
||||||
RUN apt-get install -y openssl
|
# RUN apt-get install -y openssl
|
||||||
|
|
||||||
RUN mkdir -p /etc/ssl/private
|
# RUN mkdir -p /etc/ssl/private
|
||||||
RUN mkdir -p /etc/ssl/certs
|
# RUN mkdir -p /etc/ssl/certs
|
||||||
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt -subj "/C=FR/ST=17/L=StJeanDeLiversay/O=42/CN=apommier"
|
# RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt -subj "/C=FR/ST=17/L=StJeanDeLiversay/O=42/CN=apommier"
|
||||||
|
|
||||||
COPY conf/nginx.conf /etc/nginx/conf.d/default.conf
|
COPY conf/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
@ -42,6 +42,11 @@ footer {
|
|||||||
margin:auto;
|
margin:auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.submit{
|
||||||
|
height: 5vh;
|
||||||
|
border-radius: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
.submit:hover {
|
.submit:hover {
|
||||||
background-color: blueviolet;
|
background-color: blueviolet;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<link href="./css/header.css" rel="stylesheet">
|
<link href="./css/header.css" rel="stylesheet">
|
||||||
<title>BEST PONG EVER</title>
|
<title>BEST PONG EVER</title>
|
||||||
|
<script src="./js/login.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
@ -21,14 +22,24 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class ="login">
|
<div class ="login">
|
||||||
|
|
||||||
<form method="get" name="login" action="" class ="loginForm">
|
<form id="loginForm" method="post" name="login" action="/api/login" class ="loginForm">
|
||||||
<p class="loginHere">Login Here</p>
|
<p class="loginHere">Login Here</p>
|
||||||
<!-- <input type="text" name="prenom"> -->
|
<!-- <input type="text" name="prenom"> -->
|
||||||
<!-- <label>Login</label> : -->
|
<!-- <label>Login</label> : -->
|
||||||
<input type="text" name="login" placeholder="login">
|
<input type="text" name="login" placeholder="login">
|
||||||
<!-- <label>Password</label> : -->
|
<!-- <label>Password</label> : -->
|
||||||
<input type="text" name="password" placeholder="password">
|
<input type="text" name="password" placeholder="password">
|
||||||
<input class="submit" type="button" value="LOGIN">
|
<!-- <input class="submit" type="button" value="LOGIN" onclick="login()"> -->
|
||||||
|
<button class="submit" onclick="login()">LOGIN</button>
|
||||||
|
<!-- <script>
|
||||||
|
function login()
|
||||||
|
{
|
||||||
|
alert("Le bouton a été cliqué !");
|
||||||
|
var formulaire = document.getElementById("loginForm");
|
||||||
|
formulaire.submit();
|
||||||
|
}
|
||||||
|
</script> -->
|
||||||
|
|
||||||
<!-- <p>Texte à l'intérieur du formulaire</p> -->
|
<!-- <p>Texte à l'intérieur du formulaire</p> -->
|
||||||
</form>
|
</form>
|
||||||
<!-- <p>Texte après le formulaire</p>-->
|
<!-- <p>Texte après le formulaire</p>-->
|
||||||
|
|||||||
6
frontend/js/login.js
Normal file
6
frontend/js/login.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
function login()
|
||||||
|
{
|
||||||
|
alert("Le bouton a été cliqué !");
|
||||||
|
var formulaire = document.getElementById("loginForm");
|
||||||
|
formulaire.submit();
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user