Skip to content

Commit

Permalink
rebase changes
Browse files Browse the repository at this point in the history
  • Loading branch information
murediane committed Jun 28, 2019
1 parent fe651b4 commit 448d216
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 18 deletions.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"start": "babel-node src/index.js",
"test": "npm run setup:test && NODE_ENV=test nyc --reporter=html --reporter=text --reporter=lcov ./node_modules/.bin/mocha ./tests/* --require @babel/register --timeout 4000 --exit",
"test": "NODE_ENV=test nyc --reporter=html --reporter=text --reporter=lcov ./node_modules/.bin/mocha ./tests/* --require @babel/register --timeout 4000 --exit",
"dev": "NODE_ENV=development nodemon --exec babel-node src/index.js",
"setup:test": "NODE_ENV=test npm run migrate:undo && NODE_ENV=test npm run migrate && NODE_ENV=test npm run seed",
"setup:dev": "NODE_ENV=development npm run migrate:undo && NODE_ENV=development npm run migrate && NODE_ENV=development npm run seed",
Expand Down Expand Up @@ -64,14 +64,15 @@
"sinon-chai": "^3.3.0",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.11",
"moment": "^2.24.0",
"morgan": "^1.9.1",
"multer": "^1.4.1",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"pg": "^7.11.0",
"pino": "^5.12.6",
"redis": "^2.8.0",
"sequelize": "^5.8.7",
"sequelize-cli": "^5.5.0",
"moment": "^2.24.0",
"multer": "^1.4.1",
"passport-jwt": "^4.0.0",
"slug": "^1.1.0",
"swagger-node-express": "^2.1.3",
"swagger-ui-express": "^4.0.6",
Expand Down
4 changes: 2 additions & 2 deletions src/api/controllers/authController.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export default class Auth {
email,
buttonText: 'Verify',
userName: username,
message: "Please click on the link to verify your email for authors haven.If you didn't request this, simply ignore this e-mail.",
message:
"Please click on the link to verify your email for authors haven.If you didn't request this, simply ignore this e-mail.",
link: `${env.baseUrl}/users/verifyEmail`

});
const tokenData = { id: user.dataValues.id, username, email };
const token = generateToken(tokenData, env.secret);
Expand Down
2 changes: 1 addition & 1 deletion src/api/migrations/20190622195902-create-article.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
author: {
allowNull: false,
type: Sequelize.INTEGER,
references: { model: 'users', key: 'id' }
references: { model: 'Users', key: 'id' }
},
category: {
allowNull: false,
Expand Down
2 changes: 1 addition & 1 deletion src/api/models/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default (sequelize, DataTypes) => {
author: {
allowNull: false,
type: DataTypes.INTEGER,
references: { model: 'users', key: 'id' }
references: { model: 'Users', key: 'id' }
},
category: {
allowNull: false,
Expand Down
4 changes: 2 additions & 2 deletions src/api/models/user.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default (sequelize, DataTypes) => {
const User = sequelize.define('User',
const User = sequelize.define('Users',
{
username: {
type: DataTypes.STRING
Expand Down Expand Up @@ -53,7 +53,7 @@ export default (sequelize, DataTypes) => {
type: DataTypes.STRING
}
},
{ tableName: 'users' });
{ tableName: 'Users' });
User.associate = (models) => {
User.hasMany(models.Article, {
foreignKey: 'userId',
Expand Down
2 changes: 1 addition & 1 deletion src/configs/redisConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dotenv.config();

const consoleLog = pino();
const clientConnection = redis.createClient({
url: process.env.REDIS_URL,
url: process.env.REDIS_URL
});

clientConnection.on('connect', (err) => {
Expand Down
5 changes: 3 additions & 2 deletions src/helpers/constants/error.messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ export default {
unkownEmail: "A user with the provided email doesn't exist",
invalidLink: 'Invalid link provided',
incorectPassword: 'Incorect password provided',
emailLinkInvalid: 'The link provided is corrupt, please request a new one or try to click it again',
noUser: "User doesn't exist."
emailLinkInvalid:
'The link provided is corrupt, please request a new one or try to click it again',
noUser: "User doesn't exist.",
authenticationMessage: 'You have to login to perform this action.',
serverError: 'Something went wrong',
articleCreate: 'Article created',
Expand Down
3 changes: 0 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import logger from 'morgan';
import apiRouter from './api/routes/index';
import docsRouter from './api/routes/docs';
import homeRouter from './api/routes/home';
import register from './middlewares/register.app';
import env from './configs/environments';

const app = express();
import env from './configs/environments';
import passportConfig from './middlewares/passport';
import './helpers/cloudnary';

Expand Down
1 change: 1 addition & 0 deletions src/middlewares/errorHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default callback => async (req, res, next) => {
try {
await callback(req, res, next);
} catch (error) {
console.log(error);
const { parent, details } = error;
if (parent) return res.status(SERVER_ERROR).json({ message: parent.detail });
if (details) return res.status(BAD_REQUEST).json({ message: details[0].message });
Expand Down
3 changes: 2 additions & 1 deletion tests/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ describe('create article', () => {
before((done) => {
chai
.request(server)
.post('/api/users/signup ')
.post('/api/users/signup')
.send(user)
.end((err, res) => {
console.log('res.data ===>', res.body.user.token);
res.should.have.status(statusCode.CREATED);
res.body.should.be.an('Object');
userToken = res.body.user.token;
Expand Down

0 comments on commit 448d216

Please sign in to comment.