Skip to content
62 changes: 62 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
module.exports = {
"env": {
"es6": true,
"node": true,
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"array-bracket-spacing": ["error", "never"],
"array-element-newline": ["error", "consistent"],
"arrow-spacing": ["error", { "before": true, "after": true }],
"block-spacing": "error",
"camelcase": 0,
"comma-spacing": ["error", { "before": false, "after": true }],
"computed-property-spacing": ["error", "never"],
"dot-location": ["error", "property"],
"eol-last": ["error", "always"],
"func-call-spacing": ["error", "never"],
"function-paren-newline": ["error", "never"],
"implicit-arrow-linebreak": ["error", "beside"],
"indent": ["error", 2, { "SwitchCase": 1 }],
"key-spacing": ["error", { "afterColon": true }],
"keyword-spacing": ["error", { "before": true, "after": true }],
"linebreak-style": ["error", "unix"],
"max-len": ["error", { "code": 120, "ignoreComments": true, "ignoreTrailingComments": true }],
"no-console": "error",
"no-case-declarations": 0,
"no-mixed-spaces-and-tabs": "error",
"no-multi-spaces": "error",
"no-spaced-func": "error",
"no-trailing-spaces": ["error", { "ignoreComments": true }],
"no-whitespace-before-property": "error",
"nonblock-statement-body-position": ["error", "beside"],
"object-curly-newline": ["error", { "multiline": true, "minProperties": 5, "consistent": true }],
"object-curly-spacing": ["error", "always", { "arraysInObjects": true, "objectsInObjects": true }],
"object-property-newline": ["error", { "allowAllPropertiesOnSameLine": true }],
"one-var": ["error", "never"],
"operator-linebreak": ["error", "after", { "overrides": { "?": "before", ":": "before" } }],
"padded-blocks": ["error", "never"],
"padding-line-between-statements": [
"error",
{ blankLine: "always", prev: "*", next: "return" },
{ blankLine: "always", prev: ["const", "let", "var"], next: "*" },
{ blankLine: "any", prev: ["const", "let", "var"], next: ["const", "let", "var"] },
],
"quotes": ["error", "single"],
"rest-spread-spacing": ["error", "never"],
"space-before-blocks": "error",
"space-before-function-paren": ["error", { "anonymous": "always", "named": "never", "asyncArrow": "always" }],
"space-in-parens": ["error", "never"],
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": ["error", "always"],
"semi": ["error", "never"],
"semi-spacing": ["error", { "before": false, "after": true }],
"switch-colon-spacing": "error",
"template-tag-spacing": ["error", "always"],
}
};
24 changes: 24 additions & 0 deletions .pug-lintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
disallowAttributeConcatenation: true,
disallowBlockExpansion: true,
disallowClassLiterals: true,
disallowDuplicateAttributes: true,
disallowHtmlText: true,
disallowIdLiterals: true,
disallowLegacyMixinCall: true,
disallowMultipleLineBreaks: true,
disallowSpacesInsideAttributeBrackets: true,
disallowStringConcatenation: 'aggressive',
disallowTagInterpolation: true,
disallowTrailingSpaces: true,
requireLineFeedAtFileEnd: true,
requireLowerCaseAttributes: true,
requireLowerCaseTags: true,
requireSpaceAfterCodeOperator: true,
requireStrictEqualityOperators: true,
validateAttributeQuoteMarks: '"',
validateExtensions: true,
validateIndentation: 2,
validateLineBreaks: 'LF',
validateTemplateString: true
}
18 changes: 18 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const express = require('express')

const app = express()

app.set('view engine', 'pug')
app.use(express.static('public'))

app.get('/', (request, response) => {
return response.status(200).render('index')
})

app.all('*', (request, response) => {
return response.status(404).send('Looks like you found nothing in the pokedex.')
})

app.listen(1337, () => {
console.log('Listening on 1337...')// eslint-disable-line no-console
})
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"main": ".eslintrc.js",
"scripts": {
"dev": "./node_modules/.bin/nodemon index.js",
"lint": "run lint:pug-lint && run lint:eslint",
"lint": "run lint:puglint && run lint:eslint",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"lint": "npm run lint:puglint && npm run lint:eslint", Someone didn't use this command :trollface:

"lint:eslint": "./node_modules/.bin/eslint --format codeframe .",
"lint:puglint": "./node_modules/.bin/pug-lint ."
"lint:pug": "./node_modules/.bin/pug-lint ."
},
"repository": {
"type": "git",
Expand All @@ -26,7 +26,6 @@
},
"dependencies": {
"express": "^4.17.1",
"pug": "^2.0.4",
"s": "^1.0.0"
"pug": "^2.0.4"
}
}
83 changes: 83 additions & 0 deletions public/css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
body{
margin-top: 150px;
}

h2{
text-align: center;
}

h3{
margin-bottom: 5px;
}

.delete{
color: crimson;
font-weight: bold;
}

.delete, .get, .post{
padding-right: 10px;
}

.get{
color: green;
font-weight: bold;
}

.hidden{
display: none;
}

.highlighted{
background-color: lightgray;
position: relative;
width: 320px;
}

.highlighted:after {
bottom: 0;
border-bottom: 15px solid transparent;
border-left: 15px solid lightgray;
border-top: 15px solid transparent;
content: "";
position: absolute;
right: -15px;
width: 0;
}

.left-container{
margin: 0px 30px;
width: 320px;
}

.main-container{
display: flex;
flex-direction: row;
justify-content: center;
}

.post{
color: darkorange;
font-weight: bold;
}

.right-container{
margin: 0px 20px;
position: relative;
width: 440px;
}

.spacing{
margin: 20px 0px;
padding-left: 20px;
}

.tabs{
cursor: pointer;
font-size: 20px;
letter-spacing: 1px;
margin: 30px 0;
padding-top: 4px;
padding-left: 5px;
padding-bottom: 3px;
}
18 changes: 18 additions & 0 deletions public/javascripts/indexPugInteraction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* eslint-disable no-undef */
// eslint-disable-next-line no-unused-vars
const updateSelected = (id) => {
const tabs = document.getElementsByClassName('tabs')
const methods = document.getElementsByClassName('method')

for (let i = 0; i < tabs.length; i++) {
tabs[i].id === id
? tabs[i].classList.add('highlighted')
: tabs[i].classList.remove('highlighted')
}

for (let i = 0; i < methods.length; i++) {
methods[i].id === id
? methods[i].classList.remove('hidden')
: methods[i].classList.add('hidden')
}
}
13 changes: 13 additions & 0 deletions views/index.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
html
head
title Pokemon API
link(rel="stylesheet" href="/css/styles.css")
script(src="/javascripts/indexPugInteraction.js")

body
h2 Welcome to the Pokemon API
div(class="main-container")

include partials/leftSideDocumentation.pug

include partials/rightSideDocumentaion.pug
19 changes: 19 additions & 0 deletions views/partials/leftSideDocumentation.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
div(class="left-container")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This design looks familiar 😂

div(class="tabs highlighted" id="getAll" onclick="updateSelected('getAll')")
span(class="get") GET
span /pokemon
div(class="tabs" id="getGeneration" onclick="updateSelected('getGeneration')")
span(class="get") GET
span /generation/{genId}

div(class="tabs" id="getPokemonById" onclick="updateSelected('getPokemonById')")
span(class="get") GET
span /pokemon/{pokemonId}

div(class="tabs" id="postPokemon" onclick="updateSelected('postPokemon')")
span(class="post") POST
span /pokemon

div(class="tabs" id="deletePokemonById" onclick="updateSelected('deletePokemonById')")
span(class="delete") DELETE
span /pokemon/{pokemonId}
52 changes: 52 additions & 0 deletions views/partials/rightSideDocumentaion.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
div(class="right-container")
div(class="method" id="getAll")
h3 Method
div(class="get spacing") GET
h3 Route
div(class="spacing") http://localhost:1337/pokemon
h3 Headers
div(class="spacing") None needed
h3 Decription
div(class="spacing") Returns a list all of the pokemon in the databse.

div(class="method hidden" id="getGeneration")
h3 Method
div(class="spacing get") GET
h3 Route
div(class="spacing") http://localhost:1337/pokemon/generations/{genId}
h3 Headers
div(class="spacing") None needed
h3 Decription
div(class="spacing") Returns the generation list of all pokemon associated with {genId}.

div(class="method hidden" id="getPokemonById")
h3 Method
div(class="spacing get") GET
h3 Route
div(class="spacing") http://localhost:1337/pokemon/pokemon/{pokemonId}
h3 Headers
div(class="spacing") None needed
h3 Decription
div(class="spacing") Returns the pokemon associated with the {id} (Id's are also the pokemon's pokedex number).

div(class="method hidden" id="postPokemon")
h3 Method
div(class="spacing post") POST
h3 Route
div(class="spacing") http://localhost:1337/pokemon
h3 Headers
div(class="spacing") Content-Type: application/json
h3 Body
div(class="spacing") { "gen": "1", "name": "Bulbasaur", "Types": "['grass', 'poison']" }
h3 Decription
div(class="spacing") Returns a list all of the pokemon in the databse.

div(class="method hidden" id="deletePokemonById")
h3 Method
div(class="spacing delete") DELETE
h3 Route
div(class="spacing") http://localhost:1337/pokemon/pokemon/{pokemonId}
h3 Headers
div(class="spacing") None needed
h3 Decription
div(class="spacing") Deletes the pokemon associated with the {id} (Id's are also the pokemon's pokedex number).