fix sharex
This commit is contained in:
parent
5290f4e960
commit
52b1aeea98
12 changed files with 80 additions and 49 deletions
37
app/types/db.ts
Normal file
37
app/types/db.ts
Normal file
|
@ -0,0 +1,37 @@
|
|||
import sqlite3 from "sqlite3";
|
||||
import mkdirp from "mkdirp";
|
||||
import crypto from "crypto";
|
||||
|
||||
mkdirp.sync("./uploads");
|
||||
mkdirp.sync("./var/db");
|
||||
|
||||
export const db = new sqlite3.Database("./var/db/media.db");
|
||||
|
||||
export function createUser(username: string, password: string) {
|
||||
var salt = crypto.randomBytes(16);
|
||||
db.run("INSERT OR IGNORE INTO users (username, hashed_password, salt) VALUES (?, ?, ?)", [
|
||||
username,
|
||||
crypto.pbkdf2Sync(password, salt, 310000, 32, "sha256"),
|
||||
salt
|
||||
]);
|
||||
}
|
||||
|
||||
export interface MediaRow {
|
||||
id? : Number,
|
||||
path: String,
|
||||
expire: Date,
|
||||
username?: String
|
||||
}
|
||||
|
||||
export type MediaParams = [
|
||||
path: String,
|
||||
expire: Date,
|
||||
username?: String
|
||||
]
|
||||
|
||||
export interface UserRow {
|
||||
id? : Number,
|
||||
username: String,
|
||||
hashed_password: any,
|
||||
salt: any
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue