mirror of
https://github.com/khairul169/cebol.git
synced 2026-09-19 18:57:46 +07:00
feat: initial features
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { Database } from "bun:sqlite";
|
||||
|
||||
const dbPath = process.cwd() + "/storage/database.sqlite";
|
||||
const db = new Database(dbPath);
|
||||
|
||||
export const initDb = () => {
|
||||
db.exec(
|
||||
`CREATE TABLE IF NOT EXISTS links (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
alias TEXT NOT NULL UNIQUE,
|
||||
url TEXT NOT NULL,
|
||||
clicks INTEGER DEFAULT 0,
|
||||
createdAt DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
)`
|
||||
);
|
||||
};
|
||||
|
||||
export default db;
|
||||
@@ -0,0 +1,5 @@
|
||||
import crypto from "node:crypto";
|
||||
|
||||
export const randomChars = (length = 8) => {
|
||||
return crypto.randomBytes(length / 2).toString("hex");
|
||||
};
|
||||
Reference in New Issue
Block a user