Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: The last of the API stuff #153

Draft
wants to merge 7 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ src/configs/*

src/migrate.ts
src/fixtest.ts

RateLimits.ts
Binary file modified bun.lockb
Binary file not shown.
Binary file modified lib/domain_checker.dll
Binary file not shown.
Binary file modified lib/domain_checker.so
Binary file not shown.
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,29 @@
"version": "0.1.0",
"main": "src/index.ts",
"dependencies": {
"@aws-sdk/client-s3": "^3.637.0",
"@aws-sdk/s3-request-presigner": "^3.637.0",
"@elysiajs/cors": "1.1.0",
"@elysiajs/server-timing": "^1.0.2",
"@kastelapp/cassandra-driver": "^4.6.24",
"@kastelll/util": "^0.2.7",
"@opensearch-project/opensearch": "^2.12.0",
"@react-email/components": "0.0.23",
"@react-email/render": "1.0.0",
"@sentry/bun": "8.22.0",
"@types/mime": "^4.0.0",
"amqplib": "^0.10.3",
"archiver": "^7.0.1",
"chokidar": "^3.6.0",
"elysia": "^1.0.10",
"jsonschema": "^1.4.1",
"long": "^5.2.3",
"minio": "^8.0.1",
"mime": "^4.0.4",
"nodemailer": "^6.9.13",
"react-email": "3.0.1",
"simple-git": "^3.24.0",
"undici": "6.19.7"
"undici": "6.19.7",
"winston": "^3.14.2"
},
"devDependencies": {
"@biomejs/biome": "1.8.3",
Expand All @@ -45,7 +50,7 @@
"compile-rust": "./compile.sh",
"format": "biome format --write ./src",
"lint": "biome lint --write ./src",
"prepublish": "bun run format && bun run lint"
"prepublish": "bun run format && bun run lint"
},
"keywords": ["chatting"],
"engines": {
Expand All @@ -64,6 +69,7 @@
"url": "https://github.com/KastelApp/backend.git"
},
"patchedDependencies": {
"@kastelapp/[email protected]": "patches/@kastelapp%[email protected]"
"@kastelapp/[email protected]": "patches/@kastelapp%[email protected]",
"@types/[email protected]": "patches/@types%[email protected]"
}
}
22 changes: 22 additions & 0 deletions patches/@types%[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/index.d.ts b/index.d.ts
index 1b03b789e74e889d5917e4ef6e412dd18e884611..de34cfef27104af3c5f4b7be2fd7e358356ed4b5 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -11,6 +11,8 @@ import type {
} from "amqplib/properties";
export * from "amqplib/properties";

+type StringAlike = string & {}
+
export interface Connection extends events.EventEmitter {
close(): Promise<void>;
createChannel(): Promise<Channel>;
@@ -52,7 +54,7 @@ export interface Channel extends events.EventEmitter {

assertExchange(
exchange: string,
- type: "direct" | "topic" | "headers" | "fanout" | "match" | string,
+ type: "direct" | "topic" | "headers" | "fanout" | "match" | StringAlike,
options?: Options.AssertExchange,
): Promise<Replies.AssertExchange>;
checkExchange(exchange: string): Promise<Replies.Empty>;
14 changes: 5 additions & 9 deletions src/Emails/ForgotPassword.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Body, Button, Container, Head, Heading, Hr, Html, Img, Preview, Section, Text } from "@react-email/components";
import { imrUrl } from "./Image.tsx";

const styles = {
main: {
Expand Down Expand Up @@ -37,20 +36,19 @@ const styles = {
lineHeight: "1.5rem",
},
btnContainer: {
display: "flex",
flexDirection: "column",
alignItems: "center",
margin: "27px auto",
width: "auto",
},
btn: {
textAlign: "center" as const,
margin: "0 auto",
backgroundColor: "#9AA9E0",
color: "#161922",
padding: "1rem",
borderRadius: "1rem",
textDecoration: "none",
fontWeight: "bold",
fontSize: ".8rem",
// center
display: "flex",
},
btnText: {
textAlign: "center",
Expand All @@ -75,16 +73,14 @@ const forgotPassword = (username: string, resetPasswordUrl: string) => {
<Body style={styles.main}>
<Container style={styles.container}>
<div style={styles.logo.container}>
<Img src={imrUrl} alt="Kastel Logo" style={styles.logo.icon} />
<Img src={"https://media.kastelapp.com/logo/icon-0.png"} alt="Kastel Logo" style={styles.logo.icon} />
<Heading style={styles.logo.text}>Kastel</Heading>
</div>
<Text style={styles.header}>Hello {username},</Text>
<br />
<Text style={styles.paragraph}>
We received a request to reset your password. If you did not make this request, please ignore this email.
Otherwise, you can reset your password using the button below.
</Text>
<br />
<Hr style={styles.hr} />
<Text style={styles.btnText}>Click the button below to reset your password.</Text>
<Section style={styles.btnContainer}>
Expand Down
2 changes: 0 additions & 2 deletions src/Emails/Image.tsx

This file was deleted.

135 changes: 135 additions & 0 deletions src/Emails/RecentLogin.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,136 @@
// ? Note: This is when theres a new login with an IP that has not been used before, or has not been used in a while

import { Body, Container, Head, Heading, Hr, Html, Img, Preview, Text } from "@react-email/components";

interface RecursiveTypes {
[key: string]: RecursiveTypes | React.CSSProperties;
}

const styles = {
main: {
backgroundColor: "#161922",
fontFamily: "sans-serif",
},
container: {
backgroundColor: "#101319",
color: "#CFDBFF",
padding: "20px 20px 20px",
margin: "0 auto",
},
logo: {
icon: {
width: "50px",
height: "50px",
borderRadius: "50%",
},
text: {
fontSize: "2rem",
fontWeight: "bold",
marginLeft: "1rem",
},
container: {
display: "flex",
alignItems: "center",
},
},
header: {
fontSize: "1.2rem",
lineHeight: "1.5rem",
},
paragraph: {
fontSize: "1rem",
lineHeight: "1.5rem",
},
locationContainer: {
width: "auto",
margin: "12px",
},
btnContainer: {
margin: "27px auto",
width: "auto",
marginBottom: "0px",
},
btn: {
textAlign: "center" as const,
margin: "0 auto",
backgroundColor: "#9AA9E0",
color: "#161922",
padding: "1rem",
borderRadius: "1rem",
textDecoration: "none",
fontWeight: "bold",
fontSize: ".8rem",
},
btnText: {
textAlign: "center",
fontSize: "0.8rem",
color: "#CFDBFF",
},
hr: {
borderColor: "#262F40",
margin: "15px 0",
},
footer: {
fontSize: ".7rem",
textAlign: "center",
},
} satisfies RecursiveTypes;

const recentLogin = (username: string, formattedDate: string, device: string, platform: string, ip: string) => {
return (
<Html>
<Head />
<Preview>Someone logged into your account from a new location</Preview>
<Body style={styles.main}>
<Container style={styles.container}>
<div style={styles.logo.container}>
<Img src={"https://media.kastelapp.com/logo/icon-0.png"} alt="Kastel Logo" style={styles.logo.icon} />
<Heading style={styles.logo.text}>Kastel</Heading>
</div>
<Text style={styles.header}>Hey {username},</Text>
<Text style={styles.paragraph}>
We've detected a login to your account from a new location. If this was you, feel free to disregard this
message. Below you can find the details of the login:
</Text>
<Hr style={styles.hr} />
<div style={styles.locationContainer}>
<Text style={styles.paragraph}>
<b>Time: </b>
{formattedDate}
</Text>
<Text style={{ ...styles.paragraph, marginTop: -5 }}>
<b>Device: </b>
{/* i.e macbook, windows, mobile etc */}
{device}
</Text>
<Text style={{ ...styles.paragraph, marginTop: -5 }}>
<b>Platform: </b>
{/* what platform they logged in by, i.e the web, desktop app, mobile app etc */}
{platform}
</Text>
<Text style={{ ...styles.paragraph, marginTop: -5 }}>
<b>IP: </b>
{ip}
</Text>
{/* <Text for now its disabled until we work on the IP location
style={{
fontSize: 14,
marginTop: -5,
}}
>
*Approximate geographic location based on IP address: test
</Text> */}
</div>
{/* <Section style={styles.btnContainer}>
<Button style={styles.btn}>
Learn More
</Button>
</Section> */}
<Text style={styles.footer}>If this was not you please reset your password immediately.</Text>
</Container>
</Body>
</Html>
);
};

export default recentLogin;
40 changes: 10 additions & 30 deletions src/Emails/Registration.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
// ? Note: This is for when you have registered an account, it welcomes you and has a link to verify your email

import {
Body,
Button,
Container,
Head,
Heading,
Hr,
Html,
Img,
Link,
Preview,
Section,
Text,
} from "@react-email/components";
import { imrUrl } from "./Image.tsx";
import { Body, Button, Container, Head, Heading, Hr, Html, Img, Preview, Section, Text } from "@react-email/components";

const styles = {
main: {
Expand Down Expand Up @@ -52,55 +38,52 @@ const styles = {
lineHeight: "1.5rem",
},
btnContainer: {
display: "flex",
flexDirection: "column",
alignItems: "center",
margin: "27px auto",
width: "auto",
marginBottom: "0px",
},
btn: {
textAlign: "center" as const,
margin: "0 auto",
backgroundColor: "#9AA9E0",
color: "#161922",
padding: "1rem",
borderRadius: "1rem",
textDecoration: "none",
fontWeight: "bold",
fontSize: ".8rem",
// center
display: "flex",
},
btnText: {
textAlign: "center",
fontSize: "0.8rem",
color: "#CFDBFF",
},
hr: {
// HR: Display a divider that separates content areas in your email.
borderColor: "#262F40",
margin: "15px 0",
},
footer: {
fontSize: ".6rem",
fontSize: ".7rem",
textAlign: "center",
},
} as const;

const registration = (username: string, verifyUrl: string, deleteAccountUrl: string) => {
const registration = (username: string, verifyUrl: string) => {
return (
<Html>
<Head />
<Preview>Welcome to Kastel, Verify your email to get started!</Preview>
<Body style={styles.main}>
<Container style={styles.container}>
<div style={styles.logo.container}>
<Img src={imrUrl} alt="Kastel Logo" style={styles.logo.icon} />
<Img src={"https://media.kastelapp.com/logo/icon-0.png"} alt="Kastel Logo" style={styles.logo.icon} />
<Heading style={styles.logo.text}>Kastel</Heading>
</div>
<Text style={styles.header}>Welcome to Kastel, {username}!</Text>
<br />
<Text style={styles.paragraph}>
Thank you for signing up to Kastel. We are very excited to have you here, I hope you will enjoy our
community.
</Text>
<br />
<Hr style={styles.hr} />
<Text style={styles.btnText}>
Before you can truly enjoy Kastel, you'll need to verify your email. Don't worry, it's easy; Just click the
Expand All @@ -111,10 +94,7 @@ const registration = (username: string, verifyUrl: string, deleteAccountUrl: str
Verify Email
</Button>
</Section>
<Text style={styles.footer}>
If you did not sign up for kastel, please click on this link to delete the account{" "}
<Link href={deleteAccountUrl}>Delete Account</Link>
</Text>
<Text style={styles.footer}>If you did not sign up for kastel, please ignore this email! </Text>
</Container>
</Body>
</Html>
Expand Down
Loading