├── .gitignore
├── LICENSE
├── README.md
├── Routes
├── donation_amount.js
├── donation_data.js
└── noneprofit.js
├── csv
├── donation.csv
└── nonprofit_data.csv
├── package-lock.json
├── package.json
└── server.js
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | lerna-debug.log*
8 |
9 | # Diagnostic reports (https://nodejs.org/api/report.html)
10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11 |
12 | # Runtime data
13 | pids
14 | *.pid
15 | *.seed
16 | *.pid.lock
17 |
18 | # Directory for instrumented libs generated by jscoverage/JSCover
19 | lib-cov
20 |
21 | # Coverage directory used by tools like istanbul
22 | coverage
23 | *.lcov
24 |
25 | # nyc test coverage
26 | .nyc_output
27 |
28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29 | .grunt
30 |
31 | # Bower dependency directory (https://bower.io/)
32 | bower_components
33 |
34 | # node-waf configuration
35 | .lock-wscript
36 |
37 | # Compiled binary addons (https://nodejs.org/api/addons.html)
38 | build/Release
39 |
40 | # Dependency directories
41 | node_modules/
42 | jspm_packages/
43 |
44 | # TypeScript v1 declaration files
45 | typings/
46 |
47 | # TypeScript cache
48 | *.tsbuildinfo
49 |
50 | # Optional npm cache directory
51 | .npm
52 |
53 | # Optional eslint cache
54 | .eslintcache
55 |
56 | # Microbundle cache
57 | .rpt2_cache/
58 | .rts2_cache_cjs/
59 | .rts2_cache_es/
60 | .rts2_cache_umd/
61 |
62 | # Optional REPL history
63 | .node_repl_history
64 |
65 | # Output of 'npm pack'
66 | *.tgz
67 |
68 | # Yarn Integrity file
69 | .yarn-integrity
70 |
71 | # dotenv environment variables file
72 | .env
73 | .env.test
74 |
75 | # parcel-bundler cache (https://parceljs.org/)
76 | .cache
77 |
78 | # Next.js build output
79 | .next
80 |
81 | # Nuxt.js build / generate output
82 | .nuxt
83 | dist
84 |
85 | # Gatsby files
86 | .cache/
87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js
88 | # https://nextjs.org/blog/next-9-1#public-directory-support
89 | # public
90 |
91 | # vuepress build output
92 | .vuepress/dist
93 |
94 | # Serverless directories
95 | .serverless/
96 |
97 | # FuseBox cache
98 | .fusebox/
99 |
100 | # DynamoDB Local files
101 | .dynamodb/
102 |
103 | # TernJS port file
104 | .tern-port
105 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Anand
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GiveIndia-backend Description
2 |
3 | In this project, user can upload the csv file as well as he/she can select the base currency, Now app parse the csv data and validate the each format for each row [Date,Order Id,Nonprofit,Donation Currency,Donation Amount]
4 | App converts all donation amount into the user-selected base currency
5 | App groups the donations according to nonprofit and return the data on nonprofit_data.csv file.
6 |
7 | ## Requirements
8 |
9 | If you're using Linux-based OS, install the latest version of Nodejs and npm, by typing the following commands on your terminal.
10 |
11 | ```
12 | sudo apt update
13 | sudo apt install build-essential apt-transport-https lsb-release ca-certificates curl
14 |
15 | ```
16 | Then, for the **Latest** release (version 13), add this PPA, by typing the following command on your terminal
17 |
18 | ```
19 | curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
20 | sudo apt install nodejs
21 |
22 | ```
23 | Now, you need to install necessary dependencies using npm (node-package-manager), open your termial, and first type
24 | `npm init` to initialize **package.json** file. Then, type
25 |
26 | ```
27 | npm install express
28 | npm install axios
29 | npm install body-parser
30 |
31 | ```
32 |
--------------------------------------------------------------------------------
/Routes/donation_amount.js:
--------------------------------------------------------------------------------
1 | module.exports = (app, axios, csv) => {
2 | app.put("/convert_amount/:base", (req, res) => {
3 | let base = req.params.base;
4 | axios.get('https://api.exchangeratesapi.io/latest?base=' + base)
5 | .then((data) => {
6 | // var alldata = CircularJSON.stringify(data.data.rates);
7 | var alldata = (data.data.rates)
8 | // console.log(alldata);
9 | csv().fromFile('./csv/donation.csv')
10 | .then((data) => {
11 | // res.send(data);
12 | for (var i of data){
13 | var Donation_Currency = i.DONATION_CURRENCY;
14 | for (var [key, value] of Object.entries(alldata)){
15 | if (Donation_Currency == key){
16 | if(value<0){
17 | i.DONATION_AMOUNT = i.DONATION_AMOUNT*value +" "+ base
18 | // console.log(i.DONATION_AMOUNT);
19 | }else{
20 | i.DONATION_AMOUNT = i.DONATION_AMOUNT/value +" "+ base
21 | // console.log(i.DONATION_AMOUNT)
22 | }
23 | }
24 | }
25 | }
26 | console.log(data);
27 | res.send(data);
28 | }).catch((err) => {
29 | console.log(err);
30 | })
31 | }).catch((err) => {
32 | console.log(err);
33 | })
34 | })
35 | }
36 |
--------------------------------------------------------------------------------
/Routes/donation_data.js:
--------------------------------------------------------------------------------
1 | module.exports = (app, axios, mydate, createCsvWriter) => {
2 | var newArr = [];
3 | app.post("/donates", (req, res) => {
4 | var text = "DE12";
5 | var char_list = "1234567890abcdefghijklmnopqrstuvwxyz";
6 | for (var i = 0; i < 11; i++) {
7 | text += char_list.charAt(Math.floor(Math.random() * char_list.length));
8 | }
9 |
10 | let dict = {
11 | Date: mydate(),
12 | Nonprofit: req.body.Nonprofit,
13 | Donation_Currency: req.body.Donation_Currency,
14 | Donation_Amount: req.body.Donation_Amount,
15 | order_id: text
16 | };
17 | // res.send(data);
18 | var csvWriter = createCsvWriter({
19 | path: "./csv/donation.csv",
20 | header: [
21 | { id: "Date", title: "DATE" },
22 | { id: "Nonprofit", title: "NONPROFIT" },
23 | { id: "Donation_Currency", title: "DONATION_CURRENCY" },
24 | { id: "Donation_Amount", title: "DONATION_AMOUNT" }
25 | ]
26 | });
27 | // dict data pushing in a newArr.
28 | newArr.push(dict);
29 | csvWriter
30 | .writeRecords(newArr)
31 | .then(() => {
32 | console.log("Data inserted in CSV file!");
33 | res.send({ Success: "data inserted in CSV file!" });
34 | })
35 | .catch((err) => {
36 | console.log(err);
37 | })
38 | });
39 | };
40 |
--------------------------------------------------------------------------------
/Routes/noneprofit.js:
--------------------------------------------------------------------------------
1 | module.exports = (app, axios, csv, createCsvWriter) => {
2 | var NonprofitArr = [];
3 | app.get("/nonprofit/USD", (req, res) => {
4 | var base = "USD";
5 | axios
6 | .get("https://api.exchangeratesapi.io/latest?base=" + base)
7 | .then(data => {
8 | var alldata = data.data.rates;
9 | // console.log(alldata);
10 | csv()
11 | .fromFile("./csv/donation.csv")
12 | .then(data => {
13 | // res.send(data);
14 | for (var i of data) {
15 | var Donation_Currency = i.DONATION_CURRENCY;
16 | for (var [key, value] of Object.entries(alldata)) {
17 | if (Donation_Currency == key) {
18 | if (value < 0) {
19 | i.DONATION_AMOUNT = i.DONATION_AMOUNT * value;
20 | } else {
21 | i.DONATION_AMOUNT = i.DONATION_AMOUNT / value;
22 | }
23 | }
24 | }
25 | }
26 | // res.send(data);
27 | var Nonprofit_names_data = [];
28 | for (var j of data) {
29 | var count_number = 0;
30 | if (!Nonprofit_names_data.includes(j.NONPROFIT)) {
31 | Nonprofit_names_data.push(j.NONPROFIT);
32 | // console.log(Nonprofit_names_data);
33 | for (var k of data) {
34 | if (j.NONPROFIT == k.NONPROFIT) {
35 | if (count_number > 0) {
36 | j.DONATION_AMOUNT += k.DONATION_AMOUNT;
37 | count_number += 1;
38 | } else {
39 | count_number += 1;
40 | }
41 | }
42 | }
43 | var dict = {
44 | Nonprofit: j.NONPROFIT,
45 | Donation_Amount: j.DONATION_AMOUNT +" "+ base,
46 | Numbers_of_Donations: count_number
47 | };
48 | console.log(dict);
49 | var csvWriter = createCsvWriter({
50 | path: "./csv/nonprofit_data.csv",
51 | header: [
52 | { id: "Nonprofit", title: "NONPROFIT" },
53 | { id: "Donation_Amount", title: "DONATION_AMOUNT" },
54 | { id: "Numbers_of_Donations", title: "NUMBERS_OF_DONATIONS"}
55 | ]
56 | });
57 | // dict data pushing in a NonprofitArr.
58 | NonprofitArr.push(dict);
59 | csvWriter
60 | .writeRecords(NonprofitArr)
61 | .then(() => {
62 | console.log("Data inserted in CSV file!");
63 | res.send({ Success: "data inserted in CSV file!" });
64 | })
65 | .catch(err => {
66 | console.log(err);
67 | });
68 | }
69 | }
70 | // res.send(NonprofitArr);
71 | })
72 | .catch(err => {
73 | console.log(err);
74 | });
75 | })
76 | .catch(err => {
77 | console.log(err);
78 | });
79 | });
80 | };
81 |
--------------------------------------------------------------------------------
/csv/donation.csv:
--------------------------------------------------------------------------------
1 | DATE,NONPROFIT,DONATION_CURRENCY,DONATION_AMOUNT
2 | 2020-03-04 17:25:08,Babul Films Society,AUD,20
3 | 2020-03-04 17:25:55,Bal Sansar Sanstha,USD,10
4 | 2020-03-04 17:26:20,Bangalore Baptist Hospital Society,USD,563
5 | 2020-03-04 17:26:58,Waste Warriors Society,GBP,27
6 | 2020-03-04 17:28:08,The CounterMedia Trust,USD,20
7 | 2020-03-04 17:28:41,Gubbachi Learning Community,USD,10
8 | 2020-03-04 17:29:05,Sethu Trust,USD,1000
9 | 2020-03-04 17:29:43,Fundacja Aravindam Social Development,MYR,58
10 | 2020-03-04 17:30:11,Suyam Charitable Trust,USD,20
11 | 2020-03-04 17:25:08,Babul Films Society,AUD,20
12 | 2020-03-04 17:25:55,Bal Sansar Sanstha,USD,10
13 | 2020-03-04 17:26:20,Bangalore Baptist Hospital Society,USD,563
14 | 2020-03-04 17:26:58,Waste Warriors Society,GBP,27
15 | 2020-03-04 17:28:08,The CounterMedia Trust,USD,20
16 | 2020-03-04 17:28:41,Gubbachi Learning Community,USD,10
17 | 2020-03-04 17:29:05,Sethu Trust,USD,1000
18 | 2020-03-04 17:25:08,Babul Films Society,AUD,20
19 | 2020-03-04 17:25:55,Bal Sansar Sanstha,USD,10
20 | 2020-03-04 17:26:20,Bangalore Baptist Hospital Society,USD,563
21 | 2020-03-04 17:26:58,Waste Warriors Society,GBP,27
22 |
--------------------------------------------------------------------------------
/csv/nonprofit_data.csv:
--------------------------------------------------------------------------------
1 | NONPROFIT,DONATION_AMOUNT,NUMBERS_OF_DONATIONS
2 | Babul Films Society,26.295310744494856 USD,2
3 | Bal Sansar Sanstha,20 USD,2
4 | Bangalore Baptist Hospital Society,1126 USD,2
5 | Waste Warriors Society,68.99413860065538 USD,2
6 | The CounterMedia Trust,40 USD,2
7 | Gubbachi Learning Community,20 USD,2
8 | Sethu Trust,2000 USD,2
9 | Fundacja Aravindam Social Development,13.789854142484723 USD,1
10 | Suyam Charitable Trust,20 USD,1
11 | Babul Films Society,39.442966116742284 USD,3
12 | Bal Sansar Sanstha,30 USD,3
13 | Bangalore Baptist Hospital Society,1689 USD,3
14 | Waste Warriors Society,103.49120790098306 USD,3
15 | The CounterMedia Trust,40 USD,2
16 | Gubbachi Learning Community,20 USD,2
17 | Sethu Trust,2000 USD,2
18 | Fundacja Aravindam Social Development,13.789854142484723 USD,1
19 | Suyam Charitable Trust,20 USD,1
20 |
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "give_india",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "@fast-csv/format": {
8 | "version": "4.1.1",
9 | "resolved": "https://registry.npmjs.org/@fast-csv/format/-/format-4.1.1.tgz",
10 | "integrity": "sha512-xiapqgG9bTiCcDlxjuaV+HQt7kJGQOxCT3kXkOiT0S4Q3X6Zo0WE86iYQCo4X/tlkcjozPq3bc0f0AOhCI0wZw==",
11 | "requires": {
12 | "lodash.escaperegexp": "^4.1.2",
13 | "lodash.isboolean": "^3.0.3",
14 | "lodash.isequal": "^4.5.0",
15 | "lodash.isfunction": "^3.0.9",
16 | "lodash.isnil": "^4.0.0"
17 | }
18 | },
19 | "@fast-csv/parse": {
20 | "version": "4.1.1",
21 | "resolved": "https://registry.npmjs.org/@fast-csv/parse/-/parse-4.1.1.tgz",
22 | "integrity": "sha512-ayyg/O1IlOWn0d0vcVmOz1DHnD5vutHbDdovKS2qX2PcT09TkZe0Xx/2Wh2CSynzM+2ynj/05fxYKFDpiorpzQ==",
23 | "requires": {
24 | "lodash.escaperegexp": "^4.1.2",
25 | "lodash.groupby": "^4.6.0",
26 | "lodash.isfunction": "^3.0.9",
27 | "lodash.isnil": "^4.0.0",
28 | "lodash.isundefined": "^3.0.1",
29 | "lodash.uniq": "^4.5.0"
30 | }
31 | },
32 | "@types/node": {
33 | "version": "12.12.29",
34 | "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.29.tgz",
35 | "integrity": "sha512-yo8Qz0ygADGFptISDj3pOC9wXfln/5pQaN/ysDIzOaAWXt73cNHmtEC8zSO2Y+kse/txmwIAJzkYZ5fooaS5DQ=="
36 | },
37 | "accepts": {
38 | "version": "1.3.7",
39 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
40 | "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
41 | "requires": {
42 | "mime-types": "~2.1.24",
43 | "negotiator": "0.6.2"
44 | }
45 | },
46 | "array-flatten": {
47 | "version": "1.1.1",
48 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
49 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
50 | },
51 | "axios": {
52 | "version": "0.19.2",
53 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz",
54 | "integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==",
55 | "requires": {
56 | "follow-redirects": "1.5.10"
57 | }
58 | },
59 | "bluebird": {
60 | "version": "3.7.2",
61 | "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
62 | "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
63 | },
64 | "body-parser": {
65 | "version": "1.19.0",
66 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
67 | "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==",
68 | "requires": {
69 | "bytes": "3.1.0",
70 | "content-type": "~1.0.4",
71 | "debug": "2.6.9",
72 | "depd": "~1.1.2",
73 | "http-errors": "1.7.2",
74 | "iconv-lite": "0.4.24",
75 | "on-finished": "~2.3.0",
76 | "qs": "6.7.0",
77 | "raw-body": "2.4.0",
78 | "type-is": "~1.6.17"
79 | }
80 | },
81 | "bytes": {
82 | "version": "3.1.0",
83 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
84 | "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg=="
85 | },
86 | "circular-json": {
87 | "version": "0.5.9",
88 | "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.5.9.tgz",
89 | "integrity": "sha512-4ivwqHpIFJZBuhN3g/pEcdbnGUywkBblloGbkglyloVjjR3uT6tieI89MVOfbP2tHX5sgb01FuLgAOzebNlJNQ=="
90 | },
91 | "content-disposition": {
92 | "version": "0.5.3",
93 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
94 | "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==",
95 | "requires": {
96 | "safe-buffer": "5.1.2"
97 | }
98 | },
99 | "content-type": {
100 | "version": "1.0.4",
101 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
102 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA=="
103 | },
104 | "cookie": {
105 | "version": "0.4.0",
106 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
107 | "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg=="
108 | },
109 | "cookie-signature": {
110 | "version": "1.0.6",
111 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
112 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
113 | },
114 | "csv-writer": {
115 | "version": "1.6.0",
116 | "resolved": "https://registry.npmjs.org/csv-writer/-/csv-writer-1.6.0.tgz",
117 | "integrity": "sha512-NOx7YDFWEsM/fTRAJjRpPp8t+MKRVvniAg9wQlUKx20MFrPs73WLJhFf5iteqrxNYnsy924K3Iroh3yNHeYd2g=="
118 | },
119 | "csvtojson": {
120 | "version": "2.0.10",
121 | "resolved": "https://registry.npmjs.org/csvtojson/-/csvtojson-2.0.10.tgz",
122 | "integrity": "sha512-lUWFxGKyhraKCW8Qghz6Z0f2l/PqB1W3AO0HKJzGIQ5JRSlR651ekJDiGJbBT4sRNNv5ddnSGVEnsxP9XRCVpQ==",
123 | "requires": {
124 | "bluebird": "^3.5.1",
125 | "lodash": "^4.17.3",
126 | "strip-bom": "^2.0.0"
127 | }
128 | },
129 | "current-date": {
130 | "version": "0.1.1",
131 | "resolved": "https://registry.npmjs.org/current-date/-/current-date-0.1.1.tgz",
132 | "integrity": "sha1-rQRvDK6nxuZG15B/ZpsnPkw7Oco="
133 | },
134 | "debug": {
135 | "version": "2.6.9",
136 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
137 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
138 | "requires": {
139 | "ms": "2.0.0"
140 | }
141 | },
142 | "depd": {
143 | "version": "1.1.2",
144 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
145 | "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
146 | },
147 | "destroy": {
148 | "version": "1.0.4",
149 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
150 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
151 | },
152 | "ee-first": {
153 | "version": "1.1.1",
154 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
155 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
156 | },
157 | "encodeurl": {
158 | "version": "1.0.2",
159 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
160 | "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
161 | },
162 | "escape-html": {
163 | "version": "1.0.3",
164 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
165 | "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
166 | },
167 | "etag": {
168 | "version": "1.8.1",
169 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
170 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
171 | },
172 | "express": {
173 | "version": "4.17.1",
174 | "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
175 | "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==",
176 | "requires": {
177 | "accepts": "~1.3.7",
178 | "array-flatten": "1.1.1",
179 | "body-parser": "1.19.0",
180 | "content-disposition": "0.5.3",
181 | "content-type": "~1.0.4",
182 | "cookie": "0.4.0",
183 | "cookie-signature": "1.0.6",
184 | "debug": "2.6.9",
185 | "depd": "~1.1.2",
186 | "encodeurl": "~1.0.2",
187 | "escape-html": "~1.0.3",
188 | "etag": "~1.8.1",
189 | "finalhandler": "~1.1.2",
190 | "fresh": "0.5.2",
191 | "merge-descriptors": "1.0.1",
192 | "methods": "~1.1.2",
193 | "on-finished": "~2.3.0",
194 | "parseurl": "~1.3.3",
195 | "path-to-regexp": "0.1.7",
196 | "proxy-addr": "~2.0.5",
197 | "qs": "6.7.0",
198 | "range-parser": "~1.2.1",
199 | "safe-buffer": "5.1.2",
200 | "send": "0.17.1",
201 | "serve-static": "1.14.1",
202 | "setprototypeof": "1.1.1",
203 | "statuses": "~1.5.0",
204 | "type-is": "~1.6.18",
205 | "utils-merge": "1.0.1",
206 | "vary": "~1.1.2"
207 | }
208 | },
209 | "fast-csv": {
210 | "version": "4.1.1",
211 | "resolved": "https://registry.npmjs.org/fast-csv/-/fast-csv-4.1.1.tgz",
212 | "integrity": "sha512-otu5Zc2O4xCLSZMw8NMAcl7ieJTh6RuH2kfvaEpiKnZ57jjy45estIoXyb8eisv3Js/ViBfdwNTmeyV+yMJwSw==",
213 | "requires": {
214 | "@fast-csv/format": "^4.1.1",
215 | "@fast-csv/parse": "^4.1.1",
216 | "@types/node": "^12.12.17"
217 | }
218 | },
219 | "finalhandler": {
220 | "version": "1.1.2",
221 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
222 | "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==",
223 | "requires": {
224 | "debug": "2.6.9",
225 | "encodeurl": "~1.0.2",
226 | "escape-html": "~1.0.3",
227 | "on-finished": "~2.3.0",
228 | "parseurl": "~1.3.3",
229 | "statuses": "~1.5.0",
230 | "unpipe": "~1.0.0"
231 | }
232 | },
233 | "follow-redirects": {
234 | "version": "1.5.10",
235 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
236 | "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
237 | "requires": {
238 | "debug": "=3.1.0"
239 | },
240 | "dependencies": {
241 | "debug": {
242 | "version": "3.1.0",
243 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
244 | "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
245 | "requires": {
246 | "ms": "2.0.0"
247 | }
248 | }
249 | }
250 | },
251 | "forwarded": {
252 | "version": "0.1.2",
253 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
254 | "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ="
255 | },
256 | "fresh": {
257 | "version": "0.5.2",
258 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
259 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
260 | },
261 | "fs": {
262 | "version": "0.0.1-security",
263 | "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
264 | "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ="
265 | },
266 | "http-errors": {
267 | "version": "1.7.2",
268 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
269 | "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==",
270 | "requires": {
271 | "depd": "~1.1.2",
272 | "inherits": "2.0.3",
273 | "setprototypeof": "1.1.1",
274 | "statuses": ">= 1.5.0 < 2",
275 | "toidentifier": "1.0.0"
276 | }
277 | },
278 | "iconv-lite": {
279 | "version": "0.4.24",
280 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
281 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
282 | "requires": {
283 | "safer-buffer": ">= 2.1.2 < 3"
284 | }
285 | },
286 | "inherits": {
287 | "version": "2.0.3",
288 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
289 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
290 | },
291 | "ipaddr.js": {
292 | "version": "1.9.1",
293 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
294 | "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g=="
295 | },
296 | "is-utf8": {
297 | "version": "0.2.1",
298 | "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
299 | "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI="
300 | },
301 | "lodash": {
302 | "version": "4.17.15",
303 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
304 | "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
305 | },
306 | "lodash.escaperegexp": {
307 | "version": "4.1.2",
308 | "resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz",
309 | "integrity": "sha1-ZHYsSGGAglGKw99Mz11YhtriA0c="
310 | },
311 | "lodash.groupby": {
312 | "version": "4.6.0",
313 | "resolved": "https://registry.npmjs.org/lodash.groupby/-/lodash.groupby-4.6.0.tgz",
314 | "integrity": "sha1-Cwih3PaDl8OXhVwyOXg4Mt90A9E="
315 | },
316 | "lodash.isboolean": {
317 | "version": "3.0.3",
318 | "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz",
319 | "integrity": "sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY="
320 | },
321 | "lodash.isequal": {
322 | "version": "4.5.0",
323 | "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
324 | "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA="
325 | },
326 | "lodash.isfunction": {
327 | "version": "3.0.9",
328 | "resolved": "https://registry.npmjs.org/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz",
329 | "integrity": "sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw=="
330 | },
331 | "lodash.isnil": {
332 | "version": "4.0.0",
333 | "resolved": "https://registry.npmjs.org/lodash.isnil/-/lodash.isnil-4.0.0.tgz",
334 | "integrity": "sha1-SeKM1VkBNFjIFMVHnTxmOiG/qmw="
335 | },
336 | "lodash.isundefined": {
337 | "version": "3.0.1",
338 | "resolved": "https://registry.npmjs.org/lodash.isundefined/-/lodash.isundefined-3.0.1.tgz",
339 | "integrity": "sha1-I+89lTVWUgOmbO/VuDD4SJEa+0g="
340 | },
341 | "lodash.uniq": {
342 | "version": "4.5.0",
343 | "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz",
344 | "integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M="
345 | },
346 | "media-typer": {
347 | "version": "0.3.0",
348 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
349 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
350 | },
351 | "merge-descriptors": {
352 | "version": "1.0.1",
353 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
354 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
355 | },
356 | "methods": {
357 | "version": "1.1.2",
358 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
359 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
360 | },
361 | "mime": {
362 | "version": "1.6.0",
363 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
364 | "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
365 | },
366 | "mime-db": {
367 | "version": "1.43.0",
368 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz",
369 | "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ=="
370 | },
371 | "mime-types": {
372 | "version": "2.1.26",
373 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz",
374 | "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==",
375 | "requires": {
376 | "mime-db": "1.43.0"
377 | }
378 | },
379 | "ms": {
380 | "version": "2.0.0",
381 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
382 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
383 | },
384 | "negotiator": {
385 | "version": "0.6.2",
386 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
387 | "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
388 | },
389 | "on-finished": {
390 | "version": "2.3.0",
391 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
392 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
393 | "requires": {
394 | "ee-first": "1.1.1"
395 | }
396 | },
397 | "parseurl": {
398 | "version": "1.3.3",
399 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
400 | "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="
401 | },
402 | "path-to-regexp": {
403 | "version": "0.1.7",
404 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
405 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
406 | },
407 | "proxy-addr": {
408 | "version": "2.0.6",
409 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz",
410 | "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==",
411 | "requires": {
412 | "forwarded": "~0.1.2",
413 | "ipaddr.js": "1.9.1"
414 | }
415 | },
416 | "qs": {
417 | "version": "6.7.0",
418 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
419 | "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
420 | },
421 | "range-parser": {
422 | "version": "1.2.1",
423 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
424 | "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="
425 | },
426 | "raw-body": {
427 | "version": "2.4.0",
428 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz",
429 | "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==",
430 | "requires": {
431 | "bytes": "3.1.0",
432 | "http-errors": "1.7.2",
433 | "iconv-lite": "0.4.24",
434 | "unpipe": "1.0.0"
435 | }
436 | },
437 | "safe-buffer": {
438 | "version": "5.1.2",
439 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
440 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
441 | },
442 | "safer-buffer": {
443 | "version": "2.1.2",
444 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
445 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
446 | },
447 | "send": {
448 | "version": "0.17.1",
449 | "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz",
450 | "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==",
451 | "requires": {
452 | "debug": "2.6.9",
453 | "depd": "~1.1.2",
454 | "destroy": "~1.0.4",
455 | "encodeurl": "~1.0.2",
456 | "escape-html": "~1.0.3",
457 | "etag": "~1.8.1",
458 | "fresh": "0.5.2",
459 | "http-errors": "~1.7.2",
460 | "mime": "1.6.0",
461 | "ms": "2.1.1",
462 | "on-finished": "~2.3.0",
463 | "range-parser": "~1.2.1",
464 | "statuses": "~1.5.0"
465 | },
466 | "dependencies": {
467 | "ms": {
468 | "version": "2.1.1",
469 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
470 | "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
471 | }
472 | }
473 | },
474 | "serve-static": {
475 | "version": "1.14.1",
476 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz",
477 | "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==",
478 | "requires": {
479 | "encodeurl": "~1.0.2",
480 | "escape-html": "~1.0.3",
481 | "parseurl": "~1.3.3",
482 | "send": "0.17.1"
483 | }
484 | },
485 | "setprototypeof": {
486 | "version": "1.1.1",
487 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
488 | "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
489 | },
490 | "statuses": {
491 | "version": "1.5.0",
492 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
493 | "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
494 | },
495 | "strip-bom": {
496 | "version": "2.0.0",
497 | "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz",
498 | "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=",
499 | "requires": {
500 | "is-utf8": "^0.2.0"
501 | }
502 | },
503 | "toidentifier": {
504 | "version": "1.0.0",
505 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
506 | "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw=="
507 | },
508 | "type-is": {
509 | "version": "1.6.18",
510 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
511 | "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
512 | "requires": {
513 | "media-typer": "0.3.0",
514 | "mime-types": "~2.1.24"
515 | }
516 | },
517 | "unpipe": {
518 | "version": "1.0.0",
519 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
520 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
521 | },
522 | "utils-merge": {
523 | "version": "1.0.1",
524 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
525 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
526 | },
527 | "vary": {
528 | "version": "1.1.2",
529 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
530 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
531 | }
532 | }
533 | }
534 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "give_india",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "anand",
10 | "license": "MIT",
11 | "dependencies": {
12 | "axios": "^0.19.2",
13 | "body-parser": "^1.19.0",
14 | "circular-json": "^0.5.9",
15 | "csv-writer": "^1.6.0",
16 | "csvtojson": "^2.0.10",
17 | "current-date": "^0.1.1",
18 | "express": "^4.17.1",
19 | "fast-csv": "^4.1.1",
20 | "fs": "0.0.1-security"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/server.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const app = express();
3 | const axios = require("axios");
4 | const bodyParser = require("body-parser");
5 | const mydate = require('current-date');
6 | const fs = require("fs");
7 | const CircularJSON = require('circular-json')
8 | const createCsvWriter = require('csv-writer').createObjectCsvWriter;
9 | const csv=require('csvtojson');
10 |
11 | app.use(bodyParser.json());
12 |
13 | // route to donation_data.js
14 | var donation_data = express.Router();
15 | app.use("/", donation_data);
16 | require("./Routes/donation_data")(donation_data, axios, mydate, createCsvWriter)
17 |
18 | // route to donation_amount.js
19 | var donation_amount = express.Router();
20 | app.use("/", donation_amount);
21 | require("./Routes/donation_amount")(donation_amount, axios, csv);
22 |
23 | // route to noneprofit.js
24 | var noneprofit = express.Router();
25 | app.use("/", noneprofit);
26 | require("./Routes/noneprofit")(noneprofit, axios, csv, createCsvWriter)
27 |
28 | // the port listener
29 | const server = app.listen(5051, function() {
30 | let host = server.address().address;
31 | let port = server.address().port;
32 | console.log("server is running on port.......");
33 | console.log(host, port);
34 | });
35 |
--------------------------------------------------------------------------------