Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #5

Open
wants to merge 53 commits into
base: feedback
Choose a base branch
from
Open

Feedback #5

wants to merge 53 commits into from

Conversation

cwesterduin
Copy link
Collaborator

No description provided.

@yourlocaldeveloper yourlocaldeveloper self-requested a review March 31, 2021 12:55
Comment on lines +15 to +18
- Access: client on localhost:8080/ and server on localhost:3000/
- Run `docker-compose down` to stop the services and keep data
- Run `docker-compose --volumes --remove-orphans` to stop the services and remove all artifacts
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a massive thing but would of been nice to use the scripts similar to those found in the assessment for ease of access

## Bugs

- Should display an error if no post is found from the url
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good README with plenty of detail, nice work :)

// trying to get all posts so that I can find out the id of each post
async function index(req, res) {
try {
const posts = await Post.all;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was wondering if it is necessary to make an all function given its not used in your website?

}
}

module.exports = { index, show, create };
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice clean and concise controller file 💯

Comment on lines +1 to +12
const { MongoClient } = require("mongodb");
const connectionUrl = process.env.DB_CONNECTION;

const dbName = process.env.DB_NAME;

const init = async () => {
let client = await MongoClient.connect(connectionUrl);
console.log("connected to database!", dbName);
return client.db(dbName);
};

module.exports = { init };
Copy link
Collaborator

Choose a reason for hiding this comment

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

Like the idea of using Mongo over PostgreSQL, DB config seems all in order! 👍

Comment on lines +14 to +28
static get all() {
return new Promise(async (resolve, reject) => {
try {
const db = await init();
const postsData = await db.collection("posts").find().toArray();
const posts = postsData.map(
(p) => new Post({ ...p, id: p._id })
);
resolve(posts);
} catch (err) {
console.log(err);
reject("Cannot retrieve all posts");
}
});
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good function but we don't think it gets used so is it necessary to keep in?

}
}

module.exports = Post;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great model file, looks great and good use of spread operator for inserting data. Looks great, just one console.log that could be removed on line 49 👍

Comment on lines +1 to +17
<!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">
<meta name="description" content="anonymous blogging application for ninjas!">
<title>Anoninja</title>
<link rel="stylesheet" href="static/css/index.css">
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🐱‍👤</text></svg>">
</head>
<body>
<h1><a href="/">Anoninja</a></h1>
<div id="root"></div>
</body>
<script defer src="bundle.js"></script>
</html>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice simple HTML file, and like how you remembered to add the favicon 😄

Comment on lines +1 to +90
@import url('https://fonts.googleapis.com/css2?family=Rock+Salt&display=swap');

* {
box-sizing: border-box;
}

body {
font-family: 'Raleway', sans-serif;
background: rgb(34, 33, 31);
color: rgb(248, 244, 234);
margin: 0;
padding: 0;
}

h1, h1 > a {
font-family: 'Rock Salt', cursive;
color: rgb(235, 43, 43);
text-align: center;
text-decoration: none;
}

form {
display: flex;
flex-direction: column;
width: 100%;
justify-content: space-between;
align-items: center;
text-align: center;
}

input:not(input[type="submit"]), textarea {
background: transparent;
min-height: 45px;
outline: none;
border: none;
color: rgb(248, 244, 234);
font-size: 1.2rem;
width: 50%;
min-width: 300px;
font-family: 'Raleway', sans-serif;
margin-top: .25rem;
margin-bottom: 1rem;
}
input:first-of-type {
margin-top: 0 !important;
margin-bottom: 0 !important;
}
textarea {
min-height: 100px;
resize: vertical;
}
input[type="submit"] {
border: solid 1px rgb(221, 213, 213);
color: rgb(248, 244, 234);
cursor: pointer;
border-radius: 4px;
background: transparent;
padding: .5rem 2rem;
font-size: 1.2rem;
}
input[type="submit"]:hover {
background: #333;
}

#title {font-size: 2rem}
#name {
font-family: 'Rock Salt', cursive;
color: rgb(235, 43, 43);
}
.post-cont{
width: 50%;
min-width: 300px;
margin: 0 auto;
font-size: 1.2rem;
}
.post#name {
margin: -2rem 0 0 2rem;
display: inline-block;
}
.post-cont{
width: 50%;
min-width: 300px;
margin: 0 auto;
font-size: 1.2rem;
}
.post-cont span {
font-size: 1rem;
color: rgb(221, 213, 213)
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good styling given you weren't using a framework, good job looks great 💯


const response = await fetch('http://localhost:3000/posts', options);
const data = await response.json();
window.location.hash = `#${data}`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Really picky here but you don't need the hashtag where you set the hash as it adds it in for you


module.exports = {
sendPost, getPost
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

In general nice concise and well written async functions 😄

@@ -0,0 +1,61 @@
const { sendPost, getPost } = require('./api.js')
const { encode } = require('html-entities');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Really cool idea of thinking of decoding / encoding icons, emojis, nice work!

const root = document.getElementById('root')
root.innerHTML = ''
const id = window.location.hash.substring(1)
id.length > 0 ? renderPost(id) : renderForm()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good use of a conditional operator, so much more cleaner than an if statement 😄

Comment on lines +19 to +23
<div class="post-cont">
<h2>${encode(postData.title)}</h2>
<h3 class="post" id="name">${encode(postData.pseudonym)}</h3><span> ● ${prettyDate(postData.date)}</span>
<p>${encode(postData.content)}<p>
</div>`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again great use of this encode function!

Comment on lines +26 to +32
function prettyDate(date) {
const jsDate = new Date(Date.parse(date))
const day = jsDate.getDate()
const month = jsDate.getMonth() + 1
const year = jsDate.getFullYear()
return `${day}-${month}-${year}`
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice that you made your own function to do this, good separation of code so it can be re-used!

Comment on lines +40 to +56
const fields = [
{ tag: 'input', attributes: {autocomplete : "off", id: "title", required: "true", type: 'text', name: 'title', placeholder: 'Title' } },
{ tag: 'input', attributes: {autocomplete : "off", id: "name", type: 'text', name: 'pseudonym', placeholder: 'Ninja name...' } },
{ tag: 'textarea', attributes: { name: 'content', required: "true", placeholder: 'Ninja post...' } },
{ tag: 'input', attributes: { type: 'submit', value: 'submit' } }
]
const root = document.getElementById('root')
const form = document.createElement('form');
fields.forEach(f => {
const field = document.createElement(f.tag);
field.textContent = f.text;
Object.entries(f.attributes).forEach(([a, v]) => field.setAttribute(a, v))
form.appendChild(field);
})
form.onsubmit = sendPost;
root.appendChild(form);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good creation of the form using a forEach, much nicer and makes life so much easier when you want to add more inputs. Great job 😄




})
Copy link
Collaborator

Choose a reason for hiding this comment

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

No mention on how to run the tests? Look good so far though 👍

Comment on lines +1 to +18
const db = connect("mongodb://localhost:27017/anoninjaDB");

db.posts.drop();

db.posts.insertMany([
{
title: "Ninjas",
pseudonym: "Ninja",
content: "Ninjas are better than Pirates",
date: new Date(),
},
{
title: "Pirates",
pseudonym: "Pirate",
content: "Pirates are better than ninjas",
date: new Date(),
},
]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seeding looks good and works as it should, is cool to think your storing the Date() type, as opposed to a string, so you can manipulate it later 👍

Comment on lines +1 to +43
version: "3"
services:
client:
container_name: dev_client
build: ./client
image: node:12.18.4
ports:
- 8080:8080
working_dir: /code
volumes:
- type: bind
source: ./client
target: /code
command: bash -c "npm install && npm run dev"

server:
image: node:12.18.4
working_dir: /code
ports:
- 3000:3000
environment:
- DB_NAME=anoninjaDB
- DB_CONNECTION=mongodb://anoninjaTeam:password@db:27017
depends_on:
- db
volumes:
- type: bind
source: ./api
target: /code
command: bash -c "npm install && npm run dev"

db:
image: mongo:latest
volumes:
- "dbdata:/var/lib/mongodb/data"
- "./db/seeds.js:/docker-entrypoint-initdb.d/seeds.js:ro"

environment:
- MONGO_INITDB_ROOT_USERNAME=anoninjaTeam
- MONGO_INITDB_DATABASE=anoninjaDB
- MONGO_INITDB_ROOT_PASSWORD=password
volumes:
dbdata:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Docker file worked first time, no issues!

Copy link
Collaborator

@yourlocaldeveloper yourlocaldeveloper left a comment

Choose a reason for hiding this comment

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

Great app guys, love the design and idea behind it. Perfect code just a few things (when being picky) that we pointed out. Checkout out all our comments and let us know if you have any questions or you want us to come and clarify anything 👍 Great work again 😄

Copy link
Collaborator

@JamesWheadon JamesWheadon left a comment

Choose a reason for hiding this comment

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

Really nice design, well formatted code and all the functionality works which is always nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants