Skip to content
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
npm-debug.log
.DS_Store
.env
dist
.cache
284 changes: 282 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,282 @@
# ecommerce-cms
Membuat website untuk management content ecommerce ( dipakai oleh admin)
## E-Commerce CMS
E-Commerce CMS is an server-side / admin-side application to manage E-Commerce client-side. This app has:

RESTful endpoint for Product CRUD Operation
Used Technology :
*Express Js,
*Sequelize,
*Postgres,
*Jest (JS Testing Framework)
*Json Web Token,
*Bcrypt
*JSON Formated Response

## RESTful endpoints

### Global Response
_Response (500 - Error)_
```
{
"message": "Internal Server Error"
}
```
Response (401 - Unauthorized)
```
{
"message": "Not authroized to do the actions"
}
```
### GET /products
_Request Header_
```
{
"token": "<your access token>"
}
```

_Request Body_
```
not needed
```
_Response (200)_
```
[
{
"id": 1,
"name": "<product name>",
"image_url": "<url_img>",
"price": "<product price>",
"stock": "<product stock>",
"createdAt": "2020-03-20T07:15:12.149Z",
"updatedAt": "2020-03-20T07:15:12.149Z",
},
{
"id": 2,
"name": "<product name>",
"image_url": "<url_img>",
"price": "<product price>",
"stock": "<product stock>",
"createdAt": "2020-03-20T07:15:12.149Z",
"updatedAt": "2020-03-20T07:15:12.149Z",
}, ...
]
```
_Response (400)_
```
{
"message": "Bad Request"
}
```

### GET /products/:id
_Request Header_
```
{
"token": "<your access token>"
}
```

_Request Body_
```
not needed
```
_Response (200)_
```
{
"id": 1,
"name": "<product name>",
"image_url": "<url_img>",
"price": "<product price>",
"stock": "<product stock>",
"createdAt": "2020-03-20T07:15:12.149Z",
"updatedAt": "2020-03-20T07:15:12.149Z",
}
```
_Response (404 - Not Found)_
```
{
"message": "product not found"
}
```
### POST /products

_Request Header_
```
{
"token": "<your access token>"
}
```

_Request Body_
```
{
"name": "<product name to get insert into>",
"image_url": "<product_url_img to get insert into>",
"price": "<product price to get insert into>",
"stock": "<product stock to get insert into>"
}
```
_Response (201 - Created)_
```
{
"id": <given id by system>,
"name": "<posted product name>",
"image_url": "<posted url_img>",
"price": "<posted product price>",
"stock": "<posted product stock>",
"createdAt": "2020-03-20T07:15:12.149Z",
"updatedAt": "2020-03-20T07:15:12.149Z",
}
```
_Response (400 - Bad Request)_
```
{
"message": "name cannot be empty!" || image_url cannot be empty! || price cannot be empty! || stock cannot be empty!
}
```

### PUT /products/:id

_Request Header_
```
{
"token": "<your access token>"
}
```
_Request Body_
```
{
"name": "<product name to get insert into>",
"image_url": "<product_url_img to get insert into>",
"price": "<product price to get insert into>",
"stock": "<product stock to get insert into>"
}
```

_Response (200)_
```
{
"name": "<posted name to get insert into>",
"image_url": "<posted_url_img to get insert into>",
"price": "<posted price to get insert into>",
"stock": "<posted stock to get insert into>"
}
```
_Response (400 - Bad Request)_
```
{
"message": "name cannot be empty!" || image_url cannot be empty! || price cannot be empty! || stock cannot be empty!
}
```
_Response (404 - Not Found)_
```
{
"message": "product not found"
}
```

### DELETE /products/:id

_Request Header_
```
{
"token": "<your access token>"
}
```
_Request Body_
```
not needed
```
_Response (200 - DELETED)_
```
{
"id": 1,
"name": "<deleted product name>",
"image_url": "<deleted url_img>",
"price": "<deleted product price>",
"stock": "<deleted product stock>"
}
```


_Response (404 - Not Found)_
```
{
"message": "product not found"
}
```

### POST /login
_Request Header_
```
Not needed
```
_Request Body_
```
"email": "<[email protected]>",
"password": "<admin>"
```
_Response (200)_
```
"<access_token>": "hashed token"
```
_Response (404)_
```
{
"message": "email cannot be empty" || "password cannot be empty"
}
```


### POST /register
_Request Header_
```
Not needed
```
_Request Body_
```
"email": "<[email protected]>",
"password": "<admin>",
"role": "admin"
```
_Response (201)_
```
{
"id": "<id given by system>",
"email": "[email protected]",
"password": "admin",
"role": "admin",
"updatedAt": "<contain updatedAt result register>",
"createdAt": "<contain createdAt result register>"
}
```
_Response (404)_
```
{
"message": "data not found"
}
```

### POST /googleSignIn
_Request Header_
```
Not Needed
```
_Request Body_
```
{
"id_token" : "<id_token from google>"
}
```
_Response (200)_
```
{
"access_token": "<access_token JWT>"
}
```
_Response (404 - Not Found)_
```
{
"message": "data not found"
}
```
3 changes: 3 additions & 0 deletions client/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> 1%
last 2 versions
not dead
7 changes: 7 additions & 0 deletions client/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 100
17 changes: 17 additions & 0 deletions client/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
root: true,
env: {
node: true,
},
extends: [
'plugin:vue/essential',
'@vue/airbnb',
],
parserOptions: {
parser: 'babel-eslint',
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
},
};
9 changes: 9 additions & 0 deletions client/.firebase/hosting.ZGlzdA.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
index.html,1598139829472,e8eec2d1e6e62af881ea1fe5dabf4f3cae14fcb5343aa43ebbaf11bd388539be
favicon.ico,1598139829472,d5451f0f0f0bcbcd433bbdf4f6e7e5d89d8ecce2650649e969ccb5e5cd499ab2
js/about.91c824e1.js,1598139829472,6d6de725c3d8ede92c9ac0da2744ba10ad16c44ba60139a22cfe8284b968289b
css/app.292cdaa9.css,1598139829472,84d4383a583e2b49ac0e83d7dc1e8e59245cc0ed29ac4473e644f440271761ac
js/about.91c824e1.js.map,1598139829541,342f8580d7d2333bbd92aa940aec2c8d64c7c5f0df609fb6729afd50bd9c8139
js/app.62b86dc8.js,1598139829541,11426927c988520248564c80b99a7288df6906edeb39764a2821f5a6de298920
js/app.62b86dc8.js.map,1598139829541,552eba147a6d0004b88639feda45bc96cf68a1c14c73c1d290e80df93d4d4b72
js/chunk-vendors.06109c99.js,1598139829475,5bb8fb1b747e00f9da43d901351765c09d0aece4ee8b808d4fc1ac14923b01f7
js/chunk-vendors.06109c99.js.map,1598139829542,ea798c490b809abab332cb7148e1a78d301f02b22acbe936d66fe85502435be6
5 changes: 5 additions & 0 deletions client/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "e-commerce-cms-eb7aa"
}
}
23 changes: 23 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist


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

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

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
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/).
5 changes: 5 additions & 0 deletions client/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset',
],
};
Loading