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

daniel #31

Open
wants to merge 2 commits into
base: master
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
279 changes: 278 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,278 @@
# mini-wp
# mini-wp

**Base URL:**

**User Routes:**

| Routes | Method | Description |
|---------------------|--------|--------------------------------|
| /users/login | POST | Sign in / login User |
| /users/register | POST | Sign Up / Register new user |
| /users/loginGoogle | POST | Sign in using OAuth 2.0 Google |

**Articles Routes:**

| Routes | Method | Description |
|-------------------|--------|--------------------------------------|
| /articles | GET | Find all article user |
| /articles/:id | GET | Find one article user |
| /articles | POST | Add new article |
| /articles/:id | DELETE | Delete one article with id |
| /articles/:id | PUT | Update article with id todo |
| /articles/:id | PATCH | Update status from draft to publish |



**Errors:**

| Code | Name | Description |
|------|-------------------------------|--------------------------------|
| 401 | ValidationError | error by validation database |
| 401 | UnAuthorise | user not autorised |
| 400 | CastError / JsonWebTokenError | error about token |
| 404 | Not found | data not found |
| 500 | internal server error | error by server |

## **Register User**
- **URL:** `/users/register`
- **Method:** `POST`
- **URL Params:** `None`
- **Data Body:**
-`name: user`
-`email: [email protected]`
-`password: 123456`
- **Success Respone:**
- **Status:**`200`**Content:**
```
{
"message": "login succesfully",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7Il9pZCI6IjVlMjU1MmNkZmM2YjY4NjYyZWM4ZmQwNCIsIm5hbWUiOiJ0aW5hIiwiZW1haWwiOiJ0aW5hQG1haWwuY29tIiwicGFzc3dvcmQiOiIkMmEkMTAkRkVmQVR5RHE2ZWZ0UGRJWDdaNzBHdU9yd2pVdVBUWWZ2Sk1WcnlpWHJYYzNJOUwzdUNsNi4iLCJfX3YiOjB9LCJpYXQiOjE1Nzk1MDQzMzN9.rNL8H5XvdZtGbjcDrYAMzBbjIBwYu5CZS0Pv3HBqivM",
"user": {
"email": "[email protected]",
"_id": "5e2552cdfc6b68662ec8fd04",
"name": "user"
}
}
```
- **Error Respone:**
- **Status:**`500`**Content:**
```
[
'message' : 'internal server error'
]
```
- **Status:**`401`**Content:**
```
[
'message' : 'Validation Error'
]
```

## **Login User**
- **URL:** `/users/login`
- **Method:** `POST`
- **URL Params:** `None`
- **Data Body:**
-`email: [email protected]`
-`password: 123456`
- **Success Respone:**
- **Status:**`200`**Content:**
```
{
"message": "login succesfully",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7Il9pZCI6IjVlMjFlYzVkYjk5ZTIyMWE1MTNjNDIxZSIsIm5hbWUiOiJ0ZXN0IiwiZW1haWwiOiJ0ZXN0QG1haWwuY29tIiwicGFzc3dvcmQiOiIkMmEkMTAkZVhBZjZ4TDhvMHlDRkFWa0VDV21MTy5BcU1DY1ZuY1pCSFlsZ0VmempUSEFvS0p3aFg0WGUiLCJfX3YiOjB9LCJpYXQiOjE1Nzk1MDQyOTZ9.-HPvoj-nYjahSYE8qqA1ErHGUlOEQQPjpfLVBby30WM",
"user": {
"email": "[email protected]",
"_id": "5e21ec5db99e221a513c421e",
"name": "user"
}
}
```
- **Error Respone:**
- **Status:**`500`**Content:**
```
[
'message' : 'internal server error'
]
```
- **Status:**`404`**Content:**
```
[
'message' : 'not found'
]
```

## **Google Login User**
- **URL:** `/users/login-google`
- **Method:** `POST`
- **URL Params:** `None`
- **Headers:**
-`id_token: ( token from google )`
- **Data Body:** `None`
- **Success Respone:**
- **Status:**`200`**Content:**
```
{
"message": "login succes",
"token": "OiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVkZmY3MjI4Y2M4ZjVmMTZhODE4ODMyMyIsImlhdCI6MTU3ODg1NzEwOX0.J0fUBa7Om--sn88jbfF-KaBOob-mWnR90z7PyKRPDmw",
"user": {
"email": "[email protected]",
"_id": "5dff7228cc8f5f16a8188323"
}
}
```
- **Error Respone:**
- **Status:**`500`**Content:**
```
[
'message' : 'internal server error'
]
```
- **Status:**`400`**Content:**
```
[
'message' : 'invalid Token'
]
```

## **Find All Article**
- **URL:** `/articles`
- **Method:** `GET`
- **URL Params:** `None`
- **Headers:**
-`token: ( token id )`
- **Data Body:** `None`
- **Success Respone:**
- **Status:**`200`**Content:**
```
[
{
"star": false,
"image": "https://storage.googleapis.com/azputraupload/1579487171533-1574936248_5ddf9eb801462.jpg",
"tags": [],
"_id": "5e250fc44513eb44ace13e77",
"title": "test",
"content": "<p>test222222222<u>222222222222222</u><strong><u>22222222222222</u></strong></p>",
"author": {
"_id": "5e21ec5db99e221a513c421e",
"name": "test",
"email": "[email protected]",
"password": "$2a$10$eXAf6xL8o0yCFAVkECWmLO.AqMCcVncZBHYlgEfzjTHAoKJwhX4Xe",
"__v": 0
},
"createdAt": "2020-01-20T02:26:12.759Z",
"updatedAt": "2020-01-20T02:26:12.759Z",
"__v": 0
},
{
"star": false,
"image": "null",
"tags": [
"aa",
"bb",
"cc"
],
"_id": "5e251a0ee59e6849ff34d4de",
"title": "test",
"content": "<p>testtttt</p>",
"author": {
"_id": "5e21ec5db99e221a513c421e",
"name": "test",
"email": "[email protected]",
"password": "$2a$10$eXAf6xL8o0yCFAVkECWmLO.AqMCcVncZBHYlgEfzjTHAoKJwhX4Xe",
"__v": 0
},
"createdAt": "2020-01-20T03:10:06.500Z",
"updatedAt": "2020-01-20T03:10:06.500Z",
"__v": 0
}
]
```
- **Error Respone:**
- **Status:**`500`**Content:**
```
[
'message' : 'internal server error'
]
```
- **Status:**`400`**Content:**
```
[
'message' : 'invalid Token'
]
```

## **Create Article**
- **URL:** `/articles`
- **Method:** `POST`
- **URL Params:** `None`
- **Headers:**
-`token: ( token id )`
- **Data Body:**
-`title: test`
-`content: test content`
-`description: test description`
-`image:`**file**
-`tags:tag1,tag2`
- **Success Respone:**
- **Status:**`200`**Content:**
```
{
"star": false,
"image": "",
"tags": [
"tag1",
"tag2"
],
"_id": "5e255364fc6b68662ec8fd05",
"title": "test",
"content": "test content",
"author": "5e21ec5db99e221a513c421e",
"createdAt": "2020-01-20T07:14:44.930Z",
"updatedAt": "2020-01-20T07:14:44.930Z",
"__v": 0
}
```
- **Error Respone:**
- **Status:**`500`**Content:**
```
[
'message' : 'internal server error'
]
```
- **Status:**`400`**Content:**
```
[
'message' : 'invalid Token'
]
```

## **Delete Article**
- **URL:** `/articles`
- **Method:** `DELETE`
- **URL Params:** `id` **id of article**
- **Headers:**
-`token: ( token id )`
- **Data Body:** `None`
- **Success Respone:**
- **Status:**`200`**Content:**
```
{
"n": 1,
"ok": 1,
"deletedCount": 1
}
```
- **Error Respone:**
- **Status:**`500`**Content:**
```
[
'message' : 'internal server error'
]
```
- **Status:**`400`**Content:**
```
[
'message' : 'invalid Token'
]
```
3 changes: 3 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.cache
dist
47 changes: 47 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!-- google signIn -->
<!-- <script src="https://apis.google.com/js/platform.js" async defer></script> -->
<!-- <meta name="google-signin-client_id" content="406800739449-f4dl15t3333dka2qf917rk90vcicatsj.apps.googleusercontent.com"> -->

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">

<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
<title>Mini Wp</title>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-primary">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">
<span class="menu-collapsed">Mini WordPress</span>
</a>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav">

<li class="nav-item dropdown d-sm-block d-md-none">
<a class="nav-link dropdown-toggle" href="#" id="smallerscreenmenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Menu
</a>
<div class="dropdown-menu" aria-labelledby="smallerscreenmenu">
<a class="dropdown-item" href="#">Dashboard</a>
<a class="dropdown-item" href="#">Profile</a>
</div>
</li>

</ul>
</div>
</nav>
<div id="app"></div>

<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="src/main.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>
</html>
Loading