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 3 #3

Merged
merged 16 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"require-jsdoc": 0,
"prefer-rest-params": 1,
"guard-for-in": 0,
"prefer-promise-reject-errors": 0
"prefer-promise-reject-errors": 0,
"camelcase": "off"
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.parcel-cache
dist
todo
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**О проекте:** это онлайн мессенджер.
**Функционал:** регистрация, авторизация, отправка сообщений/файлов, просмотр истории сообщений, редактирование профиля, смена пароля и аватара.
**Что интересного:** весь функционал разработан с использованием нативного JS (TS), иными словами без фреймворков. Архитектура и структура исполнена в компонентном подходе. Реализован собственный шаблонизатор, работают жизненные циклы компонентов, кастомная валидаци, написана своя обертка для xhr, настроены линтинги. Раздача статики через Express.
**Что интересного:** весь функционал разработан с использованием нативного JS (TS), иными словами без фреймворков. Архитектура и структура исполнена в компонентном подходе. Реализован собственный шаблонизатор, работают жизненные циклы компонентов, кастомная валидаци, написана своя обертка для xhr, настроены линтинги, приложение работает как SPA. Раздача статики через Express.

## Tech Stack

Expand Down Expand Up @@ -59,4 +59,4 @@ Run stylelint:

## 🔗 Links

[pull request](https://github.com/KomAnw/middle.messenger.praktikum.yandex/pull/2)
[pull request](https://github.com/KomAnw/middle.messenger.praktikum.yandex/pull/3)
17 changes: 9 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@500;600&display=swap"
rel="stylesheet" />
<script src="./src/index.ts" type="module"></script>
rel="stylesheet"
/>
<script src="./src/index.tsx" type="module"></script>
<title>Messanger</title>
</head>
<body>
<button onclick="window.history.pushState({}, null, '/login')">login page</button>
<button onclick="window.history.pushState({}, null, '/registration')">registration page</button>
<button onclick="window.history.pushState({}, null, '/404');">404</button>
<button onclick="window.history.pushState({}, null, '/500');">500</button>
<button onclick="window.history.pushState({}, null, '/profile');">Profile</button>
<button onclick="window.history.pushState({}, null, '/chat');">Chat</button>
<div id="root"></div>
<div id="popup">
<div
class="background"
onclick="document.querySelector('#popup custom-component').remove()"
></div>
</div>
</body>
</html>
4 changes: 4 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@

[build]
publish = "dist"
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"browserslist": "> 0.5%, last 2 versions, not dead",
"scripts": {
"clean:output": "rimraf dist",
"clean:output": "rimraf dist .parcel-cache",
"open": "start http://localhost:3000",
"server": "node server.js",
"start": "yarn run clean:output && parcel index.html -p 3000 --open",
Expand All @@ -13,7 +13,8 @@
"eslint": "eslint --ext .ts,.js .",
"eslint:fix": "eslint --fix --ext .ts,.js .",
"stylelint": "stylelint \"**/*.scss\"",
"stylelint:fix": "stylelint \"**/*.scss\" --fix"
"stylelint:fix": "stylelint \"**/*.scss\" --fix",
"test": "./node_modules/.bin/mocha"
},
"alias": {
"src": "./src"
Expand All @@ -27,11 +28,16 @@
"devDependencies": {
"@parcel/transformer-inline-string": "2.7.0",
"@parcel/transformer-sass": "2.7.0",
"@parcel/validator-typescript": "2.7.0",
"@types/chai": "4.3.4",
"@types/express": "4.17.14",
"@types/mocha": "10.0.1",
"@typescript-eslint/eslint-plugin": "5.42.0",
"@typescript-eslint/parser": "5.42.0",
"chai": "4.3.7",
"eslint": "8.26.0",
"eslint-config-google": "0.14.0",
"mocha": "10.2.0",
"parcel": "2.7.0",
"rimraf": "3.0.2",
"stylelint": "14.14.0",
Expand Down
13 changes: 0 additions & 13 deletions src/App/App.scss

This file was deleted.

75 changes: 0 additions & 75 deletions src/App/App.ts

This file was deleted.

59 changes: 0 additions & 59 deletions src/api/Api.ts

This file was deleted.

55 changes: 55 additions & 0 deletions src/api/Auth/Auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import Fetch from 'src/modules/Fetch/Fetch';
import addInstancePath from 'src/utils/generateUrl';
import {AUTH} from '../constants';
import {AuthOperations} from './types';
import {FetchOptions, METHODS} from 'src/modules/Fetch/types';
import {ContentTypes} from '../types';
import {RegistrationFormData} from 'src/pages/Registration/types';
import {LoginFormData} from 'src/pages/Login/types';

const {POST} = METHODS;
const {applicationJSON} = ContentTypes;
const generateUrl = addInstancePath(AUTH);

const basePostOptions: FetchOptions = {
methodType: POST,
headers: {
'content-type': applicationJSON,
},
};

export const signup = async (data: RegistrationFormData) => {
const url = generateUrl(AuthOperations.signup);
const options: FetchOptions = {
...basePostOptions,
data: JSON.stringify(data),
};

const response = await Fetch(url, options);
return response;
};

export const signin = async (data: LoginFormData) => {
const url = generateUrl(AuthOperations.signin);
const options: FetchOptions = {
...basePostOptions,
data: JSON.stringify(data),
};

const response = await Fetch(url, options);
return response;
};

export const getUserInfo = async () => {
const url = generateUrl(AuthOperations.user);

const response = await Fetch(url);
return response;
};

export const logout = async () => {
const url = generateUrl(AuthOperations.logout);

const response = await Fetch(url, basePostOptions);
return response;
};
7 changes: 7 additions & 0 deletions src/api/Auth/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint-disable */
export enum AuthOperations {
signup = "signup",
signin = "signin",
user = "user",
logout = "logout",
}