first commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
node_modules
|
||||||
84
data/todos.json
Normal file
84
data/todos.json
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
{
|
||||||
|
"todos": {
|
||||||
|
"lists": {
|
||||||
|
"pending": {
|
||||||
|
"displayName": "Pending",
|
||||||
|
"id": "list_pending",
|
||||||
|
"cards": [
|
||||||
|
{
|
||||||
|
"title": "TODO 4",
|
||||||
|
"description": "Description 4",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 7",
|
||||||
|
"description": "Description 7",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 8",
|
||||||
|
"description": "Description 8",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 10",
|
||||||
|
"description": "Description 10",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 11",
|
||||||
|
"description": "Description 11",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 13",
|
||||||
|
"description": "Description 13",
|
||||||
|
"activity": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"inprogress": {
|
||||||
|
"displayName": "In Progress",
|
||||||
|
"id": "list_inprogress",
|
||||||
|
"cards": [
|
||||||
|
{
|
||||||
|
"title": "TODO 1",
|
||||||
|
"description": "Description 1",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 2",
|
||||||
|
"description": "Description 2",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 3",
|
||||||
|
"description": "Description 3",
|
||||||
|
"activity": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"completed": {
|
||||||
|
"displayName": "Completed",
|
||||||
|
"id": "list_completed",
|
||||||
|
"cards": [
|
||||||
|
{
|
||||||
|
"title": "TODO 6",
|
||||||
|
"description": "Description 1",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 9",
|
||||||
|
"description": "Description 2",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 5",
|
||||||
|
"description": "Description 3",
|
||||||
|
"activity": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
145
data/todos_old.json
Normal file
145
data/todos_old.json
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"img_url": "https://guesseu.scene7.com/is/image/GuessEU/M63H24W7JF0-L302-ALTGHOST?wid=1500&fmt=jpeg&qlt=80&op_sharpen=0&op_usm=1.0,1.0,5,0&iccEmbed=0",
|
||||||
|
"name": "CHECK PRINT SHIRT - 2",
|
||||||
|
"id": "product-111",
|
||||||
|
"category": "Clothing",
|
||||||
|
"price": {
|
||||||
|
"display": 900,
|
||||||
|
"actual": 324
|
||||||
|
},
|
||||||
|
"discount": 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"img_url": "https://guesseu.scene7.com/is/image/GuessEU/AW6308VIS03-SAP?wid=700&fmt=jpeg&qlt=80&op_sharpen=0&op_usm=1.0,1.0,5,0&iccEmbed=0",
|
||||||
|
"name": "'70s RETRO GLAM KEFIAH - 3",
|
||||||
|
"id": "product-112",
|
||||||
|
"category": "Clothing",
|
||||||
|
"price": {
|
||||||
|
"display": 2084,
|
||||||
|
"actual": 324
|
||||||
|
},
|
||||||
|
"discount": 24
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"img_url": "https://guesseu.scene7.com/is/image/GuessEU/FLGLO4FAL12-BEIBR?wid=700&fmt=jpeg&qlt=80&op_sharpen=0&op_usm=1.0,1.0,5,0&iccEmbed=0",
|
||||||
|
"name": "GLORIA HIGH LOGO SNEAKER - 1",
|
||||||
|
"id": "product-113",
|
||||||
|
"category": "Footwear",
|
||||||
|
"price": {
|
||||||
|
"display": 650,
|
||||||
|
"actual": 324
|
||||||
|
},
|
||||||
|
"discount": 64
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"img_url": "https://guesseu.scene7.com/is/image/GuessEU/AW6308VIS03-SAP?wid=700&fmt=jpeg&qlt=80&op_sharpen=0&op_usm=1.0,1.0,5,0&iccEmbed=0",
|
||||||
|
"name": "'70s RETRO GLAM KEFIAH - 4",
|
||||||
|
"id": "product-114",
|
||||||
|
"category": "Clothing",
|
||||||
|
"price": {
|
||||||
|
"display": 3284,
|
||||||
|
"actual": 324
|
||||||
|
},
|
||||||
|
"discount": 80
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"img_url": "https://guesseu.scene7.com/is/image/GuessEU/HWVG6216060-TAN?wid=700&fmt=jpeg&qlt=80&op_sharpen=0&op_usm=1.0,1.0,5,0&iccEmbed=0",
|
||||||
|
"name": "CATE RIGID BAG - 1",
|
||||||
|
"id": "product-115",
|
||||||
|
"category": "Accessories",
|
||||||
|
"price": {
|
||||||
|
"display": 1838,
|
||||||
|
"actual": 324
|
||||||
|
},
|
||||||
|
"discount": 45
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"img_url": "https://guesseu.scene7.com/is/image/GuessEU/AW6308VIS03-SAP?wid=700&fmt=jpeg&qlt=80&op_sharpen=0&op_usm=1.0,1.0,5,0&iccEmbed=0",
|
||||||
|
"name": "'70s RETRO GLAM KEFIAH - 6",
|
||||||
|
"id": "product-116",
|
||||||
|
"category": "Clothing",
|
||||||
|
"price": {
|
||||||
|
"display": 8884,
|
||||||
|
"actual": 324
|
||||||
|
},
|
||||||
|
"discount": 38
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"img_url": "http://guesseu.scene7.com/is/image/GuessEU/WC0001FMSWC-G5?wid=520&fmt=jpeg&qlt=80&op_sharpen=0&op_usm=1.0,1.0,5,0&iccEmbed=0",
|
||||||
|
"name": "GUESS CONNECT WATCH - 1",
|
||||||
|
"id": "product-117",
|
||||||
|
"category": "Electronics",
|
||||||
|
"price": {
|
||||||
|
"display": 290,
|
||||||
|
"actual": 324
|
||||||
|
},
|
||||||
|
"discount": 22
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"img_url": "https://guesseu.scene7.com/is/image/GuessEU/AW6308VIS03-SAP?wid=700&fmt=jpeg&qlt=80&op_sharpen=0&op_usm=1.0,1.0,5,0&iccEmbed=0",
|
||||||
|
"name": "'70s RETRO GLAM KEFIAH - 1",
|
||||||
|
"id": "product-118",
|
||||||
|
"category": "Clothing",
|
||||||
|
"price": {
|
||||||
|
"display": 1284,
|
||||||
|
"actual": 324
|
||||||
|
},
|
||||||
|
"discount": 52
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"img_url": "https://guesseu.scene7.com/is/image/GuessEU/M63H24W7JF0-L302-ALTGHOST?wid=1500&fmt=jpeg&qlt=80&op_sharpen=0&op_usm=1.0,1.0,5,0&iccEmbed=0",
|
||||||
|
"name": "CHECK PRINT SHIRT - 1",
|
||||||
|
"id": "product-119",
|
||||||
|
"category": "Clothing",
|
||||||
|
"price": {
|
||||||
|
"display": 900,
|
||||||
|
"actual": 324
|
||||||
|
},
|
||||||
|
"discount": 19
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"img_url": "https://guesseu.scene7.com/is/image/GuessEU/AW6308VIS03-SAP?wid=700&fmt=jpeg&qlt=80&op_sharpen=0&op_usm=1.0,1.0,5,0&iccEmbed=0",
|
||||||
|
"name": "'70s RETRO GLAM KEFIAH - 2",
|
||||||
|
"id": "product-120",
|
||||||
|
"category": "Clothing",
|
||||||
|
"price": {
|
||||||
|
"display": 584,
|
||||||
|
"actual": 324
|
||||||
|
},
|
||||||
|
"discount": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"img_url": "https://guesseu.scene7.com/is/image/GuessEU/AW6308VIS03-SAP?wid=700&fmt=jpeg&qlt=80&op_sharpen=0&op_usm=1.0,1.0,5,0&iccEmbed=0",
|
||||||
|
"name": "'70s RETRO GLAM KEFIAH - 5",
|
||||||
|
"id": "product-121",
|
||||||
|
"category": "Clothing",
|
||||||
|
"price": {
|
||||||
|
"display": 984,
|
||||||
|
"actual": 324
|
||||||
|
},
|
||||||
|
"discount": 60
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"img_url": "https://guesseu.scene7.com/is/image/GuessEU/FLGLO4FAL12-BEIBR?wid=700&fmt=jpeg&qlt=80&op_sharpen=0&op_usm=1.0,1.0,5,0&iccEmbed=0",
|
||||||
|
"name": "GLORIA HIGH LOGO SNEAKER - 1",
|
||||||
|
"id": "product-122",
|
||||||
|
"category": "Footwear",
|
||||||
|
"price": {
|
||||||
|
"display": 6650,
|
||||||
|
"actual": 324
|
||||||
|
},
|
||||||
|
"discount": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"img_url": "https://guesseu.scene7.com/is/image/GuessEU/HWVG6216060-TAN?wid=700&fmt=jpeg&qlt=80&op_sharpen=0&op_usm=1.0,1.0,5,0&iccEmbed=0",
|
||||||
|
"name": "CATE RIGID BAG - 2",
|
||||||
|
"id": "product-123",
|
||||||
|
"category": "Accessories",
|
||||||
|
"price": {
|
||||||
|
"display": 838,
|
||||||
|
"actual": 324
|
||||||
|
},
|
||||||
|
"discount": 20
|
||||||
|
}
|
||||||
|
]
|
||||||
116
data/todos_save.json
Normal file
116
data/todos_save.json
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
{
|
||||||
|
"todos": {
|
||||||
|
"lists": {
|
||||||
|
"pending": {
|
||||||
|
"displayName": "Pending",
|
||||||
|
"id": "list_pending",
|
||||||
|
"cards": [
|
||||||
|
{
|
||||||
|
"title": "TODO 4",
|
||||||
|
"description": "Description 4",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 7",
|
||||||
|
"description": "Description 7",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 8",
|
||||||
|
"description": "Description 8",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 10",
|
||||||
|
"description": "Description 10",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 11",
|
||||||
|
"description": "Description 11",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 13",
|
||||||
|
"description": "Description 13",
|
||||||
|
"activity": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"inprogress": {
|
||||||
|
"displayName": "In Progress",
|
||||||
|
"id": "list_inprogress",
|
||||||
|
"cards": [
|
||||||
|
{
|
||||||
|
"title": "TODO 1",
|
||||||
|
"description": "Description 1",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 2",
|
||||||
|
"description": "Description 2",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 3",
|
||||||
|
"description": "Description 3",
|
||||||
|
"activity": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"completed": {
|
||||||
|
"displayName": "Completed",
|
||||||
|
"id": "list_completed",
|
||||||
|
"cards": [
|
||||||
|
{
|
||||||
|
"title": "TODO 6",
|
||||||
|
"description": "Description 1",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 9",
|
||||||
|
"description": "Description 2",
|
||||||
|
"activity": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 5",
|
||||||
|
"description": "Description 3",
|
||||||
|
"activity": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"list_inprogress": [
|
||||||
|
{
|
||||||
|
"title": "TODO 13",
|
||||||
|
"description": "Description 13",
|
||||||
|
"activity": [],
|
||||||
|
"id": "c-Card-list_inprogress-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 11",
|
||||||
|
"description": "Description 11",
|
||||||
|
"activity": [],
|
||||||
|
"id": "c-Card-list_inprogress-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 8",
|
||||||
|
"description": "Description 8",
|
||||||
|
"activity": [],
|
||||||
|
"id": "c-Card-list_inprogress-2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 1",
|
||||||
|
"description": "Description 1",
|
||||||
|
"activity": [],
|
||||||
|
"id": "c-Card-list_inprogress-3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "TODO 5",
|
||||||
|
"description": "Description 3",
|
||||||
|
"activity": [],
|
||||||
|
"id": "c-Card-list_inprogress-4"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
45
index.js
Normal file
45
index.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const express = require('express');
|
||||||
|
const bodyParser = require('body-parser');
|
||||||
|
const cors = require('cors')
|
||||||
|
|
||||||
|
var corsOptions = {origin: '*', optionsSuccessStatus: 200,}
|
||||||
|
const app = express();
|
||||||
|
app.use(cors(corsOptions))
|
||||||
|
app.use(bodyParser.json());
|
||||||
|
|
||||||
|
app.get('/todos', (req, res) => {
|
||||||
|
fs.readFile("data/todos.json", "utf8", function(err, data) {
|
||||||
|
if (err) {
|
||||||
|
// console.log(err)
|
||||||
|
return res.json(err);
|
||||||
|
}
|
||||||
|
// console.log(data)
|
||||||
|
return res.json(data)
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
app.post('/todos', (req, res) => {
|
||||||
|
fs.readFile("data/todos.json", "utf8", function(err, data) {
|
||||||
|
if (err) {
|
||||||
|
return res.json(err);
|
||||||
|
} else {
|
||||||
|
let mainDataAsJson = JSON.parse(data)
|
||||||
|
const jsonData = req.body
|
||||||
|
const key = Object.keys(jsonData)[0]
|
||||||
|
const dataCards = mainDataAsJson.todos.lists
|
||||||
|
dataCards[key] = jsonData[key]
|
||||||
|
fs.writeFile("data/todos_save.json", JSON.stringify(mainDataAsJson, null, 4), function(err, data) {
|
||||||
|
if (err) {
|
||||||
|
return res.json(err);
|
||||||
|
}
|
||||||
|
return res.json(jsonData)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
app.listen(3001, () => {
|
||||||
|
console.log("App running on the port 3001");
|
||||||
|
})
|
||||||
3308
package-lock.json
generated
Normal file
3308
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
30
package.json
Normal file
30
package.json
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"name": "subset_trello_backend",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Server to save and retrieve TODO lists",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node-env-run --exec nodemon | pino-colada",
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "mohiit1502",
|
||||||
|
"license": "ISC",
|
||||||
|
"babel": {
|
||||||
|
"presets": [
|
||||||
|
"@babel/env",
|
||||||
|
"@babel/react"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"body-parser": "^1.19.0",
|
||||||
|
"cors": "^2.8.5",
|
||||||
|
"express": "^4.17.1",
|
||||||
|
"dotenv": "^8.2.0",
|
||||||
|
"formidable": "^1.2.1",
|
||||||
|
"mongoose": "^5.7.8",
|
||||||
|
"multer": "^1.4.2",
|
||||||
|
"pino-colada": "^1.4.5",
|
||||||
|
"node-env-run": "^3.0.2",
|
||||||
|
"nodemon": "^1.19.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user