fid-sh-had-week8's People
fid-sh-had-week8's Issues
Throwing an error?!
here:
you catch then immediately throw the error? Why? if this isn't dealt with elsewhere it will crash your server. You should never throw an error without catching a dealing with it elsewhere, and normally in the same file (if this error is being caught elsewhere at the moment, maybe you will refactor a different file and forget about this error and break your app).
You should pass it on to your error handler by calling next(err)
Endpoints
- Home page
GET /
- Response should render html home page
- Search function
GET /search
- Get data by search value from request
- Call
getData()
query from database folder - Response should be rendering result to search.hbs file
- Data should be manipulate inside search.hbs file
- Login function
POST /login
- Get username and password from request
- Call
getUser()
query from database - Validate if username and password already exists
- SetCookies for the user
- Response should be redirect to profile.hbs
- Add Tutorials
POST /addTutorials
-Getusername value
,language name value
,link value
from request
-Postusername
,language name
,link
by addData() query to database - signup function
POST /signup
- Get username, email and password from request
- Call
postUser()
query from database - Validate if username and password already exists, if not add user
- Response should be redirect to home.hbs
- Handle errors
- page not found if status code = 404
- server error if status code = 500
file structure and npm modules
views files
- home
- search
- signup
- errors
- partials
- header
- layouts
- main
form validation
do you have a form validation?
may that can be helpful
for URL validation check link: Joi.string().uri().trim().required()
Variable name?
I think here:
fid-sh-had-week8/src/views/search.hbs
Line 2 in e42d666
Result isn't the best name, maybe instead tutorialsArray
or something
Create Test
- write test for router
linting script doesn't work
Hi,
Just had a look and the path for your lint
script is wrong:
Line 9 in 0019475
I think you don't want to go into the server folder?
Also eslint won't work without a config file.
I suggest on a new branch quickly:
- change your lint script path
- run
eslint --init
and choose the airbnb style guide - run
npm run lint
to see lint problems - run
npm run lint-fix
and manually fix any other problems - put in a PR and get it merged ASAP
Object deconstruction on require
Here:
Not a huge fan of this to be honest, if you are going to do it, do it consistently - especially for something like parse
which could mean anything. I would just require cookie
and do cookie.parse
when you need it, it will be neater
what is this
User name: admin,
a error message validation should returns to home page not as application/json page
make the email attribute unique
make it unique once you write the tables to avoid writing query for checkuser before inserting a new user
unique will not allow using the same email again for another user!
Database Files
- db_build.sql
- db_build.js
- db_connection.js
-
queries
- getData
- postData
clear database
need to remove the insert query in db_build.sql
manual added users cant be logged in on the server bcz of hashing the pw
something getting addtutorials handler broke/ need to follow the code again
its not working as before for some reason!
Server files
creating server files with express
readme
you have a good readme
Create heroku
Search tutorials functionality
I think you need some information for the user on what they can search for. If it's HTML then mention it somewhere ❤️
I would also try to make lowercase 'html' work too.
Post tutorial comes back with server error
Create Validation
- ClientValidation
- ServerValidation
make it more responsive!
Two declarations of router
npm run dev
doesn't work as there are two declarations of router. See below:
fid-sh-had-week8/src/controllers/index.js
Line 15 in e42d666
design/styling
all hbs files
Error Handling in search.js
Here:
fid-sh-had-week8/src/controllers/search.js
Lines 8 to 10 in e42d666
You should do something more useful than console log. Maybe render 500? Not sure.
Error handling in sign up
Add Tutorials
Add Tutorials POST /addTutorials
-Get username value , language name value , link value from request
-Post username , language name , link by addData() query to database
router/index.js is quite messy in it's requires
All of this:
fid-sh-had-week8/src/controllers/index.js
Lines 1 to 15 in e42d666
Is hard to read. You should seperate out the requires into logical groups:
- npm modules
- validation files
- controller files
Password not a password field
The password field should always be hidden! Check out this line:
fid-sh-had-week8/src/views/signup.hbs
Line 8 in e42d666
Requiring `env2` twice
Here:
And here:
It's not exactly a problem, but it's a bit messy and you shouldn't need to do it - once it's been required once, everything in config.env
will be available to your entire app.
However, the difficulty is in making sure the file where it is required happens before the other files where they need the variables (especially in much bigger apps).
Common practice is to have a config.js file that does all this requiring, and to call it from server.js
where you start you server.
See this example (first file is the start.js
, what you call server.js
and the second file is the config.js
- here the dotenv
module does the same as what env2
does:
https://github.com/foundersandcoders/open-tourism-platform/blob/master/src/start.js
https://github.com/foundersandcoders/open-tourism-platform/blob/master/config.js
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.