Skip to content

Commit c37003b

Browse files
committed
feat(project): migrate to TypeScript
1 parent f941eb4 commit c37003b

File tree

19 files changed

+264
-226
lines changed

19 files changed

+264
-226
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

.eslintrc.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/docker.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ jobs:
2626
- name: Build and Publish head Docker image
2727
uses: VaultVulp/[email protected]
2828
with:
29-
github-token: ${{ secrets.GITHUB_TOKEN }}
30-
image-name: discord-captcha-site
31-
image-tag: ${{ github.ref_name }}
29+
github-token: ${{ secrets.GITHUB_TOKEN }}
30+
image-name: discord-captcha-bot
31+
image-tag: ${{ github.ref_name }}

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ replit.nix
1717
.env.test.local
1818
.env.production.local
1919
/cache/
20-
package-lock.json
21-
bun.lockb
20+
dist

Dockerfile

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
FROM node:lts-alpine
1+
FROM node:lts-alpine AS build
22

33
WORKDIR /app
44

5+
COPY package.json package-lock.json ./
6+
7+
RUN npm ci
8+
59
COPY . .
610

7-
RUN npm install --omit=dev
11+
RUN npm run build
12+
13+
FROM node:lts-alpine AS production
14+
15+
WORKDIR /app
16+
17+
COPY --from=build /app/package.json /app/package-lock.json ./
18+
19+
RUN npm ci --omit=dev
820

9-
EXPOSE ${PORT}
21+
# COPY assets and html
22+
COPY --from=build /app/assets ./assets
23+
COPY --from=build /app/html ./html
24+
COPY --from=build /app/dist ./dist
1025

11-
CMD ["npm", "start"]
26+
CMD ["node", "dist/index.js"]

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ A powerful, advanced captcha verification system for new members in a Discord se
1919
## Docker setup
2020

2121
If you want to run this application without installing Node.js or other tools, you can use Docker to run it. Usage:
22+
2223
```
2324
docker run \
2425
-e VERIFIED_ROLE_ID=x \
@@ -34,13 +35,13 @@ docker run \
3435
-e CALLBACK_URL=x \
3536
-e CLIENT_SECRET=x \
3637
-e TOKEN=x \
37-
ghcr.io/ckt1031/discord-captcha-site
38+
ghcr.io/ckt1031/discord-captcha-bot
3839
```
3940

4041
## Installation
4142

4243
1. Clone the repository
43-
2. Install the dependencies with `npm install` or `yarn`
44+
2. Install the dependencies with `npm install`
4445

4546
## Environment Variables
4647

@@ -76,15 +77,14 @@ ghcr.io/ckt1031/discord-captcha-site
7677
6. The user will have to complete the captcha
7778
7. After the user completes the captcha, they will be given the `Verified` role and notified in the DMs
7879

79-
## Production Deployment
80-
81-
1. Install [PM2](https://pm2.keymetrics.io) with `npm install pm2 -g` or `yarn global add pm2`
82-
2. Start the server with `pm2 start ecosystem.config.js`
83-
3. Run command `pm2 start --max-memory-restart 300M --attach npm -- run start`
84-
4. (Optional) Run command `pm2 startup` to enable startup on boot
85-
8680
# Screenshots
8781

8882
## Captcha Verification Page
8983

90-
![Captcha Verification Page](./screenshots/verify-page.png)
84+
Light Mode:
85+
86+
![Captcha Verification Page](https://imgur.com/VnCbk5V.png)
87+
88+
Dark Mode:
89+
90+
![Captcha Verification Page (Dark)](https://imgur.com/ory13FX.png)

assets/style.css

Lines changed: 0 additions & 39 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import globals from 'globals';
2+
import pluginJs from '@eslint/js';
3+
import ts_eslint from 'typescript-eslint';
4+
5+
export default [
6+
{ files: ['**/*.{js,mjs,cjs,ts}'] },
7+
{ languageOptions: { globals: globals.node } },
8+
pluginJs.configs.recommended,
9+
...ts_eslint.configs.recommended,
10+
];

html/captcha.html

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,50 @@
1-
<html>
1+
<html lang="en">
22
<head>
33
<title>Verification</title>
44
<meta
55
name="viewport"
66
content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
77
<script src="<%= captcha_provider_script %>" async defer></script>
8-
<link rel="stylesheet" href="../style.css" />
8+
<script src="https://cdn.tailwindcss.com"></script>
9+
<script>
10+
tailwind.config = {
11+
// Use system dark mode
12+
darkMode: 'media',
13+
};
14+
</script>
915
</head>
1016

11-
<body>
12-
<div class="main">
13-
<h1>Verification</h1>
14-
<h4>
15-
Please solve the <%= captcha_provider %> following below to make sure you are not a
16-
robot.
17+
<body class="dark:bg-black">
18+
<div class="h-screen flex flex-col items-center p-3">
19+
<h1 class="mt-5 text-3xl font-bold dark:text-white">Verification</h1>
20+
<h4 class="text-xl text-gray-600 dark:text-gray-400">
21+
Please solve the <%= captcha_provider %> following below to make sure
22+
you are not a robot.
1723
</h4>
18-
<form action="/verify/solve" method="POST" id="captcha_verification">
19-
<center>
20-
<div
21-
class="g-recaptcha h-captcha cf-turnstile"
22-
data-sitekey="<%= captcha_sitekey %>"
23-
data-callback="onPassed"
24-
data-expired-callback="onExpired"></div>
25-
</center>
24+
<form
25+
action="/verify/solve"
26+
method="POST"
27+
id="captcha_verification"
28+
class="mt-5">
29+
<div
30+
class="g-recaptcha h-captcha cf-turnstile"
31+
data-sitekey="<%= captcha_sitekey %>"
32+
data-callback="onPassed"
33+
data-expired-callback="onExpired"></div>
2634
</form>
27-
</div>
28-
<div class="footer">
29-
<a href="../verify/logout">Logout</a>
35+
<div class="mt-5">
36+
<a
37+
href="../verify/logout"
38+
class="text-blue-500 dark:text-blue-400 hover:underline">
39+
Logout
40+
</a>
41+
</div>
3042
</div>
3143
<script>
3244
function onPassed() {
3345
document.getElementById('captcha_verification').submit();
3446
}
47+
3548
function onExpired() {
3649
location.reload();
3750
}

html/error.html

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
<html>
1+
<html lang="en">
22
<head>
3-
<title>Error Occured!</title>
3+
<title>Error Occurred!</title>
44
<meta
55
name="viewport"
66
content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
7-
<link rel="stylesheet" href="../style.css" />
7+
<script src="https://cdn.tailwindcss.com"></script>
8+
<script>
9+
tailwind.config = {
10+
// Use system dark mode
11+
darkMode: 'media',
12+
};
13+
</script>
814
</head>
915

10-
<body>
11-
<div class="error_success">
12-
<center>
13-
<img
14-
src="../cross.png"
15-
alt="Verified"
16-
style="width: 100px; height: 100px" />
17-
<h1><%= messageText %></h1>
18-
</center>
16+
<body class="dark:bg-black">
17+
<div class="h-screen flex flex-col justify-center items-center">
18+
<img
19+
src="../cross.png"
20+
alt="Verified"
21+
class="w-[100px] h-[100px] mb-10" />
22+
<h1 class="text-3xl font-bold text-red-500"><%= messageText %></h1>
1923
</div>
2024
</body>
2125
</html>

0 commit comments

Comments
 (0)