Skip to content

Commit

Permalink
Apis, styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Daelso committed Feb 9, 2024
1 parent 3d26e45 commit 4edb36f
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 2 deletions.
2 changes: 2 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ const garouRoutes = require("./server/api/garou");
app.use("/garou", garouRoutes);
const ladRoutes = require("./server/api/showlads");
app.use("/showlads", ladRoutes);
const gameFinderRoutes = require("./server/api/game_finder");
app.use("/game_finder", gameFinderRoutes);
//Uses userRoutes file to handle all user related endpoints

//Below are various controller links
Expand Down
25 changes: 25 additions & 0 deletions server/api/game_finder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const express = require("express");
const cookieParser = require("cookie-parser");
const sequelize = require("../database");
require("dotenv").config();
const app = express();

let router = express.Router();
router.use(cookieParser());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
const GameStyles = require("../models/game_finder/game_styles.js");
const lib = require("../lib");

//Route is base/game_finder/
router.route("/styles").get(lib.getLimiter, async (req, res) => {
try {
const styles = await GameStyles.findAll();

res.status(200).json(styles);
} catch (err) {
res.status(403).send(err);

Check warning

Code scanning / CodeQL

Information exposure through a stack trace Medium

This information exposed to the user depends on
stack trace information
.
}
});

module.exports = router; //Exports our routes
21 changes: 21 additions & 0 deletions server/models/game_finder/game_styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const Sequelize = require("sequelize");
const db = require("../../database");

const GameStyles = db.sequelize.define(
"game_styles",
{
style_id: {
type: Sequelize.INTEGER,
allowNull: false,
primaryKey: true,
autoIncrement: true,
},
style: {
type: Sequelize.STRING,
allowNull: false,
},
},
{ timestamps: false }
);

module.exports = GameStyles;
54 changes: 52 additions & 2 deletions src/components/game_finder/create_a_game.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@
color="secondary"
popup-content-style="background-color:#222831; color:white"
/>
<q-select
v-model="game_style"
:options="style_options"
label="How Will This Game Be Played?"
label-color="primary"
map-options
option-label="style"
option-value="style_id"
emit-value
bg-color="grey-3"
filled
style="margin-bottom: 10px"
color="secondary"
popup-content-style="background-color:#222831; color:white"
/>
<q-input
filled
type="number"
Expand All @@ -49,13 +64,14 @@
class="select"
label-color="primary"
v-model="max_players"
min="2"
max="99"
/>

<q-input
filled
type="textarea"
label="Describe your Game"
label="Describe Your Game"
bg-color="grey-3"
class="select"
label-color="primary"
Expand All @@ -68,7 +84,17 @@
class="text-primary"
style="display: flex; flex-direction: column"
>
<q-btn style="color: white" flat label="Create Game" v-close-popup />
<q-btn
style="color: white"
flat
label="Create Game"
:disable="validateCreate"
v-close-popup
>
<q-tooltip v-if="validateCreate"
>Please fill out all required fields.</q-tooltip
>
</q-btn>
<q-btn flat style="color: white" label="Cancel" v-close-popup />
</q-card-actions>
</q-card>
Expand Down Expand Up @@ -147,17 +173,41 @@ export default defineComponent({
} else {
this.baseUrl = window.location.origin;
}
const styleReq = await this.$axios.get(
this.baseUrl + "/game_finder/styles"
);
this.style_options = styleReq.data;
console.log(this.style_options);
},
data() {
return {
baseUrl: null,
game_title: "",
game_style: "",
min_players: 1,
max_players: 2,
game_line: "",
game_description: "",
style_options: [],
};
},
methods: {},
computed: {
validateCreate() {
if (
this.game_title.trim() === "" ||
this.game_style.trim() === "" ||
this.min_players === null ||
this.max_players === null ||
this.game_line === "" ||
this.game_description.trim() === ""
) {
return false;
} else {
return true;
}
},
},
});
</script>

0 comments on commit 4edb36f

Please sign in to comment.