mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 13:04:23 +00:00
Learn some basic algorithms via
https://github.com/trekhleb/javascript-algorithms?tab=readme-ov-file super cool repo! This algorithm will just run on the client, if it isn't my server will blow up :( Maybe I will just make a postgres db that sends the users processing info to save other users processing power?
This commit is contained in:
parent
2f2b4b1d19
commit
edd8e5b05a
13 changed files with 127 additions and 462 deletions
6
server/api/contentcheck/kidunfriendlycontent.ts
Normal file
6
server/api/contentcheck/kidunfriendlycontent.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
import sql from "~/server/components/postgres";
|
||||
export default defineEventHandler(async (event) => {
|
||||
return {
|
||||
words: ["violence"],
|
||||
};
|
||||
});
|
|
@ -1,6 +1,9 @@
|
|||
import sql from "~/server/components/postgres";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import argon2 from "argon2";
|
||||
|
||||
const defaultAvatarUrl = "https://s3.yhw.tw/news-analyze/avatar/default.png";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const salt = process.env.PASSWORD_HASH_SALT;
|
||||
if (!salt) {
|
||||
|
@ -30,23 +33,35 @@ export default defineEventHandler(async (event) => {
|
|||
select * from users
|
||||
where user = ${username}`;
|
||||
if (!fetchUserInfo) {
|
||||
/*const createNewUser = await sql`
|
||||
insert
|
||||
`*/
|
||||
// INSERT USER CREATING STUFF HERE LATER
|
||||
const createNewUser = await sql`
|
||||
insert into users (uuid, username, passwordhash)
|
||||
values (${uuidv4()}, ${username}, ${hashedPassword})
|
||||
`;
|
||||
if (!createNewUser) {
|
||||
return {
|
||||
error: "CANNOT_CREATE_NEW_USER",
|
||||
};
|
||||
}
|
||||
} else {
|
||||
if (fetchUserInfo.password !== hashedPassword) {
|
||||
return {
|
||||
error: "PASSWORD_NO_MATCH",
|
||||
};
|
||||
} else {
|
||||
const newToken = uuidv4();
|
||||
const newToken64 = atob(newToken);
|
||||
const saveNewToken = await sql``;
|
||||
}
|
||||
const newToken = uuidv4();
|
||||
const newToken64 = atob(newToken);
|
||||
const saveNewToken = await sql`
|
||||
insert into usertokens
|
||||
`;
|
||||
if (!saveNewToken) {
|
||||
return {
|
||||
user: fetchUserInfo.user,
|
||||
error: "CANNOT_CREATE_NEW_TOKEN",
|
||||
};
|
||||
}
|
||||
return {
|
||||
user: fetchUserInfo.user,
|
||||
token: newToken,
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
return {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue