Skip to content

Commit

Permalink
v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Kathund committed Feb 8, 2024
1 parent d899ae3 commit a026ad1
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 25 deletions.
12 changes: 11 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PORT, url, key, allowConfigGen } from './config.json';
import { loadEndpoints } from './src/functions';
import { existsSync, mkdirSync } from 'fs';
import fileUpload from 'express-fileupload';
import express from 'express';
import express, { Request, Response } from 'express';

if (!existsSync('./src/files')) {
mkdirSync('./src/files');
Expand All @@ -23,6 +23,16 @@ try {
} else {
otherMessage('No endpoints found');
}

app.get('/', async (req: Request, res: Response) => {
try {
return res.status(200).render('pages/index');
} catch (err) {
errorMessage(err as string);
return res.status(500).send({ success: false, message: 'Internal server error' });
}
});

app.listen(PORT, () => {
otherMessage(`Server started on port ${PORT} @ http://localhost:${PORT}`);
if (key === 'API_KEY') {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sharex-api",
"description": "",
"version": "1.0.0",
"version": "1.2.0",
"main": "index.ts",
"scripts": {
"start": "npx tsx index.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/endpoints/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ export default (app: Application) => {
}
apiMessage(req.path, `File ${fileName} found`);
const stats = statSync(filePath);
return res.render('pages/index', {
return res.render('pages/file', {
data: {
name: fileName.split('.')[0],
fileExtension: fileName.split('.')[1],
timestamp: {
raw: stats.birthtimeMs,
unix: stats.birthtimeMs,
Expand Down
14 changes: 14 additions & 0 deletions src/public/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,26 @@ video {
z-index: 2;
}

a {
text-decoration: none;
color: #343434;
}

.homePageText {
font-size: 2rem;
font-weight: 600;
}

@media (prefers-color-scheme: dark) {
body {
background-color: #464646;
color: #dcdcdc;
}

a {
color: #dcdcdc;
}

.container {
filter: drop-shadow(#ffffff1a 20px 20px 30px);
background-color: #363636;
Expand Down
2 changes: 1 addition & 1 deletion src/views/pages/badName.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<link rel="icon" type="image/x-icon" href="../files/favicon.ico">
<link rel="stylesheet" href="../css/index.css">
<meta name="robots" content="noindex">
<title>Missing File</title>
<title>ShareX-API | Bad Name</title>
<meta charset="UTF-8">
</head>

Expand Down
41 changes: 41 additions & 0 deletions src/views/pages/file.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="../files/favicon.ico">
<meta name="twitter:card" content="summary_large_image" />
<meta property="og:image" content="<%= img %>" />
<link rel="stylesheet" href="../css/index.css">
<meta name="theme-color" content="#000000" />
<meta property="og:description" content="" />
<meta property="og:site_name" content="">
<title>ShareX-API | <%= data.name %>.<%= data.fileExtension %></title>
<meta name="robots" content="noindex">
<meta charset="UTF-8">
</head>

<body>
<main>
<div class="container">
<% if (img.endsWith('.mp4')) { %>
<video controls>
<source src="<%= img %>" type="video/mp4"> Your browser does not support the video tag.
</video>
<% } else { %>
<img src="<%= img %>" alt="Image">
<% } %>
<div class="text">
<p>Name - <%= data.name %></p>
<div class="tooltip">
<p>Time - <%= getTime(data.timestamp.unix, Intl.DateTimeFormat().resolvedOptions().timeZone) %></p>
<span class="tooltiptext">UTC - <%= data.timestamp.utc %></span>
</div>
<p>Date - <%= getDate(data.timestamp.unix, Intl.DateTimeFormat().resolvedOptions().timeZone) %></p>
<p>Size - <%= data.size.dynamic %></p>
</div>
</div>
</main>
</body>

</html>
25 changes: 5 additions & 20 deletions src/views/pages/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,20 @@
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="../files/favicon.ico">
<meta name="twitter:card" content="summary_large_image" />
<meta property="og:image" content="<%= img %>" />
<link rel="stylesheet" href="../css/index.css">
<meta name="theme-color" content="#000000" />
<meta property="og:description" content="" />
<meta property="og:site_name" content="">
<title>File - <%= data.name %></title>
<meta name="robots" content="noindex">
<title>ShareX-API | Home</title>
<meta charset="UTF-8">
</head>

<body>
<main>
<div class="container">
<% if (img.endsWith('.mp4')) { %>
<video controls>
<source src="<%= img %>" type="video/mp4"> Your browser does not support the video tag.
</video>
<% } else { %>
<img src="<%= img %>" alt="Image">
<% } %>
<img src="https://images.unsplash.com/photo-1582845512747-e42001c95638" alt="Image of a rubber duck">
<div class="text">
<p>Name - <%= data.name %></p>
<div class="tooltip">
<p>Time - <%= getTime(data.timestamp.unix, Intl.DateTimeFormat().resolvedOptions().timeZone) %></p>
<span class="tooltiptext">UTC - <%= data.timestamp.utc %></span>
</div>
<p>Date - <%= getDate(data.timestamp.unix, Intl.DateTimeFormat().resolvedOptions().timeZone) %></p>
<p>Size - <%= data.size.dynamic %></p>
<p class="homePageText">ShareX-API Made By kathund with ❤️</p>
<a class="homePageText" href="https://github.com/Kathund/ShareX-API">Open Source on github!</a>
<p>Theres nothing much here but heres a duck instead</p>
</div>
</div>
</main>
Expand Down
2 changes: 1 addition & 1 deletion src/views/pages/missingFile.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<link rel="icon" type="image/x-icon" href="../files/favicon.ico">
<link rel="stylesheet" href="../css/index.css">
<meta name="robots" content="noindex">
<title>Missing File</title>
<title>ShareX-API | Missing File</title>
<meta charset="UTF-8">
</head>

Expand Down

0 comments on commit a026ad1

Please sign in to comment.