Skip to content

Backend - Users && more stuff - #64

Merged
alanhoff merged 15 commits into
nodebr:backendfrom
brunops:backend
Nov 15, 2016
Merged

Backend - Users && more stuff#64
alanhoff merged 15 commits into
nodebr:backendfrom
brunops:backend

Conversation

@brunops

@brunops brunops commented Nov 15, 2016

Copy link
Copy Markdown
  • Load environment variables from .env with dotenv module
  • Add steps necessary to run the app to the README
  • add morgan to print request logs
  • Add users resource
    • This follows hello-world structure
    • there are no 'use strict' thingies because es6 modules are strict by default :P
    • email is not in the specification but probably very important (?)
    • password is currently saved raw, missing bcrypt stuff

bsanches added 6 commits November 14, 2016 22:39
- This follows `hello-world` structure
- there are no `'use strict'` thingies because commonjs is strict by default :P
- `email` is not in the specification but probably very important (?)
- `password` is currently saved raw, missing bcrypt stuff
@brunops

brunops commented Nov 15, 2016

Copy link
Copy Markdown
Author

Os testes não estão rodando por algum motivo, Parece ser relacionado com como aquela .truncate() query está sendo montada. Não consegui descobrir o erro, mas é isso aqui:

screen shot 2016-11-14 at 11 45 11 pm

@thebergamo

Copy link
Copy Markdown
Member

@brunops vou dar uma olhada nisso e dar merge!

Comment thread README.md Outdated
2. Rode as migrations

```sh
$ npm run knex migrate:latest

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O lugar disto seria na documentação da wiki https://github.com/nodebr/nodebr/wiki/Backend

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depois coloco lá então 👍

Comment thread index.js Outdated
@@ -1,5 +1,7 @@
'use strict'

require('dotenv').config()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Não utilizar o dotenv, os desenvolvedores podem fazer o source do .env caso seja necessário

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aurait

Comment thread lib/db/knexfile.js Outdated

const path = require('path')

require('dotenv').config({ path: path.resolve(__dirname, '../../.env') })

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Não utilizar o dotenv, os desenvolvedores podem fazer o source do .env caso seja necessário


exports.up = knex => {
// Apenas roda esta migration se estivermos em um ambiente de desenvolvimento
if (process.env.NODE_ENV !== 'production') {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Não precisa deste if aqui, ele estava presente somente na migration do hello-world pois não queremos ela rodando em produção

}

exports.down = knex => {
if (process.env.NODE_ENV !== 'production') {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Não precisa do if

Comment thread resources/users/handlers.js Outdated
const db = require('../../lib/db')
const User = db.model('User')

exports.findAll = (req, res) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remover esta rota e handler

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do

Comment thread resources/users/routes.js Outdated

const router = express.Router()

router.get('/users', handlers.findAll)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remover esta rota e handler

Comment thread resources/users/routes.js Outdated
const router = express.Router()

router.get('/users', handlers.findAll)
router.get('/users/:id', handlers.findOne)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remover esta rota e handler

Comment thread resources/users/schemas.js Outdated

exports.create = exports.model.concat(Joi.object({
id: Joi.forbidden(),
username: Joi.string().alphanum().min(3).max(20).required(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Utilizar .token no lugar de .alphanum, assim podemos criar usernames com underscore também

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bom saber

Comment thread resources/users/schemas.js Outdated
exports.create = exports.model.concat(Joi.object({
id: Joi.forbidden(),
username: Joi.string().alphanum().min(3).max(20).required(),
password: Joi.string().max(60).required()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.min(8).max(120)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@codecov-io

codecov-io commented Nov 15, 2016

Copy link
Copy Markdown

Current coverage is 96.14% (diff: 96.22%)

Merging #64 into backend will increase coverage by 0.04%

@@            backend        #64   diff @@
==========================================
  Files            11         15     +4   
  Lines           256        311    +55   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits            246        299    +53   
- Misses           10         12     +2   
  Partials          0          0          

Powered by Codecov. Last update bc9f4cf...92833ad

@alanhoff
alanhoff dismissed their stale review November 15, 2016 17:36

Novo review

@alanhoff alanhoff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Faltando testes para:

  • Nome de usuário duplicado
  • Se a senha foi realmente criptografada

@@ -0,0 +1,13 @@

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remover a linha em branco

@@ -0,0 +1,13 @@

exports.up = knex => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Não precisa criar um escopo com as chaves aqui, pode simplesmente knex => knex.schema...

})
}

exports.down = knex => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mesma questão do escopo

Comment thread resources/users/handlers.js Outdated
@@ -0,0 +1,17 @@

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remover linha em branco

Comment thread resources/users/model.js Outdated
@@ -0,0 +1,6 @@

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linha em branco

Comment thread resources/users/routes.js Outdated
@@ -0,0 +1,16 @@

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linha em branco

Comment thread test/fixtures/users.js Outdated
@@ -0,0 +1,27 @@
'use strict'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remover use strict

Comment thread test/fixtures/users.js Outdated
* Insere dois registros na tabela hello_world
* @return {Promise} Uma promise que resolve quando os registros forem inseridos
*/
exports.insertMultiple = () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

não precisa criar um escopo e um return

Comment thread test/fixtures/users.js Outdated
const { knex } = require('../../lib/db')

/**
* Insere dois registros na tabela hello_world

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentação errada

Comment thread test/resources/users.js Outdated
@@ -0,0 +1,46 @@
'use strict'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remover o use strict daqui também

@alanhoff

Copy link
Copy Markdown
Member

LGMT

@alanhoff
alanhoff merged commit aabd929 into nodebr:backend Nov 15, 2016
@thebergamo thebergamo mentioned this pull request Nov 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants