feat(cleanup): removed built application
This commit is contained in:
parent
157b06ea4b
commit
bdc4616106
23 changed files with 2 additions and 210 deletions
2
src/@shared/dist/auth.d.ts
vendored
2
src/@shared/dist/auth.d.ts
vendored
|
|
@ -1,2 +0,0 @@
|
|||
import { FastifyInstance } from 'fastify';
|
||||
export default function (_fastify: FastifyInstance, _options: any): Promise<void>;
|
||||
3
src/@shared/dist/auth.js
vendored
3
src/@shared/dist/auth.js
vendored
|
|
@ -1,3 +0,0 @@
|
|||
export default async function (_fastify, _options) {
|
||||
console.log("inside the plugin !");
|
||||
}
|
||||
23
src/@shared/dist/database/a.d.ts
vendored
23
src/@shared/dist/database/a.d.ts
vendored
|
|
@ -1,23 +0,0 @@
|
|||
import { Result } from 'typescript-result';
|
||||
import { UUIDv7 } from '@shared/uuid';
|
||||
export declare class DBUserExists extends Error {
|
||||
readonly type = "db-user-exists";
|
||||
}
|
||||
export declare class Database {
|
||||
private db;
|
||||
private st;
|
||||
constructor(db_path: string);
|
||||
destroy(): void;
|
||||
private prepare;
|
||||
createUser(user: string): Result<UUIDv7, DBUserExists>;
|
||||
}
|
||||
declare module 'fastify' {
|
||||
interface FastifyInstance {
|
||||
db: Database;
|
||||
}
|
||||
}
|
||||
export type DatabaseOption = {
|
||||
path: string;
|
||||
};
|
||||
export declare const uDatabase: import("fastify").FastifyPluginCallback<DatabaseOption, import("fastify").RawServerDefault, import("fastify").FastifyTypeProviderDefault, import("fastify").FastifyBaseLogger>;
|
||||
export default uDatabase;
|
||||
43
src/@shared/dist/database/a.js
vendored
43
src/@shared/dist/database/a.js
vendored
|
|
@ -1,43 +0,0 @@
|
|||
import fp from 'fastify-plugin';
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { Result } from 'typescript-result';
|
||||
import initSql from "./init.sql.js";
|
||||
import { newUUIDv7 } from '@shared/uuid';
|
||||
export class DBUserExists extends Error {
|
||||
type = 'db-user-exists';
|
||||
}
|
||||
export class Database {
|
||||
db;
|
||||
st = new Map();
|
||||
constructor(db_path) {
|
||||
this.db = sqlite(db_path, {});
|
||||
this.db.pragma('journal_mode = WAL');
|
||||
this.db.transaction(() => this.db.exec(initSql))();
|
||||
}
|
||||
destroy() {
|
||||
this.st.clear();
|
||||
this.db?.close();
|
||||
}
|
||||
prepare(query) {
|
||||
let st = this.st.get(query);
|
||||
if (st !== undefined)
|
||||
return st;
|
||||
st = this.db.prepare(query);
|
||||
this.st.set(query, st);
|
||||
return st;
|
||||
}
|
||||
createUser(user) {
|
||||
const st = this.prepare('INSERT INTO users VALUES (?, ?) RETURNING id');
|
||||
try {
|
||||
st.get(newUUIDv7(), user);
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e);
|
||||
console.log(typeof e);
|
||||
}
|
||||
return Result.ok(newUUIDv7());
|
||||
}
|
||||
}
|
||||
export const uDatabase = fp(async function (_fastify, _options) {
|
||||
});
|
||||
export default uDatabase;
|
||||
1
src/@shared/dist/database/index.d.ts
vendored
1
src/@shared/dist/database/index.d.ts
vendored
|
|
@ -1 +0,0 @@
|
|||
export {};
|
||||
1
src/@shared/dist/database/index.js
vendored
1
src/@shared/dist/database/index.js
vendored
|
|
@ -1 +0,0 @@
|
|||
export {};
|
||||
2
src/@shared/dist/database/init.sql.d.ts
vendored
2
src/@shared/dist/database/init.sql.d.ts
vendored
|
|
@ -1,2 +0,0 @@
|
|||
declare const _default: "-- this file will make sure that the database is always up to date with the correct schema\n-- when editing this file, make sure to always include stuff like `IF NOT EXISTS` such as to not throw error\n-- NEVER DROP ANYTHING IN THIS FILE\nCREATE TABLE IF NOT EXISTS users (\n id STRING UNIQUE PRIMARY KEY, -- UUIDv7 as a string\n name STRING UNIQUE, -- name of the user\n token STRING UNIQUE, -- the token of the user (aka the cookie)\n);\n\n";
|
||||
export default _default;
|
||||
1
src/@shared/dist/database/init.sql.js
vendored
1
src/@shared/dist/database/init.sql.js
vendored
|
|
@ -1 +0,0 @@
|
|||
export default "-- this file will make sure that the database is always up to date with the correct schema\n-- when editing this file, make sure to always include stuff like `IF NOT EXISTS` such as to not throw error\n-- NEVER DROP ANYTHING IN THIS FILE\nCREATE TABLE IF NOT EXISTS users (\n id STRING UNIQUE PRIMARY KEY, -- UUIDv7 as a string\n name STRING UNIQUE, -- name of the user\n token STRING UNIQUE, -- the token of the user (aka the cookie)\n);\n\n";
|
||||
10
src/@shared/dist/uuid/index.d.ts
vendored
10
src/@shared/dist/uuid/index.d.ts
vendored
|
|
@ -1,10 +0,0 @@
|
|||
import { Result } from "typescript-result";
|
||||
export declare class InvalidUUID extends Error {
|
||||
readonly type = "invalid-uuid";
|
||||
}
|
||||
export type UUIDv7 = string & {
|
||||
readonly __brand: unique symbol;
|
||||
};
|
||||
export declare function isUUIDv7(value: string): value is UUIDv7;
|
||||
export declare function toUUIDv7(value: string): Result<UUIDv7, InvalidUUID>;
|
||||
export declare function newUUIDv7(): UUIDv7;
|
||||
18
src/@shared/dist/uuid/index.js
vendored
18
src/@shared/dist/uuid/index.js
vendored
|
|
@ -1,18 +0,0 @@
|
|||
import { Result } from "typescript-result";
|
||||
import { uuidv7 } from "uuidv7";
|
||||
export class InvalidUUID extends Error {
|
||||
type = 'invalid-uuid';
|
||||
}
|
||||
;
|
||||
const uuidv7Regex = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
||||
export function isUUIDv7(value) {
|
||||
return uuidv7Regex.test(value);
|
||||
}
|
||||
export function toUUIDv7(value) {
|
||||
if (!isUUIDv7(value))
|
||||
return Result.error(new InvalidUUID());
|
||||
return Result.ok(value.toLowerCase());
|
||||
}
|
||||
export function newUUIDv7() {
|
||||
return uuidv7();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue