From bdc4616106acb15608c003e19951847d9d52a50d Mon Sep 17 00:00:00 2001 From: Maieul BOYER Date: Wed, 30 Jul 2025 14:07:44 +0200 Subject: [PATCH] feat(cleanup): removed built application --- .gitignore | 2 ++ src/@shared/dist/auth.d.ts | 2 -- src/@shared/dist/auth.js | 3 -- src/@shared/dist/database/a.d.ts | 23 ------------- src/@shared/dist/database/a.js | 43 ------------------------- src/@shared/dist/database/index.d.ts | 1 - src/@shared/dist/database/index.js | 1 - src/@shared/dist/database/init.sql.d.ts | 2 -- src/@shared/dist/database/init.sql.js | 1 - src/@shared/dist/uuid/index.d.ts | 10 ------ src/@shared/dist/uuid/index.js | 18 ----------- src/icons/dist/app.d.ts | 12 ------- src/icons/dist/app.js | 31 ------------------ src/icons/dist/app.js.map | 1 - src/icons/dist/plugins/sensible.d.ts | 3 -- src/icons/dist/plugins/sensible.js | 5 --- src/icons/dist/plugins/sensible.js.map | 1 - src/icons/dist/routes/set/index.d.ts | 3 -- src/icons/dist/routes/set/index.js | 33 ------------------- src/icons/dist/routes/set/index.js.map | 1 - src/icons/dist/run.d.ts | 1 - src/icons/dist/run.js | 14 -------- src/icons/dist/run.js.map | 1 - 23 files changed, 2 insertions(+), 210 deletions(-) delete mode 100644 src/@shared/dist/auth.d.ts delete mode 100644 src/@shared/dist/auth.js delete mode 100644 src/@shared/dist/database/a.d.ts delete mode 100644 src/@shared/dist/database/a.js delete mode 100644 src/@shared/dist/database/index.d.ts delete mode 100644 src/@shared/dist/database/index.js delete mode 100644 src/@shared/dist/database/init.sql.d.ts delete mode 100644 src/@shared/dist/database/init.sql.js delete mode 100644 src/@shared/dist/uuid/index.d.ts delete mode 100644 src/@shared/dist/uuid/index.js delete mode 100644 src/icons/dist/app.d.ts delete mode 100644 src/icons/dist/app.js delete mode 100644 src/icons/dist/app.js.map delete mode 100644 src/icons/dist/plugins/sensible.d.ts delete mode 100644 src/icons/dist/plugins/sensible.js delete mode 100644 src/icons/dist/plugins/sensible.js.map delete mode 100644 src/icons/dist/routes/set/index.d.ts delete mode 100644 src/icons/dist/routes/set/index.js delete mode 100644 src/icons/dist/routes/set/index.js.map delete mode 100644 src/icons/dist/run.d.ts delete mode 100644 src/icons/dist/run.js delete mode 100644 src/icons/dist/run.js.map diff --git a/.gitignore b/.gitignore index 09189d1..f7fff56 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ *.lock node_modules/ *.pdf +**/dist/ + diff --git a/src/@shared/dist/auth.d.ts b/src/@shared/dist/auth.d.ts deleted file mode 100644 index b39a703..0000000 --- a/src/@shared/dist/auth.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import { FastifyInstance } from 'fastify'; -export default function (_fastify: FastifyInstance, _options: any): Promise; diff --git a/src/@shared/dist/auth.js b/src/@shared/dist/auth.js deleted file mode 100644 index 2b670a0..0000000 --- a/src/@shared/dist/auth.js +++ /dev/null @@ -1,3 +0,0 @@ -export default async function (_fastify, _options) { - console.log("inside the plugin !"); -} diff --git a/src/@shared/dist/database/a.d.ts b/src/@shared/dist/database/a.d.ts deleted file mode 100644 index 0524742..0000000 --- a/src/@shared/dist/database/a.d.ts +++ /dev/null @@ -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; -} -declare module 'fastify' { - interface FastifyInstance { - db: Database; - } -} -export type DatabaseOption = { - path: string; -}; -export declare const uDatabase: import("fastify").FastifyPluginCallback; -export default uDatabase; diff --git a/src/@shared/dist/database/a.js b/src/@shared/dist/database/a.js deleted file mode 100644 index ea6ea5e..0000000 --- a/src/@shared/dist/database/a.js +++ /dev/null @@ -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; diff --git a/src/@shared/dist/database/index.d.ts b/src/@shared/dist/database/index.d.ts deleted file mode 100644 index cb0ff5c..0000000 --- a/src/@shared/dist/database/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/@shared/dist/database/index.js b/src/@shared/dist/database/index.js deleted file mode 100644 index cb0ff5c..0000000 --- a/src/@shared/dist/database/index.js +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/@shared/dist/database/init.sql.d.ts b/src/@shared/dist/database/init.sql.d.ts deleted file mode 100644 index e8252fe..0000000 --- a/src/@shared/dist/database/init.sql.d.ts +++ /dev/null @@ -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; diff --git a/src/@shared/dist/database/init.sql.js b/src/@shared/dist/database/init.sql.js deleted file mode 100644 index c6aab82..0000000 --- a/src/@shared/dist/database/init.sql.js +++ /dev/null @@ -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"; diff --git a/src/@shared/dist/uuid/index.d.ts b/src/@shared/dist/uuid/index.d.ts deleted file mode 100644 index ddbdd1f..0000000 --- a/src/@shared/dist/uuid/index.d.ts +++ /dev/null @@ -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; -export declare function newUUIDv7(): UUIDv7; diff --git a/src/@shared/dist/uuid/index.js b/src/@shared/dist/uuid/index.js deleted file mode 100644 index e2646a3..0000000 --- a/src/@shared/dist/uuid/index.js +++ /dev/null @@ -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(); -} diff --git a/src/icons/dist/app.d.ts b/src/icons/dist/app.d.ts deleted file mode 100644 index 97ecd65..0000000 --- a/src/icons/dist/app.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { AutoloadPluginOptions } from '@fastify/autoload'; -import { FastifyPluginAsync } from 'fastify'; -export type AppOptions = {} & Partial; -declare const options: AppOptions; -declare module 'fastify' { - interface FastifyInstance { - image_store: string; - } -} -declare const app: FastifyPluginAsync; -export default app; -export { app, options }; diff --git a/src/icons/dist/app.js b/src/icons/dist/app.js deleted file mode 100644 index 3183c25..0000000 --- a/src/icons/dist/app.js +++ /dev/null @@ -1,31 +0,0 @@ -import * as path from 'node:path'; -import AutoLoad from '@fastify/autoload'; -import { fileURLToPath } from 'node:url'; -import fastifyFormBody from '@fastify/formbody'; -import fastifyMultipart from '@fastify/multipart'; -import { mkdir } from 'node:fs/promises'; -import fp from 'fastify-plugin'; -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); -const options = {}; -const app = async (fastify, opts) => { - void fastify.register(fastifyFormBody, {}); - void fastify.register(fastifyMultipart, {}); - void fastify.register(fp(async (fastify) => { - const image_store = process.env.USER_ICONS_STORE ?? "/tmp/icons"; - fastify.decorate('image_store', image_store); - await mkdir(fastify.image_store, { recursive: true }); - })); - void fastify.register(AutoLoad, { - dir: path.join(__dirname, 'plugins'), - options: opts, - forceESM: true - }); - void fastify.register(AutoLoad, { - dir: path.join(__dirname, 'routes'), - options: opts, - forceESM: true - }); -}; -export default app; -export { app, options }; diff --git a/src/icons/dist/app.js.map b/src/icons/dist/app.js.map deleted file mode 100644 index 7c38c1f..0000000 --- a/src/icons/dist/app.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,QAAmC,MAAM,mBAAmB,CAAA;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC/B,OAAO,QAAQ,MAAM,QAAQ,CAAA;AAE7B,MAAM,UAAU,GAAG,aAAa,CAAC,MA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/icons/dist/plugins/sensible.d.ts b/src/icons/dist/plugins/sensible.d.ts deleted file mode 100644 index b5c8bb4..0000000 --- a/src/icons/dist/plugins/sensible.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import sensible from '@fastify/sensible'; -declare const _default: import("fastify").FastifyPluginCallback; -export default _default; diff --git a/src/icons/dist/plugins/sensible.js b/src/icons/dist/plugins/sensible.js deleted file mode 100644 index 6ad7356..0000000 --- a/src/icons/dist/plugins/sensible.js +++ /dev/null @@ -1,5 +0,0 @@ -import fp from 'fastify-plugin'; -import sensible from '@fastify/sensible'; -export default fp(async (fastify) => { - fastify.register(sensible); -}); diff --git a/src/icons/dist/plugins/sensible.js.map b/src/icons/dist/plugins/sensible.js.map deleted file mode 100644 index 45a9a19..0000000 --- a/src/icons/dist/plugins/sensible.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"sensible.js","sourceRoot":"","sources":["../../src/plugins/sensible.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC/B,OAAO,QAAoC,MAAM,mBAAmB,CAAA;AAOpE,eAAe,EAAE,CAAyB,KAAK,EAAE,OAAO,EAAE,EAAE;IAC1D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAC5B,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/src/icons/dist/routes/set/index.d.ts b/src/icons/dist/routes/set/index.d.ts deleted file mode 100644 index 6bf9935..0000000 --- a/src/icons/dist/routes/set/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { FastifyPluginAsync } from 'fastify'; -declare const example: FastifyPluginAsync; -export default example; diff --git a/src/icons/dist/routes/set/index.js b/src/icons/dist/routes/set/index.js deleted file mode 100644 index 09aca6e..0000000 --- a/src/icons/dist/routes/set/index.js +++ /dev/null @@ -1,33 +0,0 @@ -import { join } from 'node:path'; -import { open } from 'node:fs/promises'; -import fastifyRawBody from 'fastify-raw-body'; -import sharp from 'sharp'; -const example = async (fastify, opts) => { - await fastify.register(fastifyRawBody, { encoding: false }); - fastify.post('/:userid', { config: { rawBody: true, encoding: false } }, async function (request, reply) { - const userid = request.params['userid']; - if (userid === undefined) { - return await reply.code(403); - } - const image_store = fastify.getDecorator('image_store'); - const image_path = join(image_store, userid); - try { - let img = sharp(request.rawBody); - img.resize({ - height: 512, - width: 512, - fit: 'fill', - }); - const data = await img.png({ compressionLevel: 6 }).toBuffer(); - let image_file = await open(image_path, "w", 0o666); - await image_file.write(data); - await image_file.close(); - } - catch (e) { - fastify.log.error(`Error: ${e}`); - reply.code(400); - return { status: "error", message: e.toString() }; - } - }); -}; -export default example; diff --git a/src/icons/dist/routes/set/index.js.map b/src/icons/dist/routes/set/index.js.map deleted file mode 100644 index 8bfe255..0000000 --- a/src/icons/dist/routes/set/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/routes/set/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,OAAO,GAAuB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAiB,EAAE;IAI1E,MAAM,OAAO,CAAC,QAAQ,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IAI5D,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,WAAU,OAAO,EAAE,KAAK;QAGrG,MAAM,MAAM,GAAwB,OAAO,CAAC,MAAc,CAAC,QAAQ,CAAC,CAAC;QACrE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC9B,CAAC;QACD,MAAM,WAAW,GAAW,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,CAAA;QAC/D,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;QAC5C,IAAI,CAAC;YACJ,IAAI,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,OAAiB,CAAC,CAAC;YAC3C,GAAG,CAAC,MAAM,CAAC;gBACV,MAAM,EAAE,GAAG;gBACX,KAAK,EAAE,GAAG;gBACV,GAAG,EAAE,MAAM;aACX,CAAC,CAAA;YACF,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAA;YAC9D,IAAI,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;YACnD,MAAM,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC7B,MAAM,UAAU,CAAC,KAAK,EAAE,CAAA;QACzB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YACjC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAChB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;QACnD,CAAC;IACF,CAAC,CAAC,CAAA;AACH,CAAC,CAAA;AAED,eAAe,OAAO,CAAA"} \ No newline at end of file diff --git a/src/icons/dist/run.d.ts b/src/icons/dist/run.d.ts deleted file mode 100644 index cb0ff5c..0000000 --- a/src/icons/dist/run.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/icons/dist/run.js b/src/icons/dist/run.js deleted file mode 100644 index c34bcc8..0000000 --- a/src/icons/dist/run.js +++ /dev/null @@ -1,14 +0,0 @@ -import fastify from "fastify"; -import app from './app.js'; -const start = async () => { - const f = fastify({ logger: true }); - try { - await f.register(app, {}); - await f.listen({ port: 80, host: '0.0.0.0' }); - } - catch (err) { - f.log.error(err); - process.exit(1); - } -}; -start(); diff --git a/src/icons/dist/run.js.map b/src/icons/dist/run.js.map deleted file mode 100644 index 904647e..0000000 --- a/src/icons/dist/run.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAEA,OAAO,OAA4B,MAAM,SAAS,CAAC;AACnD,OAAO,GAAG,MAAM,UAAU,CAAA;AAE1B,MAAM,KAAK,GAAG,KAAK,IAAI,EAAE;IACxB,MAAM,CAAC,GAAoB,OAAO,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC;IACnD,IAAI,CAAC;QACJ,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC1B,MAAM,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;IAC9C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAChB,CAAC;AACF,CAAC,CAAA;AACD,KAAK,EAAE,CAAA"} \ No newline at end of file