feat(cleanup): removed built application
This commit is contained in:
parent
157b06ea4b
commit
bdc4616106
23 changed files with 2 additions and 210 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -3,3 +3,5 @@
|
||||||
*.lock
|
*.lock
|
||||||
node_modules/
|
node_modules/
|
||||||
*.pdf
|
*.pdf
|
||||||
|
**/dist/
|
||||||
|
|
||||||
|
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
12
src/icons/dist/app.d.ts
vendored
12
src/icons/dist/app.d.ts
vendored
|
|
@ -1,12 +0,0 @@
|
||||||
import { AutoloadPluginOptions } from '@fastify/autoload';
|
|
||||||
import { FastifyPluginAsync } from 'fastify';
|
|
||||||
export type AppOptions = {} & Partial<AutoloadPluginOptions>;
|
|
||||||
declare const options: AppOptions;
|
|
||||||
declare module 'fastify' {
|
|
||||||
interface FastifyInstance {
|
|
||||||
image_store: string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
declare const app: FastifyPluginAsync<AppOptions>;
|
|
||||||
export default app;
|
|
||||||
export { app, options };
|
|
||||||
31
src/icons/dist/app.js
vendored
31
src/icons/dist/app.js
vendored
|
|
@ -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 };
|
|
||||||
1
src/icons/dist/app.js.map
vendored
1
src/icons/dist/app.js.map
vendored
|
|
@ -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,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACjD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AAO1C,MAAM,OAAO,GAAe,EAC3B,CAAA;AASD,MAAM,GAAG,GAAmC,KAAK,EAChD,OAAO,EACP,IAAI,EACY,EAAE;IAGlB,KAAK,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;IACnC,KAAK,OAAO,CAAC,QAAQ,CAAC,eAAe,EAAE,EAAE,CAAC,CAAA;IAC1C,KAAK,OAAO,CAAC,QAAQ,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAA;IAI3C,KAAK,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC1C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,YAAY,CAAC;QACjE,OAAO,CAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,CAAA;QAC5C,MAAM,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACtD,CAAC,CAAC,CAAC,CAAA;IAUH,KAAK,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE;QAC/B,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC;QACpC,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACd,CAAC,CAAA;IAKF,KAAK,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE;QAC/B,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC;QACnC,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACd,CAAC,CAAA;AAEH,CAAC,CAAA;AAED,eAAe,GAAG,CAAA;AAClB,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAA"}
|
|
||||||
3
src/icons/dist/plugins/sensible.d.ts
vendored
3
src/icons/dist/plugins/sensible.d.ts
vendored
|
|
@ -1,3 +0,0 @@
|
||||||
import sensible from '@fastify/sensible';
|
|
||||||
declare const _default: import("fastify").FastifyPluginCallback<sensible.FastifySensibleOptions, import("fastify").RawServerDefault, import("fastify").FastifyTypeProviderDefault, import("fastify").FastifyBaseLogger>;
|
|
||||||
export default _default;
|
|
||||||
5
src/icons/dist/plugins/sensible.js
vendored
5
src/icons/dist/plugins/sensible.js
vendored
|
|
@ -1,5 +0,0 @@
|
||||||
import fp from 'fastify-plugin';
|
|
||||||
import sensible from '@fastify/sensible';
|
|
||||||
export default fp(async (fastify) => {
|
|
||||||
fastify.register(sensible);
|
|
||||||
});
|
|
||||||
1
src/icons/dist/plugins/sensible.js.map
vendored
1
src/icons/dist/plugins/sensible.js.map
vendored
|
|
@ -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"}
|
|
||||||
3
src/icons/dist/routes/set/index.d.ts
vendored
3
src/icons/dist/routes/set/index.d.ts
vendored
|
|
@ -1,3 +0,0 @@
|
||||||
import { FastifyPluginAsync } from 'fastify';
|
|
||||||
declare const example: FastifyPluginAsync;
|
|
||||||
export default example;
|
|
||||||
33
src/icons/dist/routes/set/index.js
vendored
33
src/icons/dist/routes/set/index.js
vendored
|
|
@ -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;
|
|
||||||
1
src/icons/dist/routes/set/index.js.map
vendored
1
src/icons/dist/routes/set/index.js.map
vendored
|
|
@ -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"}
|
|
||||||
1
src/icons/dist/run.d.ts
vendored
1
src/icons/dist/run.d.ts
vendored
|
|
@ -1 +0,0 @@
|
||||||
export {};
|
|
||||||
14
src/icons/dist/run.js
vendored
14
src/icons/dist/run.js
vendored
|
|
@ -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();
|
|
||||||
1
src/icons/dist/run.js.map
vendored
1
src/icons/dist/run.js.map
vendored
|
|
@ -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"}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue