Skip to content

Commit

Permalink
server codes added
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhoseinZare committed Jun 17, 2021
1 parent b0d343a commit af2978d
Show file tree
Hide file tree
Showing 8 changed files with 4,945 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
uploads
198 changes: 198 additions & 0 deletions backend/Maktab47 Exercise Upload.postman_collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
{
"info": {
"_postman_id": "16c3a187-0e3d-41d4-8704-b2cfa744e0f0",
"name": "Maktab47 Exercise Upload",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Test Upload",
"item": [
{
"name": "Upload Only",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "image",
"type": "file",
"src": "/C:/Users/Babak/Desktop/Desktop/thumbnail.jpg"
}
]
},
"url": {
"raw": "{{SERVER}}/upload",
"host": [
"{{SERVER}}"
],
"path": [
"upload"
]
}
},
"response": []
},
{
"name": "List of Files",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{SERVER}}/files",
"host": [
"{{SERVER}}"
],
"path": [
"files"
]
}
},
"response": []
}
]
},
{
"name": "Products",
"item": [
{
"name": "Create [JSON]",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\r\n \"name\": \"surface pro laptop\",\r\n \"brand\": \"microsoft\",\r\n \"image\": \"/files/65ddd8b1bbce4d8396b62611147fa1d6\",\r\n \"price\": \"1500\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{SERVER}}/products",
"host": [
"{{SERVER}}"
],
"path": [
"products"
]
}
},
"response": []
},
{
"name": "Upload & Create [FormData]",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "name",
"value": "surface pro laptop",
"type": "text"
},
{
"key": "brand",
"value": "microsoft",
"type": "text"
},
{
"key": "image",
"type": "file",
"src": "/C:/Users/Babak/Desktop/Desktop/thumbnail.jpg"
},
{
"key": "price",
"value": "1500",
"type": "text"
}
]
},
"url": {
"raw": "{{SERVER}}/products",
"host": [
"{{SERVER}}"
],
"path": [
"products"
]
}
},
"response": []
},
{
"name": "List",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{SERVER}}/products",
"host": [
"{{SERVER}}"
],
"path": [
"products"
]
}
},
"response": []
}
]
},
{
"name": "Download a File",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{SERVER}}/files/:file_id",
"host": [
"{{SERVER}}"
],
"path": [
"files",
":file_id"
],
"variable": [
{
"key": "file_id",
"value": ""
}
]
}
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"key": "SERVER",
"value": "http://localhost:3000"
}
]
}
20 changes: 20 additions & 0 deletions backend/db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"products": [
{
"name": "asus laptop",
"brand": "asus",
"image": "/files/3d545729eb7cdb3f85407805ec160740",
"price": "1000",
"createdAt": 1622901942857,
"id": 1
},
{
"name": "apple laptop",
"brand": "apple",
"image": "/files/65ddd8b1bbce4d8396b62611147fa1d6",
"price": "2000",
"createdAt": 1622901942857,
"id": 2
}
]
}
Loading

0 comments on commit af2978d

Please sign in to comment.