-
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.
- Loading branch information
Caspar Oostendorp
committed
Jun 19, 2024
1 parent
4cec902
commit 7f485ce
Showing
22 changed files
with
740 additions
and
141 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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# dev | ||
assets/tiles | ||
|
||
# App specific | ||
web/ | ||
.idea | ||
|
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,4 +1,4 @@ | ||
# server | ||
NodeExpress backend for "bots" and other optimizations | ||
|
||
Version 0.3.10 | ||
Version 0.3.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 |
---|---|---|
@@ -1 +1 @@ | ||
0.3.10 | ||
0.3.11 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 was deleted.
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
File renamed without changes.
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,50 @@ | ||
import {Database} from 'sqlite'; | ||
import sqlite3 from 'sqlite3'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
import {open} from 'sqlite' | ||
|
||
export class SqliteDb { | ||
private db: Database; | ||
|
||
constructor(private dbFile: string) { | ||
} | ||
|
||
async open(): Promise<void> { | ||
const filename= `${this.dbFile}` | ||
|
||
if (!fs.existsSync(filename)) { | ||
this.db = await open({ | ||
filename, | ||
driver: sqlite3.Database | ||
}); | ||
|
||
const schema = fs.readFileSync(path.join(__dirname, 'schema.sql'), 'utf-8'); | ||
await this.db.exec(schema); | ||
} else { | ||
this.db = await open({ | ||
filename, | ||
driver: sqlite3.Database | ||
}); | ||
} | ||
} | ||
|
||
async setLastBlockNumber(blockNumber: number): Promise<void> { | ||
const query = 'UPDATE system SET data_number = ? WHERE name = ?'; | ||
await this.db.run(query, [blockNumber, 'last_blocknumber']); | ||
} | ||
|
||
|
||
async getLastBlockNumber(): Promise<number> { | ||
const query = 'SELECT data_number FROM system WHERE name = ?'; | ||
const row = await this.db.get(query, ['last_blocknumber']); | ||
if(!row) throw "last_blocknumber does not exist in db" | ||
return row.data_number; | ||
} | ||
|
||
|
||
async close(): Promise<void> { | ||
await this.db.close(); | ||
} | ||
} |
Oops, something went wrong.