Git Product home page Git Product logo

baraka-v2's People

Contributors

amoodaa avatar fadeomar avatar maiubeid avatar mohqarmout avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

maiubeid

baraka-v2's Issues

Select after insert

dbBuild()
.then(() => user.insert({ username: 'kalb', password: 1, email: '[email protected]' }))
.then(() => user.selectAll())
.then(res => res.rows)

You don't need to make a select query after the insert.
the insert query already gives you the ability to return what you insert.
you just need to add the ( RETURNING * ) word at the end of the SQL query.

So Clean!

It felt so good reading your code! Other than the few minor issues I pointed out, everything was so nice and clean! Keep it up :D

Validation

  • client side validation using html5 required attribute
  • server side using @hapi/joi:
    • username: has to be string, and unique(done with assist of db, not associated with joi)
    • password: string, min 8 characters long, max 30 or whatever
    • confirmPassword
    • email: string email, 2 mail segments

Eslint

Baraka-V2/package.json

Lines 23 to 28 in e286244

"eslint": "^6.1.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-prettier": "^6.1.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-prettier": "^3.1.0",

you install more than eslint configurations, you should use just one.

insert queries

write tests that insert before! Hint: use the commented tests
insert queries and get all into the following tables:

  • baraka_user
  • baraka_list
  • baraka_item

hashing passwords

make a function for hashing passwords with salt using bcrypt module not bcryptjs

Fake data

const expected = [
{ id: 1, username: 'mohammed', password: 'password1', email: '[email protected]' },
{ id: 2, username: 'fadi', password: '1', email: '[email protected]' },
{ id: 3, username: 'mai', password: '1', email: '[email protected]' },
{ id: 4, username: 'amooda', password: '1', email: '[email protected]' }
];
dbBuild()
.then(() => user.selectAll())
.then(res => res.rows)
.then(res => {
t.deepEqual(res, expected, 'the table of user should contain four user');
t.deepEqual(
Object.keys(res[0]),
['id', 'username', 'password', 'email'],
' the keys of first user object should return id and name'
);
t.equal(res[0].id, 1, 'the first id in the user is 1');

The test for the keys in the query result is enough to make sure the query is running correctly, you don't need to test the value of keys

Test script

"test": "NODE_ENV=test node test/logic.test.js | tap-spec && NODE_ENV=test node test/routes.test.js | tap-spec && NODE_ENV=test node test/db.test.js | tap-spec && NODE_ENV=test node test/validate.test.js | tap-spec",

import all of your test files in one file and then run this file in the script.

More Validation Required

For some reason inserting a white space passes the form submission when filling up a new post. Make sure to fix it before your presentation :)

Promis

);
t.equal(res[0].id, 1, 'the first id in the user is 1');
t.equal(res[1].username, 'fadi', 'the last name in the user is Fadi');
})
.then(t.end)
.catch(t.error);

Just add the t.end after the t.equal, you don't need to add new .then()

 );
      t.equal(res[0].id, 1, 'the first id in the user is 1');
      t.equal(res[1].username, 'fadi', 'the last name in the user is Fadi');
      t.end();
    })
    .catch(t.error);

Validation follow up

feedback the user about what he did not satisfy the requirements in
and test the validate function

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.