Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprint 1 #100

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
582 changes: 582 additions & 0 deletions README.md

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions frontend/auth-microfrontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@mesto/auth",
"version": "1.0.0",
"main": "src/index.js",
"scripts": {
"start": "webpack serve --env development",
"build": "webpack --env production"
},
"dependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2",
"single-spa-react": "^4.0.0"
},
"devDependencies": {
"@babel/core": "^7.14.6",
"@babel/preset-env": "^7.14.7",
"@babel/preset-react": "^7.14.5",
"babel-loader": "^8.2.2",
"webpack": "^5.38.1",
"webpack-cli": "^4.7.2",
"webpack-config-single-spa-react": "^2.1.2",
"webpack-dev-server": "^3.11.2",
"webpack-merge": "^5.7.3"
}
}
17 changes: 17 additions & 0 deletions frontend/auth-microfrontend/src/AuthApp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import Login from './components/Login';
import Register from './components/Register';

function AuthApp() {
return (
<Router basename="/auth">
<Switch>
<Route path="/signin" component={Login} />
<Route path="/signup" component={Register} />
</Switch>
</Router>
);
}

export default AuthApp;
16 changes: 16 additions & 0 deletions frontend/auth-microfrontend/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import ReactDOM from 'react-dom';
import singleSpaReact from 'single-spa-react';
import AuthApp from './AuthApp'; // Корневой компонент микрофронтенда Auth

const lifecycles = singleSpaReact({
React,
ReactDOM,
rootComponent: AuthApp,
errorBoundary(err, info, props) {
// Обработка ошибок
return null;
},
});

export const { bootstrap, mount, unmount } = lifecycles;
24 changes: 24 additions & 0 deletions frontend/auth-microfrontend/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const path = require('path');
const { merge } = require('webpack-merge');
const singleSpaDefaults = require('webpack-config-single-spa-react');

module.exports = (webpackConfigEnv, argv) => {
const defaultConfig = singleSpaDefaults({
orgName: 'mesto',
projectName: 'auth',
webpackConfigEnv,
argv,
});

return merge(defaultConfig, {
output: {
publicPath: 'http://localhost:8500/',
},
devServer: {
port: 8500,
headers: {
'Access-Control-Allow-Origin': '*',
},
},
});
};
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions frontend/gallery-microfrontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@mesto/gallery",
"version": "1.0.0",
"main": "src/index.js",
"scripts": {
"start": "webpack serve --env development",
"build": "webpack --env production"
}
// ...
}

15 changes: 15 additions & 0 deletions frontend/gallery-microfrontend/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import ReactDOM from 'react-dom';
import singleSpaReact from 'single-spa-react';
import GalleryApp from './GalleryApp'; // Корневой компонент микрофронтенда Gallery

const lifecycles = singleSpaReact({
React,
ReactDOM,
rootComponent: GalleryApp,
errorBoundary(err, info, props) {
return null;
},
});

export const { bootstrap, mount, unmount } = lifecycles;
File renamed without changes.
24 changes: 24 additions & 0 deletions frontend/gallery-microfrontend/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const path = require('path');
const { merge } = require('webpack-merge');
const singleSpaDefaults = require('webpack-config-single-spa-react');

module.exports = (webpackConfigEnv, argv) => {
const defaultConfig = singleSpaDefaults({
orgName: 'mesto',
projectName: 'gallery',
webpackConfigEnv,
argv,
});

return merge(defaultConfig, {
output: {
publicPath: 'http://localhost:8502/',
},
devServer: {
port: 8502,
headers: {
'Access-Control-Allow-Origin': '*',
},
},
});
};
11 changes: 11 additions & 0 deletions frontend/profile-microfrontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@mesto/profile",
"version": "1.0.0",
"main": "src/index.js",
"scripts": {
"start": "webpack serve --env development",
"build": "webpack --env production"
}
// ...
}

15 changes: 15 additions & 0 deletions frontend/profile-microfrontend/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import ReactDOM from 'react-dom';
import singleSpaReact from 'single-spa-react';
import ProfileApp from './ProfileApp'; // Корневой компонент микрофронтенда Profile

const lifecycles = singleSpaReact({
React,
ReactDOM,
rootComponent: ProfileApp,
errorBoundary(err, info, props) {
return null;
},
});

export const { bootstrap, mount, unmount } = lifecycles;
106 changes: 106 additions & 0 deletions frontend/profile-microfrontend/src/utils/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
class Api {
constructor({ address, token, groupId }) {
// стандартная реализация -- объект options
this._token = token;
this._groupId = groupId;
this._address = address;

// Запросы в примере работы выполняются к старому Api, в новом URL изменены.
}

getAppInfo() {
return Promise.all([this.getCardList(), this.getUserInfo()]);
}

getCardList() {
return fetch(`${this._address}/${this._groupId}/cards`, {
headers: {
authorization: this._token,
},
})
.then(res => res.ok ? res.json() : Promise.reject(`Ошибка: ${res.status}`));
}

addCard({ name, link }) {
return fetch(`${this._address}/${this._groupId}/cards`, {
method: 'POST',
headers: {
authorization: this._token,
'Content-Type': 'application/json',
},
body: JSON.stringify({
name,
link,
}),
})
.then(res => res.ok ? res.json() : Promise.reject(`Ошибка: ${res.status}`));
}

removeCard(cardID) {
return fetch(`${this._address}/${this._groupId}/cards/${cardID}`, {
method: 'DELETE',
headers: {
authorization: this._token,
},
})
.then(res => res.ok ? res.json() : Promise.reject(`Ошибка: ${res.status}`));
}

getUserInfo() {
return fetch(`${this._address}/${this._groupId}/users/me`, {
headers: {
authorization: this._token,
},
})
.then(res => res.ok ? res.json() : Promise.reject(`Ошибка: ${res.status}`));
}

setUserInfo({ name, about }) {
return fetch(`${this._address}/${this._groupId}/users/me`, {
method: 'PATCH',
headers: {
authorization: this._token,
'Content-Type': 'application/json',
},
body: JSON.stringify({
name,
about,
}),
})
.then(res => res.ok ? res.json() : Promise.reject(`Ошибка: ${res.status}`));
}

setUserAvatar({ avatar }) {
return fetch(`${this._address}/${this._groupId}/users/me/avatar`, {
method: 'PATCH',
headers: {
authorization: this._token,
'Content-Type': 'application/json',
},
body: JSON.stringify({
avatar,
}),
})
.then(res => res.ok ? res.json() : Promise.reject(`Ошибка: ${res.status}`));
}

changeLikeCardStatus(cardID, like) {
// Обычная реализация: 2 разных метода для удаления и постановки лайка.
return fetch(`${this._address}/${this._groupId}/cards/like/${cardID}`, {
method: like ? 'PUT' : 'DELETE',
headers: {
authorization: this._token,
'Content-Type': 'application/json',
},
})
.then(res => res.ok ? res.json() : Promise.reject(`Ошибка: ${res.status}`));
}
}

const api = new Api({
address: 'https://nomoreparties.co',
groupId: `cohort0`,
token: `80a75492-21c5-4330-a02f-308029e94b63`,
});

export default api;
24 changes: 24 additions & 0 deletions frontend/profile-microfrontend/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const path = require('path');
const { merge } = require('webpack-merge');
const singleSpaDefaults = require('webpack-config-single-spa-react');

module.exports = (webpackConfigEnv, argv) => {
const defaultConfig = singleSpaDefaults({
orgName: 'mesto',
projectName: 'profile',
webpackConfigEnv,
argv,
});

return merge(defaultConfig, {
output: {
publicPath: 'http://localhost:8501/',
},
devServer: {
port: 8501,
headers: {
'Access-Control-Allow-Origin': '*',
},
},
});
};
4 changes: 0 additions & 4 deletions frontend/src/blocks/content/content.css

This file was deleted.

8 changes: 0 additions & 8 deletions frontend/src/blocks/page/__content/page__content.css

This file was deleted.

15 changes: 0 additions & 15 deletions frontend/src/blocks/page/__section/page__section.css

This file was deleted.

6 changes: 0 additions & 6 deletions frontend/src/blocks/page/page.css

This file was deleted.

3 changes: 0 additions & 3 deletions frontend/src/blocks/places/__item/places__item.css

This file was deleted.

9 changes: 0 additions & 9 deletions frontend/src/blocks/places/__list/places__list.css

This file was deleted.

13 changes: 0 additions & 13 deletions frontend/src/blocks/places/places.css

This file was deleted.

Loading