Create a Node.js server app and move the following logic
from the frontend app from the previous stage:
POST request for login (auth is still a ‘simulation’).
Code for login: loginpage.jsx: import React, { useState } from 'react';
import { useDispatch } from 'react-redux';
import { useNavigate } from 'react-router-dom';
import logo from '../../img/LogoSpring.svg';
import style from './Auth.module.css';

export const LoginPage = () => {
    const [username, setUsername] = useState('');
    const [password, setPassword] = useState('');
    const dispatch = useDispatch();
    const navigate = useNavigate();

    const handleSubmit = (e) => {
        e.preventDefault();
        const validUsername = process.env.REACT_APP_USERNAME;
        const validPassword = process.env.REACT_APP_PASSWORD;

        if (username === validUsername && password === validPassword) {
            dispatch({ type: 'LOGIN' });
            navigate('/');
        } else {
            alert('Неправильное имя пользователя или пароль');
        }
    };

    return (
        <div className={style.form_login_wrapper}>
            <img
                className={style.header__logo}
                alt="Spring Framework Logo"
                src={logo}
            />
            <h1 className={style.form_title}>Welcome back!</h1>
            <form onSubmit={handleSubmit} className={style.form_login}>
                <input
                    className={style.form_login_input}
                    type="text"
                    placeholder="Username"
                    value={username}
                    onChange={(e) => setUsername(e.target.value)}
                />
                <input
                    className={style.form_login_input}
                    type="password"
                    placeholder="Password"
                    value={password}
                    onChange={(e) => setPassword(e.target.value)}
                />
                <button type="submit" className={style.form_button_submit}>
                    Login
                </button>
            </form>
        </div>
    );
};
actions.js export const SET_SEARCH_VALUE = 'SET_SEARCH_VALUE';
export const FILTER_CARDS = 'FILTER_CARDS';

export const setSearchValue = (value) => ({
    type: SET_SEARCH_VALUE,
    payload: value
});

export const filterCards = (value) => ({
    type: FILTER_CARDS,
    payload: value
});

export const login = () => ({
    type: 'LOGIN'
});

export const logout = () => ({
    type: 'LOGOUT'
});
AuthReducer.js const initialState = {
    isAuthenticated: false
};

export const authReducer = (state = initialState, action) => {
    switch (action.type) {
        case 'LOGIN':
            return { ...state, isAuthenticated: true };
        case 'LOGOUT':
            return { ...state, isAuthenticated: false };
        default:
            return state;
    }
};
store.js import { createStore, combineReducers } from 'redux';
import { cardsReducer } from './reducer';
import { authReducer } from './authReducer';

const rootReducer = combineReducers({
    cards: cardsReducer,
    auth: authReducer
});

export const store = createStore(rootReducer);
App.js import React from 'react';
import PropTypes from 'prop-types';
import { ThemeProvider } from './Components/Selector/ThemeContext';
import {
    BrowserRouter as Router,
    Route,
    Routes,
    Navigate
} from 'react-router-dom';
import { Provider, useSelector } from 'react-redux';
import { Main } from './Components/Main';
import { store } from './Components/Redux/store';
import { LoginPage } from './Components/Auth/LoginPage';

const PrivateRoute = ({ element }) => {
    const isAuthenticated = useSelector((state) => state.auth.isAuthenticated);
    return isAuthenticated ? element : <Navigate to="/login" />;
};

PrivateRoute.propTypes = {
    element: PropTypes.element.isRequired
};

export const App = () => {
    return (
        <Provider store={store}>
            <ThemeProvider>
                <Router>
                    <Routes>
                        <Route path="/login" element={<LoginPage />} />
                        <Route
                            path="/"
                            element={<PrivateRoute element={<Main />} />}
                        />
                    </Routes>
                </Router>
            </ThemeProvider>
        </Provider>
    );
};
index.js import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { Provider } from 'react-redux';
import { store } from './Components/Redux/store';
import { App } from './App';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
    <React.StrictMode>
        <Provider store={store}>
            <App />
        </Provider>
    </React.StrictMode>
);