-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* started the SQLite class. Still have to fix types. * fixed the issues with the sqlite class. Co-authored-by: Ideen <[email protected]> * mobile view fixed (#94) * Amplify working code * Final Backend Deployment cahnges * Bump next from 14.1.0 to 14.1.1 (#88) Bumps [next](https://github.com/vercel/next.js) from 14.1.0 to 14.1.1. - [Release notes](https://github.com/vercel/next.js/releases) - [Changelog](https://github.com/vercel/next.js/blob/canary/release.js) - [Commits](vercel/next.js@v14.1.0...v14.1.1) --- updated-dependencies: - dependency-name: next dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Tel 107 add unit conversion to pis transformer (#86) * started unit conversion logic * Create dockerfile for backend (#77) * make the CarGraphicComponent SSR instead of the HeroComponent (#80) * local storage and darkmode settings implemented * Create dockerfile for backend (#77) * make the CarGraphicComponent SSR instead of the HeroComponent (#80) * local storage and darkmode settings implemented * continued unit conversion function Co-authored-by: JenniferJa <[email protected]> * finsihed unit handler function without changes from setting modal changes * yarn issue fixed by brian * local storage and darkmode settings implemented * yarn issue fixed by brian * moved enum to appStateContext * fixed small issue with displaying units * fixed PR comments * made unit conversion logic work with setting modal * made speed adapt value adapt to change in units * addressed comments. Changed to switch, case and destructured appState * changed to switch * fixed bug with undefined units and addressed comment * fixed the miles per hour to 0 decimal places --------- Co-authored-by: alexwhelan12 <[email protected]> Co-authored-by: brian nguyen <[email protected]> Co-authored-by: jenniferja <[email protected]> Co-authored-by: JenniferJa <[email protected]> * mobile view fixed * some changes * Should be good * change to scrollbars * scrollbar spacing * oops * please im begging --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: ideen1 <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ideen <[email protected]> Co-authored-by: alexwhelan12 <[email protected]> Co-authored-by: brian nguyen <[email protected]> Co-authored-by: jenniferja <[email protected]> Co-authored-by: JenniferJa <[email protected]> * removed database.sqlite file * Fixed package * Add SQLITE back --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Ideen <[email protected]> Co-authored-by: Burton Jong <[email protected]> Co-authored-by: ideen1 <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ideen <[email protected]> Co-authored-by: brian nguyen <[email protected]> Co-authored-by: jenniferja <[email protected]> Co-authored-by: JenniferJa <[email protected]>
- Loading branch information
1 parent
a49effb
commit 5be38eb
Showing
9 changed files
with
727 additions
and
1,139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ server/dist | |
# misc | ||
.DS_Store | ||
*.pem | ||
.sqlite | ||
|
||
# debug | ||
npm-debug.log* | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"watch": ["src"], | ||
"ext": "ts", | ||
"exec": "ts-node ./src/server.ts" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
{ | ||
"main": "dist/server.js", | ||
"license": "ISC", | ||
"scripts": { | ||
"clean": "rimraf dist", | ||
"start": "node -r ts-node/register -r tsconfig-paths/register .", | ||
"build": "npm-run-all clean tsc", | ||
"dev:start": "npm-run-all build start", | ||
"dev": "nodemon --watch src -e ts,ejs --exec \"npm run dev:start\"", | ||
"dev": "nodemon - exec 'ts-node' src/server.ts", | ||
"tsc": "tsc -p ./tsconfig.json" | ||
}, | ||
"dependencies": { | ||
"@types/sqlite3": "^3.1.11" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import sqlite3 from "sqlite3"; | ||
|
||
import type ITelemetryData from "@/client/objects/telemetry-data.interface"; | ||
|
||
class SQLite { | ||
private db: sqlite3.Database; | ||
constructor(dbPath: string) { | ||
this.db = new sqlite3.Database(dbPath, (err: Error | null) => { | ||
if (err) { | ||
console.error("Error opening database:", err.message); | ||
} else { | ||
console.log("Connected to the SQLite database."); | ||
} | ||
}); | ||
|
||
this.db | ||
.prepare( | ||
"CREATE TABLE IF NOT EXISTS packetData (id INTEGER PRIMARY KEY, date TEXT, data TEXT)", | ||
) | ||
.run() | ||
.finalize(); | ||
this.db | ||
.prepare( | ||
"CREATE TABLE IF NOT EXISTS lapData (id INTEGER PRIMARY KEY, date TEXT, data TEXT)", | ||
) | ||
.run() | ||
.finalize(); | ||
} | ||
|
||
//Helper function to run a query | ||
private runQuery(sql: string, params: any[]): Promise<{ id: number }> { | ||
return new Promise((resolve, reject) => { | ||
this.db.run( | ||
sql, | ||
params, | ||
function (this: sqlite3.RunResult, err: Error | null) { | ||
if (err) { | ||
reject(new Error(`Error running SQL: ${err.message}`)); | ||
} else { | ||
resolve({ id: this.lastID }); | ||
} | ||
}, | ||
); | ||
}); | ||
} | ||
|
||
//Helper function to get all rows | ||
private getAllRows(sql: string): Promise<ITelemetryData[]> { | ||
return new Promise<ITelemetryData[]>((resolve, reject) => { | ||
this.db.all(sql, (err: Error | null, rows: any[]) => { | ||
if (err) { | ||
reject(new Error(`Error retrieving data: ${err.message}`)); | ||
} else { | ||
// Deserialize JSON strings to ITelemetryData objects | ||
const telemetryData = rows.map((row) => JSON.parse(row.data)); | ||
resolve(telemetryData); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
//Four basic insert and select functions | ||
public insertPacketData(packet: ITelemetryData): Promise<{ id: number }> { | ||
const sql = "INSERT INTO packetData (date, data) VALUES (?, ?)"; | ||
const data = JSON.stringify(packet); // Serialize ITelemetryData to JSON | ||
return this.runQuery(sql, [packet.TimeStamp, data]); | ||
} | ||
public insertLapData(packet: ITelemetryData): Promise<{ id: number }> { | ||
const sql = "INSERT INTO lapData (date, data) VALUES (?, ?)"; | ||
const data = JSON.stringify(packet); // Serialize ITelemetryData to JSON | ||
return this.runQuery(sql, [packet.TimeStamp, data]); | ||
} | ||
|
||
public getPacketData(): Promise<ITelemetryData[]> { | ||
const sql = "SELECT * FROM packetData"; | ||
return this.getAllRows(sql); | ||
} | ||
public getLapData(): Promise<ITelemetryData[]> { | ||
const sql = "SELECT * FROM lapData"; | ||
return this.getAllRows(sql); | ||
} | ||
|
||
//Close the connection to the database | ||
public close(): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
this.db.close((err) => { | ||
if (err) { | ||
reject(new Error(`Error closing the database: ${err.message}`)); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
export default SQLite; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters