-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from IamMohaiminul/refurbish
Refurbish MERNjs
- Loading branch information
Showing
77 changed files
with
25,996 additions
and
1,466 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
{ | ||
"presets": [ | ||
"env", | ||
"react" | ||
] | ||
"presets": ["@babel/preset-env", "@babel/preset-react"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
NODE_ENV=development | ||
PORT=3000 | ||
API_URL=http://127.0.0.1:3000/api | ||
MONGO_URL=mongodb://127.0.0.1:27017/MERNjs | ||
JWT_SECRET=MERNjsJsonWebTokenSecret | ||
JWT_EXPIRES=1h | ||
MORGAN_FMT=dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2020": true | ||
}, | ||
"extends": ["eslint:recommended", "plugin:react/recommended", "airbnb", "prettier"], | ||
"parserOptions": { | ||
"ecmaFeatures": { | ||
"jsx": true | ||
}, | ||
"ecmaVersion": 11, | ||
"sourceType": "module" | ||
}, | ||
"plugins": ["react"], | ||
"rules": { | ||
"no-console": "off", | ||
"no-underscore-dangle": ["error", { "allow": ["_id", "_createdBy"] }], | ||
"no-param-reassign": ["error", { "props": true, "ignorePropertyModificationsFor": ["req", "res", "err"] }], | ||
"import/no-extraneous-dependencies": ["error", { "peerDependencies": true }], | ||
"react/forbid-prop-types": ["error", { "forbid": ["any"] }], | ||
"jsx-a11y/label-has-associated-control": ["error", { "assert": "either" }] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
# Dependency directories | ||
node_modules | ||
|
||
# Environment variables | ||
.env | ||
|
||
# Build/Generate directories | ||
build | ||
dist | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"semi": true, | ||
"trailingComma": "all", | ||
"singleQuote": true, | ||
"printWidth": 120 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,29 @@ | ||
import axios from 'axios'; | ||
|
||
/* | ||
* Get all user | ||
*/ | ||
export const loginUser = ((object, callback) => { | ||
try { | ||
return function (dispatch) { | ||
dispatch({ type: 'AUTH_LOGIN_REQUEST' }); | ||
axios.post('auth', object) | ||
.then((response) => { | ||
dispatch({ | ||
type: 'AUTH_LOGIN_SUCCESS', | ||
payload: response.data, | ||
}); | ||
localStorage.setItem('token', response.data.data.token); | ||
localStorage.setItem('email', response.data.data.email); | ||
if (typeof callback === 'function') { | ||
callback(null, response.data); | ||
} | ||
}) | ||
.catch((error) => { | ||
dispatch({ type: 'AUTH_LOGIN_FAILURE' }); | ||
if (typeof callback === 'function') { | ||
callback(error.response.data, null); | ||
} | ||
}); | ||
}; | ||
} catch (e) { | ||
return res.status(500).json({ | ||
success: false, | ||
message: 'Error in loginUser', | ||
error: e, | ||
const loginUser = (object, callback) => (dispatch) => { | ||
dispatch({ | ||
type: 'AUTH_LOGIN_REQUEST', | ||
}); | ||
axios | ||
.post('/auth', object) | ||
.then((response) => { | ||
dispatch({ | ||
type: 'AUTH_LOGIN_SUCCESS', | ||
payload: response.data, | ||
}); | ||
localStorage.setItem('token', response.data.data.token); | ||
localStorage.setItem('email', response.data.data.email); | ||
if (typeof callback === 'function') { | ||
callback(null, response.data); | ||
} | ||
}) | ||
.catch((err) => { | ||
console.log('auth_err: ', err); | ||
dispatch({ type: 'AUTH_LOGIN_FAILURE' }); | ||
if (typeof callback === 'function') { | ||
callback(err.response.data, null); | ||
} | ||
}); | ||
} | ||
}); | ||
}; | ||
|
||
export default loginUser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,24 @@ | ||
import axios from 'axios'; | ||
|
||
/* | ||
* Get all user | ||
*/ | ||
export const registerUser = ((object, callback) => { | ||
try { | ||
return function (dispatch) { | ||
dispatch({ type: 'AUTH_REGISTER_REQUEST' }); | ||
axios.post('auth/register', object) | ||
.then((response) => { | ||
dispatch({ | ||
type: 'AUTH_REGISTER_SUCCESS', | ||
payload: response.data, | ||
}); | ||
if (typeof callback === 'function') { | ||
callback(null, response.data); | ||
} | ||
}) | ||
.catch((error) => { | ||
dispatch({ type: 'AUTH_REGISTER_FAILURE' }); | ||
if (typeof callback === 'function') { | ||
callback(error.response.data, null); | ||
} | ||
}); | ||
}; | ||
} catch (e) { | ||
return res.status(500).json({ | ||
success: false, | ||
message: 'Error in registerUser', | ||
error: e, | ||
const registerUser = (object, callback) => (dispatch) => { | ||
dispatch({ type: 'AUTH_REGISTER_REQUEST' }); | ||
axios | ||
.post('/auth/register', object) | ||
.then((response) => { | ||
dispatch({ | ||
type: 'AUTH_REGISTER_SUCCESS', | ||
payload: response.data, | ||
}); | ||
if (typeof callback === 'function') { | ||
callback(null, response.data); | ||
} | ||
}) | ||
.catch((error) => { | ||
dispatch({ type: 'AUTH_REGISTER_FAILURE' }); | ||
if (typeof callback === 'function') { | ||
callback(error.response.data, null); | ||
} | ||
}); | ||
} | ||
}); | ||
}; | ||
|
||
export default registerUser; |
Oops, something went wrong.