Added simple microservice
Not integrated into UI yet
This commit is contained in:
21
server/index.js
Normal file
21
server/index.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const micro = require('micro');
|
||||
const Database = require('better-sqlite3');
|
||||
|
||||
module.exports = (req, res) => {
|
||||
console.log(req.method, req.url);
|
||||
if (req.method === "GET") {
|
||||
console.log("Get Request coming in");
|
||||
if (req.url === "/dates") {
|
||||
console.log("Request for Dates");
|
||||
const db = new Database('./quoteDBs/consolidated.sqlite3', { verbose: console.log });
|
||||
const stmt = db.prepare("SELECT distinct Symbol,date(TimeStamp,'localtime') Date ,time(TimeStamp,'localtime') Time FROM OptionQuotes");
|
||||
let allDates = stmt.all();
|
||||
//console.log(JSON.stringify(allDates));
|
||||
db.close();
|
||||
micro.send(res,200,allDates);
|
||||
}
|
||||
} else {
|
||||
res.end('Welcome to Micro');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user