Giter Site home page Giter Site logo

ntask-api's People

Contributors

caio-ribeiro-pereira avatar lagden avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

ntask-api's Issues

this error happen when i run tests

Routes: Index
GET /
✓ returns the API status

Routes: Token
POST /token
status 200
Unhandled rejection SequelizeBaseError: null
at /home/dell/Workspace/Web/ntask-api/node_modules/sequelize/lib/instance-validator.js:74:14
at tryCatcher (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:693:18)
at Promise._fulfill (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:638:18)
at PromiseArray._resolve (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise_array.js:126:19)
at PromiseArray._promiseFulfilled (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise_array.js:144:14)
at Promise._settlePromise (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:574:26)
at Promise._settlePromise0 (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)

1) "before each" hook for "returns authenticated user token"

1 passing (2s)
1 failing

Routes: Token POST /token "before each" hook for "returns authenticated user token":
Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.

Problema com testes

Olá Caio,

Estou lendo o seu livro e estou tendo problemas com testes, mais especificamente da rota task / tasks/:id.
Não tá passando nenhum teste.

Segue um resumo:

  1. Routes: Tasks GET /tasks status 200 returns a list of tasks: Uncaught AssertionError: expected {} to have a property 'length'
  2. Routes: Tasks POST /tasks status 200 creates a new task: Uncaught AssertionError: expected undefined to deeply equal 'Run'
  3. Routes: Tasks GET /tasks/:id status 200 returns one task: Uncaught AssertionError: expected undefined to deeply equal 'Work'
  4. Routes: Tasks GET /tasks/:id status 404 throws error when task does not exist: Error: expected 404 "Not Found", got 401 "Unauthorized"

5 e 6 retorna Unauthorized tambem...

Verifiquei que o beforeEach ta rodando certinho, mas percebi que na tabela Tasks não tem o campo user_id que adicionamos ai, nem no seu repositório aqui no github. Tentei adicionar o campo mas ou não adicionei certo ou não fez efeito hehe.

Bom, fiz o upload pro github para que você possa dar uma olhada: https://github.com/esganzerla/ntask-api

Obrigado

Arrow Function

Caio,
na linha 13 meu código não estava conseguindo realizar post. Após ver um repositório teu building-apis-with-nodejs , tu colocou .then(() => done()); e fiz isto no meu e funcionou.

É necessário criar desta forma ou é alguma versão que existe essa diferença na promise .then(done()); ?

this error happen when run all the tests

Routes: Token
POST /token
status 200

**Unhandled rejection SequelizeBaseError: null**

at /home/dell/Workspace/Web/ntask-api/node_modules/sequelize/lib/instance-validator.js:74:14
at tryCatcher (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:693:18)
at Promise._fulfill (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:638:18)
at PromiseArray._resolve (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise_array.js:126:19)
at PromiseArray._promiseFulfilled (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise_array.js:144:14)
at Promise._settlePromise (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:574:26)
at Promise._settlePromise0 (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)

    1) returns authenticated user token
  status 401

Unhandled rejection SequelizeBaseError: null
at /home/dell/Workspace/Web/ntask-api/node_modules/sequelize/lib/instance-validator.js:74:14
at tryCatcher (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:693:18)
at Promise._fulfill (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:638:18)
at PromiseArray._resolve (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise_array.js:126:19)
at PromiseArray._promiseFulfilled (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise_array.js:144:14)
at Promise._settlePromise (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:574:26)
at Promise._settlePromise0 (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)

    ✓ throws error when password is incorrect

Unhandled rejection SequelizeBaseError: null
at /home/dell/Workspace/Web/ntask-api/node_modules/sequelize/lib/instance-validator.js:74:14
at tryCatcher (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:693:18)
at Promise._fulfill (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:638:18)
at PromiseArray._resolve (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise_array.js:126:19)
at PromiseArray._promiseFulfilled (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise_array.js:144:14)
at Promise._settlePromise (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:574:26)
at Promise._settlePromise0 (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)

    ✓ throws error when email not exist

Unhandled rejection SequelizeBaseError: null
at /home/dell/Workspace/Web/ntask-api/node_modules/sequelize/lib/instance-validator.js:74:14
at tryCatcher (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:693:18)
at Promise._fulfill (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:638:18)
at PromiseArray._resolve (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise_array.js:126:19)
at PromiseArray._promiseFulfilled (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise_array.js:144:14)
at Promise._settlePromise (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:574:26)
at Promise._settlePromise0 (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/home/dell/Workspace/Web/ntask-api/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)

    ✓ throws error when email and password are blank

4 passing (187ms)
1 failing

  1. Routes: Token POST /token status 200 returns authenticated user token:

    Uncaught AssertionError: expected {} to contain key 'token'

    • expected - actual

    -[]
    +[

    • "token"
      +]

    at Test. (token.js:24:41)
    at Test.assert (node_modules/supertest/lib/test.js:156:6)
    at Server.assert (node_modules/supertest/lib/test.js:127:12)
    at emitCloseNT (net.js:1577:8)
    at _combinedTickCallback (internal/process/next_tick.js:77:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)

Erro no test utilizando ntask_test.sqlite

Quando tento rodar o npm test utilizando a configuração original...

module.exports = {
  database: "ntask_test",
  username: "",
  password: "",
  params: {
    dialect: "sqlite",
    storage: "ntask_test.sqlite",
    logging: false,
    sync: {
      force: true
    },
    define: {
      underscored: true
    }
  },
  jwtSecret: "NTALK_TEST",
  jwtSession: {session: false}
};

aparece o seguinte erro: Unhandled rejection SequelizeDatabaseError: SQLITE_ERROR: no such table: Users...

Então, mudei apenas o storage para o arquivo sqlite que o app criou. Ficando assim:

...
  params: {
    dialect: "sqlite",
    storage: "ntask.sqlite",
...

Sucesso!!!
Mas a pergunta é: Por quê não funciona com o ntask_test.sqlite?

ES6 no node.js 4.x

Vi que você está usando babel-node para fazer o transpiling do es6, mas o node.js 4.x (depois da fusão com o io.js) já tem suporte ao es6 por padrão. Talvez fosse o caso de não precisar mais usá-lo. ;) (belo trabalho aqui, btw ;) )

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.