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

Imanuel N Jodi #11

Open
wants to merge 10 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
336 changes: 335 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,335 @@
# mini-wp
# Mini-Wp
---
## Usage
Make sure you have node.js installed in your computer,and then run this command :
1. $ npm install
2. $ npm run dev

---
## Link Demo
#### [Demo](http://mini-wp-client.itsjoel.site/)


### Base url : http://mini-wp-server.itsjoel.site
---

#### User

| URL | Method | Headers | Body | Success Status | Error Status |
| --- | ------ | ------- | ---- | -------------- | ------------ |
| /login | POST | none | email(String) , password(string) | 200 | 404,500 |
| /register | POST | none | email(string) , password(string) | 201 | 400,500 |
| /google | POST | none | none | 200 | 500 |
##### Login
* URL

(base url)/login
* Method
POST
* URL params
none
* Data params
Required :
* email=[String]
* password=[string]
* Success Response
Status : 200
Content :
```
token: 'eyJhbGciOiJIUzabcdefghijklmnopqrstuvwxyz'
```
* Error Response
Status : 404
content :
```
{
"message": "Wrong email/password"
}
```
---
##### Register
* URL

(base url)/register
* Method
POST
* URL params
none
* Data params
Required :
* email=[String]
* password=[string]
* Success Response
Status : 201
Content :
```
{
"user": {
"full_name": "hello",
"_id": "5dc82ef4cb35b84d6bf79583",
"email": "[email protected]",
"password": "<hashed password>",
"createdAt": "2019-11-10T15:38:29.124Z",
"updatedAt": "2019-11-10T15:38:29.124Z"
}
}
```
* Error Response
Status : 400
content :
```
{
"message": "Please make sure all required fields are filled"
}
```
---
##### Google
* URL

(base url)/google
* Method
POST
* URL params
none
* Data params
Required :
* email=[String]
* Success Response
Status : 200,201
Content :
```
token: 'eyJhbGciOiJIUzabcdefghijklmnopqrstuvwxyz'
```
* Error Response
Status : 500
---
#### Article

| URL | Method | Headers | Body | Success Status | Error Status |
| --- | ------ | ------- | ---- | -------------- | ------------ |
| /article/user | GET | token | none | 200 | 403,500 |
| /article/user | POST | token | title(string) , content(string) , image(file) | 201 | 403,400,500 |
| /article | GET | token | none | 200 | 403,500 |
| /article/user/:id | PUT | token | title(string) , content(string) , image(file) , status(string) | 200 | 403,401,400,500 |
| /article/user/:id | DELETE | token | none | 200 | 403,404,500 |
##### Get all my article
* URL

(base url)/article/user

* Method
GET
* URL Params
none
* Data Params
none
* Headers
token(jwt token)
* Success Response
Status : 200
content:
```
[
{
"created_at": "2019-11-10",
"featured_image": "<image url>",
"status": "Draft",
"_id": "5dc7f919258e6a284fc2c697",
"title": "lagii",
"content": "lagii2",
"author": {
"full_name": "bella",
"_id": "5dc7f8e3258e6a284fc2c696",
"email": "[email protected]",
"password": "<hashed password>",
"createdAt": "2019-11-10T11:47:48.037Z",
"updatedAt": "2019-11-10T11:47:48.037Z"
},
"createdAt": "2019-11-10T11:48:41.733Z",
"updatedAt": "2019-11-10T11:48:41.733Z"
}
]
```
* Error Response
Status : 403
content :
```
{
"message": "Sorry this site is forbidden for you"
}
```
---
##### Create new article
* URL

(base url)/article/user

* Method
POST
* URL Params
none
* Data Params
Required :
* title=[string]
* content=[string]
* Optional : image=[file]
* Headers
token(jwt token)
* Success Response
Status : 201
content:
```
{
"article": {
"created_at": "2019-11-10",
"featured_image": "<image url>",
"status": "Draft",
"_id": "5dc8330acb35b84d6bf79587",
"title": "lagii",
"content": "lagii2",
"author": "5dc7f8e3258e6a284fc2c696",
"createdAt": "2019-11-10T15:55:54.085Z",
"updatedAt": "2019-11-10T15:55:54.085Z"
}
}
```
* Error Response
Status : 400
content :
```
{
"message": "Please make sure all required fields are filled"
}
```
---
##### Get all published article
* URL

(base url)/article

* Method
GET
* URL Params
none
* Data Params
none
* Headers
token(jwt token)
* Success Response
Status : 200
content:
```
[
{
"created_at": "2019-11-10",
"featured_image": "<image url>",
"status": "Published",
"_id": "5dc7f919258e6a284fc2c697",
"title": "lagii",
"content": "lagii2",
"author": {
"full_name": "bella",
"_id": "5dc7f8e3258e6a284fc2c696",
"email": "[email protected]",
"password": "<hashed password>",
"createdAt": "2019-11-10T11:47:48.037Z",
"updatedAt": "2019-11-10T11:47:48.037Z"
},
"createdAt": "2019-11-10T11:48:41.733Z",
"updatedAt": "2019-11-10T11:48:41.733Z"
}
]
```
* Error Response
Status : 403
content :
```
{
"message": "Sorry this site is forbidden for you"
}
```
---
##### Edit my article
* URL

(base url)/article/user

* Method
PUT
* URL Params
Article id
* Data Params
title=[string]
content=[string]
image=[file]
status=[string]
* enum: ['Published','Draft']
* Headers
token(jwt token)
* Success Response
Status : 200
content:
```
{
"article": {
"created_at": "2019-11-10",
"featured_image": "<image url>",
"status": "Draft",
"_id": "5dc8330acb35b84d6bf79587",
"title": "lagii",
"content": "lagii2",
"author": "5dc7f8e3258e6a284fc2c696",
"createdAt": "2019-11-10T15:55:54.085Z",
"updatedAt": "2019-11-10T15:55:54.085Z"
}
}
```
* Error Response
Status : 401
content :
```
{
"message": "Data not exists / You trying to access data that you don't have permission on"
}
```
---
##### Delete my article
* URL

(base url)/article/user

* Method
Delete
* URL Params
Article id
* Data Params
none
* Headers
token(jwt token)
* Success Response
Status : 200
content:
```
{
"article": {
"created_at": "2019-11-10",
"featured_image": "<image url>",
"status": "Draft",
"_id": "5dc8330acb35b84d6bf79587",
"title": "lagii",
"content": "lagii2",
"author": "5dc7f8e3258e6a284fc2c696",
"createdAt": "2019-11-10T15:55:54.085Z",
"updatedAt": "2019-11-10T15:55:54.085Z"
}
}
```
* Error Response
Status : 401
content :
```
{
"message": "Data not exists / You trying to access data that you don't have permission on"
}
```
---
4 changes: 4 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
.env
.cache
dist
11 changes: 11 additions & 0 deletions client/credentials (1).json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"web": {
"client_id": "744731547758-dcm687eda4snbuuahsq4r5rnfcic4cip.apps.googleusercontent.com",
"project_id": "myminiwp-1573371163026",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "WJyOxC42NmAVy2b9Ojt6Z87Q",
"javascript_origins": ["http://localhost:1234"]
}
}
17 changes: 17 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://kit.fontawesome.com/eb0f5f8ed5.js" crossorigin="anonymous"></script>
<title>My Mini-WP</title>
</head>

<body>
<div id="app"></div>
<script src="./src/main.js"></script>
</body>

</html>
Loading