Coder Social home page Coder Social logo

task-app's People

Contributors

canyener avatar dependabot-preview[bot] avatar dependabot[bot] avatar hasankemaldemirci avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

task-app's Issues

Additional test cases for POST /tasks

Should NOT save empty object to database
Should NOT save task with empty description to database
Should ignore invalid fields in request
Should NOT save task with invalid completed property to database

INDEX.JS

  • Create index.js
  • Seperate app and export to use inside index.js
  • Modify scripts

Develop POST /users endpoint

  • Write all test cases for POST /users endpoint using test-first approach.
  • Use user model as a reference for test cases
  • Design user router and POST /users endpoint around these approaches and test cases.
  • HAVE FUN! <3

Create web server

  • Create web server with expressjs
  • Set port to 3000
  • Create POST /tasks endpoint

math.js tests

  • Modify package.json -> test script

  • Add playground folder

  • Provide describe blocks
    -Write test cases for scenarios below;
    -Should calculate total when tip provided
    -Should calculate total with .25 tip if tip not provided
    -Should convert 32 F to 0 C
    -Should convert 0 C to 32 F

  • Run tests in watch mode

Implement POST /users/login endpoint

Edit user model

  • Add tokens property to user document

Add findByCredentials function

  • Find user by given credentials
  • Don't forget to compare plain text password with hashed one

Add generateAuthToken function

  • Generate an authentication token for user by using jsonwebtoken
  • Add only user id to jwt payload
  • Add a secret for jwt to env files and use it to generate token
  • Add newly generated token to user's existing tokens
  • Return token
  • Generate auth token in POST /users endpoint as well

Add test cases

  • Add test cases
  • Tweak existing test cases if necessary

Write test requested below for POST /tasks endpoint

  • Should return 201 with valid request
  • Should set completed to false in database if not sent in request
  • Should return correct object in response
  • Should return validation error message with empty description

Fix POST /users response

  • Return only id, name, email and age in response.
  • Add, remove or modify test cases if necessary
  • And as always, Have Fun! <3

Implement CI

  • Implement Circle CI
  • Also check Github Actions feature!!

Error handling maybe?

I just realized we're repeating same try-catch logic in all our endpoints.

Could be great if we can build a simple express error handler.

POST /tasks endpoint

Save task to database

  • return 201, task object in response
  • return 400, error object in response

Create user model

name: required
email: required, unique, lowercase, validate with validator library "Email is invalid"
password: min length 7, required, validate: "can not contain the word "password"'
age: validate: "must be a positive number"

Encrypt user password

  • Encrypt user password before saving
  • Fix, add or remove test cases if necessary.
  • Add "Should save age as null to database with empty string" test case
  • And as always, HAVE FUN! ๐Ÿ”ฅ

Use bcryptjs library for hashing. Link to the library is below;

https://www.npmjs.com/package/bcryptjs

Fix HTTP Status Codes in Task Router

When we send a request to task router endpoints but no matching task is not found, we always return 404 (Not Found) status code.

I suggest that we should change that to 204 (No Content) since our request is perfectly valid - no client error- but no data matches our criteria.

It will certainly affect some of our test cases, so they will need to be fixed as well if you agree with my suggestion of course. ๐Ÿ˜ธ

Write tests for add function

Test cases to write;

  • Should return error message with negative numbers
  • Should return error message with negative numbers async/await
  • Should add two numbers
  • Should add two numbers async/await

add function

  return new Promise((resolve, reject) => {
      setTimeout(() => {
          if(a < 0 || b < 0) {
              return reject('Numbers must be non-negative')
          }
          resolve(a + b)
      }, 500);
  })
  .catch(e => e)
}```

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.