Skip to content

Commit

Permalink
Merge branch 'develop' into bg-fix-jwt-165595365
Browse files Browse the repository at this point in the history
  • Loading branch information
Black Developa committed Apr 29, 2019
2 parents 38c907e + 0b6b192 commit 7cd92ff
Show file tree
Hide file tree
Showing 15 changed files with 278 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ services:
before_script:
- psql -c 'create database travis_ci_test;' -U postgres
after_success:
- npm run coverage
- npm run coverage
134 changes: 53 additions & 81 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"start": "node dist/index.js",
"heroku-postbuild": "npm run initdb && npm run build",
"heroku-postbuild": "npm run build",
"build": "babel server -d dist --source-maps",
"test": "cross-env NODE_ENV=test npm run initdb && DEBUG=vale-ah* nyc --reporter=text --reporter=html mocha --timeout=20000 --recursive --exit",
"coverage": "nyc report --reporter=lcov --reporter=text-lcov | coveralls",
Expand Down Expand Up @@ -40,7 +40,7 @@
"passport-twitter": "1.0.4",
"pg": "7.8.1",
"pg-hstore": "2.3.2",
"sequelize": "4.43.0",
"sequelize": "5.7.6",
"sequelize-cli": "5.4.0",
"slug": "1.0.0",
"swagger-ui-express": "4.0.2",
Expand Down
3 changes: 0 additions & 3 deletions server/config/db-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@ module.exports = {
development: {
env_variable: 'DATABASE_URL',
dialect: 'postgres',
operatorsAliases: false,
url: DATABASE_URL
},
test: {
env_variable: 'DATABASE_URL',
dialect: 'postgres',
operatorsAliases: false,
url: DATABASE_URL,
logging: false
},
production: {
env_variable: 'DATABASE_URL',
dialect: 'postgres',
operatorsAliases: false,
url: DATABASE_URL,
logging: false
}
Expand Down
30 changes: 20 additions & 10 deletions server/controllers/recipe-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class RecipeController {
ingredients,
steps,
cookingTime,
preparationTime
preparationTime,
videoList
} = req.body;
try {
await validate(req.body, recipeSchema);
Expand All @@ -58,7 +59,8 @@ class RecipeController {
ingredients,
steps,
cookingTime,
preparationTime
preparationTime,
videoList
})
.then(({ dataValues }) => {
return successResponse(res, { recipe: dataValues }, 201);
Expand All @@ -82,9 +84,16 @@ class RecipeController {
static async updateRecipe(req, res) {
const { id } = req.user;
const { slug } = req.params;
const { ...newRecipe } = req.body;
const {
title,
ingredients,
steps,
cookingTime,
preparationTime,
videoList
} = req.body;
try {
await validate(newRecipe, recipeUpdateSchema);
await validate(req.body, recipeUpdateSchema);
const recipe = await Recipe.findOne({ where: { slug } });
if (!recipe) {
return errorResponse(res, 'recipe not found', 404);
Expand All @@ -98,11 +107,12 @@ class RecipeController {
}
const data = await recipe.update(
{
title: newRecipe.title || recipe.title,
ingredients: newRecipe.ingredients || recipe.ingredients,
cookingTime: newRecipe.cookingTime || recipe.cookingTime,
preparationTime: newRecipe.preparationTime || recipe.preparationTime,
steps: newRecipe.steps || recipe.steps
title,
ingredients,
steps,
cookingTime,
preparationTime,
videoList
},
{ returning: true }
);
Expand All @@ -112,7 +122,7 @@ class RecipeController {
200
);
} catch (error) {
return errorResponse(res, error.message);
return validationErrorResponse(res, error.details);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
up: (queryInterface, Sequelize) =>
queryInterface.sequelize
.query('drop type if exists "enum_Users_socialProvider"')
.query('drop type if exists "enum_Users_socialProvider" cascade')
.then(() =>
queryInterface.addColumn('Users', 'socialProvider', {
type: Sequelize.ENUM(['facebook', 'google', 'twitter'])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
up: queryInterface =>
queryInterface.renameColumn('Followers', 'followingId', 'userId'),

down: queryInterface =>
queryInterface.renameColumn('Followers', 'userId', 'followingId')
};
12 changes: 12 additions & 0 deletions server/migrations/20190418464787-recipe-userid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
up: (queryInterface, Sequelize) =>
queryInterface.addColumn('Recipes', 'userId', {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'Users',
key: 'id'
}
}),
down: queryInterface => queryInterface.removeColumn('Recipes', 'userId')
};
Loading

0 comments on commit 7cd92ff

Please sign in to comment.