React/Redux - publish component #323

Merged
bones7242 merged 80 commits from react-upload into master 2018-01-25 22:43:20 +01:00
6 changed files with 42 additions and 33 deletions
Showing only changes of commit 0220e649c2 - Show all commits

View file

@ -34,7 +34,6 @@ class ChannelCreateForm extends React.Component {
} else {
this.setState({error: 'Please enter a channel name'});
}
console.log('end of handlechannelinput');
}
handleInput (event) {
const name = event.target.name;
@ -61,11 +60,10 @@ class ChannelCreateForm extends React.Component {
return new Promise((resolve, reject) => {
makeGetRequest(`/api/channel-is-available/${channelWithAtSymbol}`)
.then(isAvailable => {
console.log('checkIsChannelAvailable result:', isAvailable);
if (!isAvailable) {
console.log('channel is not available');
return reject(new Error('That channel has already been claimed'));
}
console.log('channel is available');
resolve();
})
.catch((error) => {
@ -89,6 +87,7 @@ class ChannelCreateForm extends React.Component {
return new Promise((resolve, reject) => {
makePostRequest('/signup', params)
.then(result => {
console.log('makePublishChannelRequest result:', result);
return resolve(result);
})
.catch(error => {

View file

@ -20,11 +20,15 @@ class ChannelLoginForm extends React.Component {
neb-b commented 2018-01-18 06:19:30 +01:00 (Migrated from github.com)
Review

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik

I really like how they use the render prop, I think it's a really nice way to interact with React elements

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik I really like how they use the `render` prop, I think it's a really nice way to interact with React elements
neb-b commented 2018-01-18 06:19:30 +01:00 (Migrated from github.com)
Review

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik

I really like how they use the render prop, I think it's a really nice way to interact with React elements

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik I really like how they use the `render` prop, I think it's a really nice way to interact with React elements
loginToChannel (event) {
event.preventDefault();
const params = `username=${this.state.name}&password=${this.state.password}`;
const url = '/login';
neb-b commented 2018-01-18 06:19:30 +01:00 (Migrated from github.com)
Review

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik

I really like how they use the render prop, I think it's a really nice way to interact with React elements

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik I really like how they use the `render` prop, I think it's a really nice way to interact with React elements
const that = this;
makePostRequest(url, params)
neb-b commented 2018-01-18 06:19:30 +01:00 (Migrated from github.com)
Review

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik

I really like how they use the render prop, I think it's a really nice way to interact with React elements

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik I really like how they use the `render` prop, I think it's a really nice way to interact with React elements
makePostRequest('login', params)
neb-b commented 2018-01-18 06:19:30 +01:00 (Migrated from github.com)
Review

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik

I really like how they use the render prop, I think it's a really nice way to interact with React elements

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik I really like how they use the `render` prop, I think it's a really nice way to interact with React elements
.then(result => {
that.props.onChannelLogin(result.channelName, result.shortChannelId, result.channelClaimId);
neb-b commented 2018-01-18 06:19:30 +01:00 (Migrated from github.com)
Review

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik

I really like how they use the render prop, I think it's a really nice way to interact with React elements

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik I really like how they use the `render` prop, I think it's a really nice way to interact with React elements
console.log('loginToChannel result:', result);
neb-b commented 2018-01-18 06:19:30 +01:00 (Migrated from github.com)
Review

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik

I really like how they use the render prop, I think it's a really nice way to interact with React elements

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik I really like how they use the `render` prop, I think it's a really nice way to interact with React elements
if (result.success) {
neb-b commented 2018-01-18 06:19:30 +01:00 (Migrated from github.com)
Review

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik

I really like how they use the render prop, I think it's a really nice way to interact with React elements

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik I really like how they use the `render` prop, I think it's a really nice way to interact with React elements
that.props.onChannelLogin(result.channelName, result.shortChannelId, result.channelClaimId);
neb-b commented 2018-01-18 06:19:30 +01:00 (Migrated from github.com)
Review

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik

I really like how they use the render prop, I think it's a really nice way to interact with React elements

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik I really like how they use the `render` prop, I think it's a really nice way to interact with React elements
} else {
neb-b commented 2018-01-18 06:19:30 +01:00 (Migrated from github.com)
Review

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik

I really like how they use the render prop, I think it's a really nice way to interact with React elements

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik I really like how they use the `render` prop, I think it's a really nice way to interact with React elements
that.setState({'error': result.message});
neb-b commented 2018-01-18 06:19:30 +01:00 (Migrated from github.com)
Review

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik

I really like how they use the render prop, I think it's a really nice way to interact with React elements

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik I really like how they use the `render` prop, I think it's a really nice way to interact with React elements
};
neb-b commented 2018-01-18 06:19:30 +01:00 (Migrated from github.com)
Review

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik

I really like how they use the render prop, I think it's a really nice way to interact with React elements

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik I really like how they use the `render` prop, I think it's a really nice way to interact with React elements
})
.catch(error => {
console.log('login error', error);

neb-b commented 2018-01-18 06:19:30 +01:00 (Migrated from github.com)
Review

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik

I really like how they use the render prop, I think it's a really nice way to interact with React elements

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik I really like how they use the `render` prop, I think it's a really nice way to interact with React elements
neb-b commented 2018-01-18 06:19:30 +01:00 (Migrated from github.com)
Review

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik

I really like how they use the render prop, I think it's a really nice way to interact with React elements

Forms are one of the most painful things in React. It might be worth looking into 3rd party React form elements. I've done a fair bit of work with forms and think that Formik is really nice. Hoping to add it to more parts of the app soon. https://github.com/jaredpalmer/formik I really like how they use the `render` prop, I think it's a really nice way to interact with React elements

View file

@ -43,6 +43,7 @@ class PublishUrlInput extends React.Component {
const that = this;
makeGetRequest(`/api/claim-is-available/${claim}`)
.then(response => {
console.log('makeGetRequest response:', response);
if (response) {
that.props.onUrlError(null);
} else {

View file

@ -2,8 +2,7 @@ import {makeGetRequest} from 'utils/xhr';
module.exports = {
authenticateUser () {
// send authentication request to server
// receive the user info back
// send request to server & receive the user info back
return makeGetRequest('/user');
},
};

View file

@ -6,14 +6,9 @@ module.exports = {
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
xhttp.responseType = 'json';
xhttp.onreadystatechange = () => {
if (xhttp.readyState === 4) {
if (xhttp.status === 200) {
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
resolve(xhttp.response);
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
} if (xhttp.status === 401) {
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
reject(new Error('Wrong username or password'));
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
} else {
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
reject(new Error(xhttp.response));
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
}
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
}
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
console.log('makeGetRequest response:', xhttp.response);
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
resolve(xhttp.response);
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
};
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
};
xhttp.send();
});
@ -26,14 +21,9 @@ module.exports = {
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.onreadystatechange = () => {
if (xhttp.readyState === 4) {
if (xhttp.status === 200) {
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
resolve(xhttp.response);
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
} if (xhttp.status === 401) {
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
reject(new Error('Wrong username or password'));
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
} else {
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
reject(new Error(xhttp.response));
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
}
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
}
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
console.log('makePostRequest response:', xhttp.response);
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
resolve(xhttp.response);
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
};
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
};
xhttp.send(params);
});

kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.
kauffj commented 2018-01-22 19:36:01 +01:00 (Migrated from github.com)
Review

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

All get and post requests should not assume a 401 means invalid username and password. Instead, have the server pass back the error message. Also, checks for 401 vs. 403 appear to be inconsistent.

View file

@ -13,15 +13,31 @@ module.exports = (app) => {
});
});
// route for log in
app.post('/login', passport.authenticate('local-login'), (req, res) => {
// logger.debug('req.user:', req.user); // req.user contains the authenticated user's info
logger.debug('successful login');
res.status(200).json({
success : true,
channelName : req.user.channelName,
channelClaimId: req.user.channelClaimId,
shortChannelId: req.user.shortChannelId,
});
app.post('/login', (req, res, next) => {
passport.authenticate('local-login', (err, user, info) => {
logger.debug('info:', info);
if (err) {
return next(err);
}
if (!user) {
return res.status(200).json({
success: false,
message: info.message,
});
}
logger.debug('successful login');
req.logIn(user, (err) => {
if (err) {
return next(err);
}
return res.status(200).json({
success : true,
channelName : req.user.channelName,
channelClaimId: req.user.channelClaimId,
shortChannelId: req.user.shortChannelId,
});
});
})(req, res, next);
});
// see if user is authenticated, and return credentials if so
app.get('/user', (req, res) => {