datasquirel/index.ts
Benjamin Toby e9bb9fb07f Updates
2025-02-19 20:01:50 +01:00

134 lines
4.2 KiB
TypeScript

import { ServerlessMysql } from "serverless-mysql";
declare global {
var DSQL_DB_CONN: ServerlessMysql | undefined;
var DSQL_READ_ONLY_DB_CONN: ServerlessMysql | undefined;
var DSQL_FULL_ACCESS_DB_CONN: ServerlessMysql | undefined;
var DSQL_USE_LOCAL: boolean | undefined;
var ERROR_CALLBACK: ErrorCallback | undefined;
}
import get from "./package-shared/actions/get";
import post from "./package-shared/actions/post";
import getSchema from "./package-shared/actions/get-schema";
import uploadImage from "./package-shared/actions/upload-image";
import uploadFile from "./package-shared/actions/upload-file";
import deleteFile from "./package-shared/actions/delete-file";
import createUser from "./package-shared/actions/users/add-user";
import updateUser from "./package-shared/actions/users/update-user";
import loginUser from "./package-shared/actions/users/login-user";
import sendEmailCode from "./package-shared/actions/users/send-email-code";
import logoutUser from "./package-shared/actions/users/logout-user";
import userAuth from "./package-shared/actions/users/user-auth";
import reAuthUser from "./package-shared/actions/users/reauth-user";
import getUser from "./package-shared/actions/users/get-user";
import loginWithGoogle from "./package-shared/actions/users/social/google-auth";
import loginWithGithub from "./package-shared/actions/users/social/github-auth";
import getToken from "./package-shared/actions/users/get-token";
import validateToken from "./package-shared/actions/users/validate-token";
import datasquirelClient from "./client";
import sqlGenerator from "./package-shared/functions/dsql/sql/sql-generator";
import sqlInsertGenerator from "./package-shared/functions/dsql/sql/sql-insert-generator";
import sqlDeleteGenerator from "./package-shared/functions/dsql/sql/sql-delete-generator";
import trimSql from "./package-shared/utils/trim-sql";
import parseCookies from "./package-shared/utils/backend/parseCookies";
import httpRequest from "./package-shared/functions/backend/httpRequest";
import connDbHandler from "./package-shared/utils/db/conn-db-handler";
import encrypt from "./package-shared/functions/dsql/encrypt";
import decrypt from "./package-shared/functions/dsql/decrypt";
import hashPassword from "./package-shared/functions/dsql/hashPassword";
import validateTempEmailCode from "./package-shared/actions/users/validate-temp-email-code";
import deleteUser from "./package-shared/actions/users/delete-user";
import dsqlCrud from "./package-shared/utils/data-fetching/crud";
import dsqlMethodCrud from "./package-shared/utils/data-fetching/method-crud";
import debugLog from "./package-shared/utils/logging/debug-log";
import { ErrorCallback } from "./package-shared/types";
/**
* User Functions Object
*/
const user = {
createUser: createUser,
deleteUser,
loginUser: loginUser,
sendEmailCode: sendEmailCode,
logoutUser: logoutUser,
userAuth: userAuth,
reAuthUser: reAuthUser,
updateUser: updateUser,
getUser: getUser,
getToken: getToken,
validateToken: validateToken,
validateTempEmailCode,
social: {
loginWithGoogle: loginWithGoogle,
loginWithGithub: loginWithGithub,
},
};
/**
* Media Functions Object
*/
const media = {
uploadImage: uploadImage,
uploadFile: uploadFile,
deleteFile: deleteFile,
};
/**
* SQL Utils
*/
const sql = {
sqlGenerator,
sqlInsertGenerator,
sqlDeleteGenerator,
trim: trimSql,
};
/**
* Main Export
*/
const datasquirel = {
/**
* Get Action
*/
get,
/**
* Post Action
*/
post,
media,
user,
getSchema,
client: datasquirelClient,
sql,
utils: {
crypto: {
encrypt,
decrypt,
hashPassword,
},
parseCookies,
httpRequest,
connDbHandler,
debugLog,
},
/**
* Run Crud actions `get`, `insert`, `update`, `delete`
* @note *Requires global variables `DSQL_USE_LOCAL` and `DSQL_DB_CONN`
*/
crud: dsqlCrud,
/**
* Run Crud based on request Methods `GET`, `POST`, `PUT`, `PATCH`
* @note *Requires global variables `DSQL_USE_LOCAL` and `DSQL_DB_CONN`
*/
methodCrud: dsqlMethodCrud,
};
export default datasquirel;