Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
Binary file added Public/aquarius.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Public/aries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Public/cancer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Public/capricorn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Public/gemini.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Public/leo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Public/libra.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Public/pisces.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Public/sagittarius.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Public/scorpio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Public/taurus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Public/virgo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
23 changes: 23 additions & 0 deletions controllers/air.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const express = require("express")
const router = express.Router()

const air = {
type: "air",
signs: ["Aquarius", "Gemini", "Libra"],
traits: ["movement", "creativity", "action", "adventure", "exciting", "easily provoked"]
}

// main air route
// http GET url localhost:8000/air
router.get("/", (req, res) => {
res.render("show", {element: air})
})

// air sign route
// http GET url localhost:8000/air/:sign
router.get("/:sign", (req, res) => {
// res.send(req.params.sign)
res.render("sign", {sign: req.params.sign})
})

module.exports = router
23 changes: 23 additions & 0 deletions controllers/earth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const express = require("express")
const router = express.Router()

const earth = {
type: "earth",
signs: ["Taurus", "Virgo", "Capricorn"],
traits: ["grounded", "helpful", "practical", "realistic", "materialistic", "dependable"]
}

// main air route
// http GET url localhost:8000/air
router.get("/", (req, res) => {
res.render("show", {element: earth})
})

// air sign route
// http GET url localhost:8000/air/:sign
router.get("/:sign", (req, res) => {
// res.send(req.params.sign)
res.render("sign", {sign: req.params.sign})
})

module.exports = router
23 changes: 23 additions & 0 deletions controllers/fire.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const express = require("express")
const router = express.Router()

const fire = {
type: "fire",
signs: ["Aries", "Leo", "Sagittarius"],
traits: ["passionate", "strong emotions", "tempermental", "energetic", "accomplished", "interesting"]
}

// main air route
// http GET url localhost:8000/air
router.get("/", (req, res) => {
res.render("show", {element: fire})
})

// air sign route
// http GET url localhost:8000/air/:sign
router.get("/:sign", (req, res) => {
// res.send(req.params.sign)
res.render("sign", {sign: req.params.sign})
})

module.exports = router
23 changes: 23 additions & 0 deletions controllers/water.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const express = require("express")
const router = express.Router()

const water = {
type: "water",
signs: ["Pisces", "Cancer", "Scorpio"],
traits: ["private", "mysterious", "pyshic", "charming", "emotional", "sensitive"]
}

// main air route
// http GET url localhost:8000/air
router.get("/", (req, res) => {
res.render("show", {element: water})
})

// air sign route
// http GET url localhost:8000/air/:sign
router.get("/:sign", (req, res) => {
// res.send(req.params.sign)
res.render("sign", {sign: req.params.sign})
})

module.exports = router
50 changes: 50 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const express = require("express")
const app = express()

const PORT = 8000

// graphic represented as an object
const elements = {
air: {
type: "air",
signs: ["Aquarius", "Gemini", "Libra"],
traits: ["movement", "creativity", "action", "adventure", "exciting", "easily provoked"]
},
water: {
type: "water",
signs: ["Pisces", "Cancer", "Scorpio"],
traits: ["private", "mysterious", "pyshic", "charming", "emotional", "sensitive"]
},
fire: {
type: "fire",
signs: ["Aries", "Leo", "Sagittarius"],
traits: ["passionate", "strong emotions", "tempermental", "energetic", "accomplished", "interesting"]
},
earth: {
type: "earth",
signs: ["Taurus", "Virgo", "Capricorn"],
traits: ["grounded", "helpful", "practical", "realistic", "materialistic", "dependable"]
}
}

// set the view engine
app.set("view engine", "ejs")
app.use(express.static("public"))

// CONTROLLERS
app.use("/air", require("./controllers/air"))
app.use("/water", require("./controllers/water"))
app.use("/earth", require("./controllers/earth"))
app.use("/fire", require("./controllers/fire"))

// ROUTES
// http GET url localhost:8000/
// home route
app.get("/", (req, res) => {
res.render("index")
})


app.listen(PORT, () => {
console.log(`smooth smooth sounds of javascript coming from port ${PORT}`)
})
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "zodiac-controllers",
"version": "1.0.0",
"description": "![image showing signs' traits and categories](./zodiac.jpeg)",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
19 changes: 19 additions & 0 deletions views/index.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Zodiac Controllers</h1>
<p>Let's learn about the signs!</p>
<ul>
<li><a href="/air">air</a></li>
<li><a href="/water">water</a></li>
<li><a href="/earth">earth</a></li>
<li><a href="/fire">fire</a></li>
</ul>
</body>
</html>
24 changes: 24 additions & 0 deletions views/show.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1><%= element.type %></h1>
<a href="/">Home</a>
<ul>
<% element.signs.forEach((sign) => { %>
<li><a href="/<%= element.type %>/<%= sign %>"><%= sign %></a></li>
<% }) %>
</ul>
<ul>
<% element.traits.forEach((trait) => { %>
<li><%= trait %></li>
<% }) %>
</ul>

</body>
</html>
13 changes: 13 additions & 0 deletions views/sign.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<a href="/">Home</a>
<img src="/<%= sign %>.png">
</body>
</html>