From aa9d21c91428c352ff92824310d75134eafb3a22 Mon Sep 17 00:00:00 2001 From: underdorff18 Date: Sat, 25 Jun 2022 15:09:45 -0400 Subject: [PATCH] small refactor to fit specifications --- JS/Inventory/samplepc1234.xlsx | Bin 0 -> 5187 bytes JS/excelreader.js | 19 +++++++++++++++++++ JS/index.js | 16 +++++++++++----- JS/parse.js | 11 ----------- JS/{testinput.json => systems.json} | 0 5 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 JS/Inventory/samplepc1234.xlsx create mode 100644 JS/excelreader.js delete mode 100644 JS/parse.js rename JS/{testinput.json => systems.json} (100%) diff --git a/JS/Inventory/samplepc1234.xlsx b/JS/Inventory/samplepc1234.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..41708a425797a2fb2b390cbfeb993953cfeb1f25 GIT binary patch literal 5187 zcmaJ_2RPgN*H3IxwfCkqYL*s7DQd3>HEShe@4fe`Yty2rQKi&gEk(t;_EtM~FDmw| z^+xai`PbX`z4zpK@=Km4=X~=$<8waefK@QD$N_kGc!0H>p^7CE4 zmnID=W8No@-1d)7@b#>tcxqnV6g8Bg=pU5UcWEY)EP+sEJOnrwCZ*#>l!?-0RyipSdR4w#c1fK_w?lg~9< z^^C=qOyAMhN1D%>`-a&YnP6U-uN_4d9U-ldXR$hw$6=`zMc?HkJy(n|EmXC++H(v@h-w^^q=FQe=OHm0h|% z`h+JRf7zI%w%%(s-ZIQ#B?SPh;Nn>nhkRT>Ut1glfd2kZjv+$-!V7(dql+!n(b1OA z%ibO0We2g*qxpvPiY%X-nIKG?+Qr*f5$Z~OCaJg)6{IIlzxy4w zP0dIl|CDD}qSz8duzUe;QG)uIEAWX`zUn>Mfv>xF7R&?xG#q6?TC*9~$nbrvABJ?^ z>R&X7jmqn~qL``+^;tYDXgEJ{Eb z_cn7GwENhBkGaDu*P=zq)wAe>H)<&#u6$YVLX}88Ud7okj^KSJwhb!YbPFLDBj6TP zis_dDx6D!{%5IvypUeElPkd{Y<3~=E%%qDTIA8=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RdTv1WoRol&}8Xm$k@7eW3_ea(;RoBw)^88hR@5amK=f^tov$BnsnnS^XUh29%FP~m%@KY{8^KR2|G*f2w{sJ` zuRH25nL~T?`Xayg*WWGNgqLfO|0OYK&-@?A|6ToN)m>xIFX2H)<-h9xL8RZcZ)V1I fW&RRvw6XuEPQfbJXfFc*_~@4u8W6XB{^kDx7AV)z literal 0 HcmV?d00001 diff --git a/JS/excelreader.js b/JS/excelreader.js new file mode 100644 index 0000000..870e54a --- /dev/null +++ b/JS/excelreader.js @@ -0,0 +1,19 @@ +const fs = require('fs'); +const path = require('path'); +const xlsx = require('xlsx'); + +const myfilepath = path.join(__dirname, 'Inventory', 'samplepc1234.xlsx'); + +function readInventoryFile(filepath) { + const workbook = xlsx.readFileSync(filepath); + const sheetNames = workbook.SheetNames; + const data = workbook.Sheets[sheetNames[0]]; + console.log(data); + + //Here is where we use known cell locations of the specs needed to build the systems file +} + + +readInventoryFile(myfilepath); +//console.log('yo'); + diff --git a/JS/index.js b/JS/index.js index 294cbcc..36d9e39 100644 --- a/JS/index.js +++ b/JS/index.js @@ -1,16 +1,22 @@ const express = require('express', '4.17.1'); +const fs = require('fs'); const app = express(); -const myparse = require('./parse'); +//const myparse = require('./parse'); const port = 3000; -console.log(JSON.stringify(myparse.systems)); - app.get('/', (req, res) => { - res.send('Hello World!'); + res.send('Homepage'); +}); + +app.get('/systems.json', (req, res) => { + fs.readFile('systems.json', 'utf8', (err, data) => { + if (err) throw err; + res.json(JSON.parse(data)); + }); }); app.listen(port, () => { - console.log('Listening at http://localhost:${port}'); + console.log(`Listening at http://localhost:${port}`); }); diff --git a/JS/parse.js b/JS/parse.js deleted file mode 100644 index 9b376c3..0000000 --- a/JS/parse.js +++ /dev/null @@ -1,11 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -var systems; -fs.readFile('testinput.json', 'utf8', (err, data) => { - if (err) throw err; - console.log(data); - systems = JSON.parse(data); -}); - -exports.systems = systems; diff --git a/JS/testinput.json b/JS/systems.json similarity index 100% rename from JS/testinput.json rename to JS/systems.json