Giter VIP home page Giter VIP logo

fid-sh-had-week8's People

Contributors

fidaahersh avatar hadeel-salamin avatar m4v15 avatar shahenazmonia avatar shaima96 avatar

Watchers

 avatar  avatar

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
    -Get username value , language name value , link value from request
    -Post username , 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

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()

linting script doesn't work

Hi,

Just had a look and the path for your lint script is wrong:

"lint": "./node_modules/.bin/eslint ./src/server/**/*.js",

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:

  1. change your lint script path
  2. run eslint --init and choose the airbnb style guide
  3. run npm run lint to see lint problems
  4. runnpm run lint-fix and manually fix any other problems
  5. put in a PR and get it merged ASAP

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

readme

you have a good readme

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

I'm unable to add new tutorials at the mo. This may be due to the way you're parsing your body, there's this line missing in your app.js: app.use(express.json()) (which works the same as 'bodyParser'). Also see @m4v15's issue #41.

screenshot 2018-12-20 at 08 58 18

Error handling in sign up

It's awesome you have error handling here but the json error coming back may scare users.

screenshot 2018-12-20 at 08 56 39

Adding a error message could be done the same way as this:

screenshot 2018-12-20 at 08 57 34

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:

const express = require('express');
const search = require('./search');
const home = require('./home');
const error=require('./error');
const signup = require('./signup');
const login = require('./login');
const validate = require('../validation/validate.js');
const { signupValidation} = require('../validation/server-side');
const router = express.Router();
const addTutorials = require('./addtutorials');
const logout = require('./logout');
const router = express.Router();

Is hard to read. You should seperate out the requires into logical groups:

  • npm modules
  • validation files
  • controller files

Requiring `env2` twice

Here:

require('env2')('./config.env');

And here:
require('env2')('./config.env');

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.