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

Bayu Oktari #11

Open
wants to merge 11 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
321 changes: 320 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,320 @@
# hacktivoverflow
# hacktivoverflow

#### Getting Started

Welcome to HacktivOverflow API Documentation, You can use the API to access HacktivOverflow API endpoints.

First of All you need some dependencies

```
//install some core application
$ sudo apt-get install nodejs
$ sudo apt-get install npm
$ sudo apt-get install redis-server

//install dependencies
$ npm install

//running the server
$ npm run dev
```

All API can be accessed from the `http://localhost:3000`

To Use API Endpoints, the format is as follows:

`http://localhost:3000/{resource}`

### Users Login & Register

------

##### POST `/users/register/`

```
url:'http://localhost:3000/users/',
method:'POST',
body:{
'name' : 'Your Full Name',
'username' : 'yourusername',
'email': [email protected],
'password' : 'yoursuperpassword'
}

response:{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVlMzJkOWNkZTg4NzU5MjI3Yjc2YjQwZCIsInVzZXJuYW1lIjoidXNlcnRlc3Rkb2MiLCJpYXQiOjE1ODAzOTA4NjF9.BQy_CFlWbEN3_HR9i2hiYnledD2ojH3YPFmp7iHj36Q",
"id": "5e32d9cde88759227b76b40d"
}
```

##### POST `/users/login/`

```
url:'http://localhost:3000/users/',
method:'POST',
body:{
'email': [email protected],
'password' : 'yoursuperpassword'
}

response:{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVlMzJkOWNkZTg4NzU5MjI3Yjc2YjQwZCIsInVzZXJuYW1lIjoidXNlcnRlc3Rkb2MiLCJpYXQiOjE1ODAzOTA4NjF9.BQy_CFlWbEN3_HR9i2hiYnledD2ojH3YPFmp7iHj36Q",
"id": "5e32d9cde88759227b76b40d"
}

```

### QUESTION

------

##### GET `/questions/`

```
url:'http://localhost:3000/questions',
method:'GET'

response:[
{
"upvote": [],
"downvote": [],
"_id": "5e32b78ce88759227b76b40b",
"userId": {
"_id": "5e32b691e88759227b76b40a",
"username": "yourusername"
},
"title": "Your Question",
"description": "<p>Your Description with WYSIWIG</p>",
"__v": 0
},
....
]
```

##### GET `/questions/{id}`

```
url:'http://localhost:3000/questions/5e33068be88759227b76b411'
method: 'GET'

response :{
"upvote": [],
"downvote": [],
"_id": "5e33068be88759227b76b411",
"userId": "5e32c9b6e88759227b76b40c",
"title": "Your Question Detail",
"description": "Your Question Description",
"__v": 0
}
```

##### POST `/questions/`

```
url:'http://localhost:3000/questions/',
method:'POST',
headers:{
token:{token}
},
body:{
'title':'Your Question Title',
'description':'<p>Your Description with WYSIWIG</p>'
}

response:{
"upvote": [],
"downvote": [],
"_id": "5e33068be88759227b76b411",
"userId": "5e32c9b6e88759227b76b40c",
"title": "Your Question Detail",
"description": "Your Question Description",
"__v": 0
}
```

##### PUT `/question/{id}`

```
url:'http://localhost:3000/questions/5e33068be88759227b76b411'
method:'PUT',
headers:{
token:{token}
},
body:{
'title':'Your Edited Title',
'description':'<p>Your Edited Description</p>'
}

response :{
"message": "Question Updated"
}
```

##### DELETE `/question/{id}`

```
url:'http://localhost:3000/questions/5e33068be88759227b76b411'
method:'DELETE'
headers:{
token:{token}
}

response: {
"message": "Question Deleted"
}
```



### ANSWER

------

##### GET `/answers/`

```
url:'http://localhost:3000/answers/'
method:'GET',

response : [
{
"upvote": [],
"downvote": [],
"_id": "5e330892e88759227b76b413",
"description": "<p>Your Answer Description/p>",
"questionId": "5e32b06de2097511f6af3f48",
"userId": "5e330877e88759227b76b412",
"__v": 0
},
....
]
```

##### GET `/answers/{questionId}`

```
url:'http://localhost:3000/answers/5e330892e88759227b76b413'
method:'GET',

response:[
{
"upvote": [],
"downvote": [],
"_id": "5e330892e88759227b76b413",
"description": "<p>Your Answer Description/p>",
"questionId": "5e32b06de2097511f6af3f48",
"userId": "5e330877e88759227b76b412",
"__v": 0
},
....
]
```

##### POST `/answers/`

```
url:'http://localhost:3000/answers/'
method:'POST',
headers:{
token:{token}
},
body:{
description:'<p>Your Answer Description</p>'
questionId:'5e32b06de2097511f6af3f48'
}

response:{
"upvote": [],
"downvote": [],
"_id": "5e330d04e88759227b76b417",
"description": "Your Answer",
"questionId": "5e32b06de2097511f6af3f48",
"userId": "5e32c9b6e88759227b76b40c",
"__v": 0
}
```

##### PUT `/answers/{id}`

```
url:'http://localhost:3000/answers/5e330d04e88759227b76b417'
method:'POST',
headers:{
token:{token}
},
body:{
description:'<p>Your Answer Description</p>'
}

response:{
"message": "Answer Edited"
}
```



### ERROR HANDLING

------


- Validation Login

```
Status Code : 400

response : {
message: "Email / Password Wrong"
}
```

- Not Found

```
Status Code : 404

response:{
message:"Item Not Found"
}
```

- Token Validation

```
Status Code : 400

response:{
message:"Invalid Token"
}
```

- Unauthorized

```
Status Code : 401

response:{
message:"Authentication Required"
}
```

- Validation Error

```
Status Code : 400

response:{
message:"Invalid Email Format"
}
```

- Internal Server Error

```
Status Code : 500

response:{
message:"Internal Server Error"
}
```

2 changes: 2 additions & 0 deletions client/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
> 1%
last 2 versions
5 changes: 5 additions & 0 deletions client/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
15 changes: 15 additions & 0 deletions client/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
root: true,
env: {
node: true
},
extends: ['plugin:vue/essential', '@vue/standard'],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'space-before-function-paren': ['error', 'never']
},
parserOptions: {
parser: 'babel-eslint'
}
}
21 changes: 21 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.DS_Store
node_modules
/dist

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
4 changes: 4 additions & 0 deletions client/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"semi": false
}
24 changes: 24 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# client

## Project setup
```
npm install
```

### Compiles and hot-reloads for development
```
npm run serve
```

### Compiles and minifies for production
```
npm run build
```

### Lints and fixes files
```
npm run lint
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
Loading