routes added
This commit is contained in:
parent
3b6fa7eab6
commit
99d347a514
13
backend/routes/player.js
Normal file
13
backend/routes/player.js
Normal file
@ -0,0 +1,13 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
|
||||
//adding users to exisiting room or creating new room if full
|
||||
router.post('/add', function (req, res) {
|
||||
|
||||
});
|
||||
//deleting user in case he left before game started
|
||||
router.delete('/delete/{id}', function(req,res){
|
||||
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
24
backend/routes/room.js
Normal file
24
backend/routes/room.js
Normal file
@ -0,0 +1,24 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
|
||||
//creating new room in db
|
||||
router.post('/add', function (req, res) {
|
||||
|
||||
});
|
||||
|
||||
//deleting room after game ends
|
||||
router.delete('/delete/{id}', function(req,res){
|
||||
|
||||
});
|
||||
|
||||
//editing room every move
|
||||
router.put('/edit', function(req,res){
|
||||
|
||||
});
|
||||
|
||||
//get room values
|
||||
router.get('/', function(req,res){
|
||||
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
@ -2,7 +2,7 @@ var mongoose = require('mongoose');
|
||||
|
||||
var Schema = mongoose.Schema;
|
||||
|
||||
var GameRoomSchema = new Schema({
|
||||
var RoomSchema = new Schema({
|
||||
id: Number,
|
||||
createDate: Date,
|
||||
started: Boolean,
|
||||
@ -10,4 +10,4 @@ var GameRoomSchema = new Schema({
|
||||
positions: Map
|
||||
});
|
||||
|
||||
var GameRoomModel = mongoose.model('GameRoomModel', GameRoomSchema );
|
||||
var RoomModel = mongoose.model('RoomModel', RoomSchema );
|
||||
@ -1,6 +1,8 @@
|
||||
const express = require("express");
|
||||
const app = express();
|
||||
const PORT = 3000|| process.env.PORT;
|
||||
|
||||
//DATABASE CONFIG
|
||||
const mongoose = require("mongoose");
|
||||
const CONNECTION_URI = require("./credentials.js").MONGODB_URL;
|
||||
|
||||
@ -13,6 +15,13 @@ mongoose.connect(CONNECTION_URI, {
|
||||
})
|
||||
.catch(err => console.error(err));
|
||||
|
||||
//ROUTES CONFIG
|
||||
const roomRoutes = require("./routes/room");
|
||||
const playerRoutes = require("./routes/player");
|
||||
|
||||
app.use('/player', playerRoutes);
|
||||
app.use('/room', roomRoutes);
|
||||
|
||||
app.listen(PORT, ()=>{
|
||||
console.log("Server runs on port "+PORT);
|
||||
});
|
||||
@ -2,42 +2,11 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
<title>Ludo online</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -10,7 +10,7 @@ const NameInput = ()=>{
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ name: inputValue })
|
||||
};
|
||||
fetch('localhost:3000/adduser', request)
|
||||
fetch('localhost:3000/room/add', request)
|
||||
.then(response => {
|
||||
if(response.status == 200){
|
||||
//redirect
|
||||
@ -21,7 +21,7 @@ const NameInput = ()=>{
|
||||
}
|
||||
return(
|
||||
<div>
|
||||
<input placeholder = "Podaj swoje imię" type="text" onChange={handleInputChange}/>
|
||||
<input placeholder = "Enter name" type="text" onChange={handleInputChange}/>
|
||||
<input type="submit" onClick={handleButtonClick}/>
|
||||
</div>
|
||||
)
|
||||
|
||||
0
src/components/game-board-components/Dice.jsx
Normal file
0
src/components/game-board-components/Dice.jsx
Normal file
0
src/components/game-board-components/Map.jsx
Normal file
0
src/components/game-board-components/Map.jsx
Normal file
Loading…
Reference in New Issue
Block a user