Giter Site home page Giter Site logo

safeplaces-ct-backend's People

Contributors

adamleonsmith avatar aiyan avatar alfonsopqa avatar altoplano avatar dependabot[bot] avatar elhoudini9 avatar jvisenti avatar krishnadurai avatar marshallmccoy avatar sherifkozman avatar sublet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

safeplaces-ct-backend's Issues

Setting up the DB: Error in migrate:up

While running the npm run migrate:up

getting this below error,

(node:68645) UnhandledPromiseRejectionWarning: Error: The migration directory is corrupt, the following files are missing: 20200420011122_organizations.js, 20200420011123_users.js, 20200428174152_trails.js, 20200501174613_publications.js

Passport local authentication won't handle errors properly

Problem

In the following lines, the function done is not defined. It is called on line 23 and line 40.

When testing in development, no error occurs, so the /login endpoint still works. However, in the event that an error does occur, the middleware will not pass the error.

https://github.com/Path-Check/safeplaces-backend/blob/5fdabc658526d7727fab419f63b81034324a014a/expressjs/routes/index.js#L19-L41

Possible Solution

Change done on the two lines to next, which should be the proper, defined function to call.

Validate input parameters to APIs

The current backend does not validate if the received input is according to spec. We need to add relevant checks to the code to ensure that each API checks whether the received input is in the expected type and format.

Express JS Validator looks like a good option to validate input params.

DateTimeParseError

To reproduce run the /safe_paths endpoint in Postman, see example below.

Request:
POST /safe_paths HTTP/1.1
Host: https://api.express.safeplaces.extremesolution.com
Content-Type: application/json
Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImFkbWluIiwiaWF0IjoxNTg5MjEyNjQ3fQ.-jyAO9RQQRYBiuxgR1d77vyfWxvgP7daiQHvD50ZGIQ
Content-Type: text/plain

{
"authority_name": "PQA Testing",
"publish_date_utc": "1584924583",
"info_website": "https://www.who.int/emergencies/diseases/novel-coronavirus-2019",
"concern_points":
[
{
"time": 123,
"latitude": 51.53839304439309,
"longitude": -0.11477509793272855
},
{
"time": 456,
"latitude": 51.55987524514395,
"longitude": -0.10753902581515137
}
]
}
Response:
{
"message": {
"name": "error",
"length": 160,
"severity": "ERROR",
"code": "22007",
"file": "datetime.c",
"line": "3774",
"routine": "DateTimeParseError"
}
}

Further Unit-tests needed for all APIs

The APIs:

  • Login
  • Redacted Trails GET
  • Redacted Trails POST
  • Safe Paths GET
  • Safe Paths POST

Only have a single API test testing a positive or happy path returning status 200 with a response.

We need to write cases which test other scenarios including:

  • Negative paths
  • Error statuses
  • Edge cases

Readme doesn't cover updates to pg_hba.conf

In addition to the steps in the README, I needed to edit pg_hba.conf in the postgres (12) configuration to add a line under IPv4 local connections for my docker container, namely:

host all all 172.17.0.2/32 md5

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.