Code Monkey home page Code Monkey logo

emq-rest-api's People

Contributors

brylie avatar frenchbread avatar

Watchers

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

emq-rest-api's Issues

Unable authenticate with created username/password

Unable to authenticate with username: admin; password: test12345 - 403 response code.

Running Sails app via:

sails_permissions__adminUsername='admin' sails_permissions__adminPassword='test12345' sails lift --models.migrate='alter' --port=1339

Check that item was created:

screen shot 2017-02-23 at 17 48 05

If creating different admin user, e.g. admin1, following error pops up:

info: sails-permissions: admin user does not exist; creating...
debug: Error (E_VALIDATION) :: 1 attribute is invalid
error: duplicate key value violates unique constraint "user_email_key"
    at Connection.parseE (/home/damir/apps/emq-rest-api/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:539:11)
    at Connection.parseMessage (/home/damir/apps/emq-rest-api/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:366:17)
    at Socket.<anonymous> (/home/damir/apps/emq-rest-api/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:105:22)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at TCP.onread (net.js:551:20)

Invalid attributes sent to undefined:
 • email
   • A record with that `email` already exists (`[email protected]`).

error: { [Error]
  originalError:
   Error (E_VALIDATION) :: 1 attribute is invalid
   error: duplicate key value violates unique constraint "user_email_key"
       at Connection.parseE (/home/damir/apps/emq-rest-api/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:539:11)
       at Connection.parseMessage (/home/damir/apps/emq-rest-api/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:366:17)
       at Socket.<anonymous> (/home/damir/apps/emq-rest-api/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:105:22)
       at emitOne (events.js:96:13)
       at Socket.emit (events.js:188:7)
       at readableAddChunk (_stream_readable.js:176:18)
       at Socket.Readable.push (_stream_readable.js:134:10)
       at TCP.onread (net.js:551:20)

   Invalid attributes sent to undefined:
    • email
      • A record with that `email` already exists (`[email protected]`).
   ,
  reason: 'NaN attributes are invalid',
  code: 'E_VALIDATION',
  status: 400,
  invalidAttributes: { email: [ [Object] ] } }

Test and document REST API design

Definition of done

  • Test current REST API to make sure
    • users can be created
    • it is possible to create ACL rules for the users
  • API endpoints have documentation either in readme or as a Swagger document

Add unit tests

Quoting Micheal C Feathers in his book

To me, legacy code is simply code without tests. I’ve gotten some grief for this definition. What do tests have to do with whether code is bad? To me, the answer is straightforward, and it is a point that I elaborate throughout the book:

Code without tests is bad code. It doesn’t matter how well written it is; it doesn’t mat-
ter how pretty or object-oriented or well-encapsulated it is. With tests, we can change
the behavior of our code quickly and verifiably. Without them, we really don’t know
if our code is getting better or worse

We need at least some unit testing coverage in this repository.

There are a few examples on how to write unit tests for a sails application.

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.