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

Some simple changes #261

Merged
merged 38 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ddcce09
test this change
TheAlienKnight Mar 12, 2023
7510b28
almost forgot about redis lmao
TheAlienKnight Mar 12, 2023
1d332f2
forgot this
TheAlienKnight Mar 12, 2023
8b4a8ce
right. alpine
TheAlienKnight Mar 12, 2023
ea050a7
fix
TheAlienKnight Mar 12, 2023
8e6c046
how did I not see that
TheAlienKnight Mar 12, 2023
5aa124c
am i an idiot? likely
TheAlienKnight Mar 12, 2023
904fdfd
wasted an hour. didn't see it was in ignore.
TheAlienKnight Mar 12, 2023
9f99cf4
may cause issues on RHEL8
TheAlienKnight Mar 12, 2023
4bab806
will error
TheAlienKnight Mar 12, 2023
6285435
bump discordjs
TheAlienKnight Mar 12, 2023
01b28f6
update networking
TheAlienKnight Mar 12, 2023
aa8c6b5
oops
TheAlienKnight Mar 12, 2023
90d9e3b
forgot this lol
TheAlienKnight Mar 12, 2023
0696cb2
broken autocomplete ffs
TheAlienKnight Mar 12, 2023
70b73d6
changes for v14
TheAlienKnight Mar 12, 2023
a48c6c7
changes in v14
TheAlienKnight Mar 12, 2023
9c342f8
one last change
TheAlienKnight Mar 13, 2023
ab81250
Merge pull request #7 from TheAlienKnight/dev
TheAlienKnight Mar 13, 2023
962b76d
Moves to the new 'rest' module/separation sys
TheAlienKnight Mar 15, 2023
fb99c95
might bc giving incorrect counts bc of this
TheAlienKnight Mar 15, 2023
c684834
Use direct URL instead of half working way
TheAlienKnight Mar 15, 2023
96817d6
so that's why it was never sending alerts
TheAlienKnight Mar 15, 2023
095b7d6
fixes manual sync failing if only _id
TheAlienKnight Mar 15, 2023
56ce4b8
didn't mean to keep those logs in lol
TheAlienKnight Mar 15, 2023
0d4dce4
remove ??? logs
TheAlienKnight Mar 15, 2023
43ed1fa
for some reason this didn't parse right
TheAlienKnight Mar 16, 2023
3c85ec4
im a fool
TheAlienKnight Mar 16, 2023
69ea78b
Merge pull request #8 from TheAlienKnight/dev
TheAlienKnight Mar 16, 2023
62f7ce2
Use proper enums
TheAlienKnight Mar 16, 2023
5c812b0
Merge pull request #9 from TheAlienKnight/dev
TheAlienKnight Mar 16, 2023
ba01f4b
Ensure values *are* cached
TheAlienKnight Mar 16, 2023
c927920
Should fix pagination being broken
TheAlienKnight Mar 16, 2023
acd25e5
the problem is different, this is unneeded
TheAlienKnight Mar 16, 2023
5d7b401
switching this to async caused much faster results
TheAlienKnight Mar 16, 2023
ee515ae
Merge pull request #10 from TheAlienKnight/dev
TheAlienKnight Mar 16, 2023
9d09bb8
use client rest, update deps, clean up, update ci
advaith1 Jul 24, 2023
c1fe2e2
small changes
advaith1 Jul 24, 2023
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
62 changes: 62 additions & 0 deletions .docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# You should configure the passwords/username's where expected
services:
web:
build: .
ports:
- "127.0.0.1:3000:3000" # Expected to be proxied via something like Nginx
restart: always
shm_size: 1024mb # Set 1gb default memory alloc. 1gb should be more than enough
depends_on:
- redis
- mongo
networks:
- mongo
- redis
- public

mongo:
image: mongo
restart: always
env_file: .env.production
networks:
- mongo
volumes:
- ./data/mongo:/data/db
healthcheck:
test: ["CMD", "echo 'db.runCommand(\"ping\").ok' | mongo mongo:27017/test --quiet"]
interval: 10s
timeout: 10s
retries: 5
start_period: 40s

mongo-express:
image: mongo-express
restart: always
env_file: .env.production
ports:
- "127.0.0.1:8081:8081" # Expected to be proxied by something like Nginx
networks:
- mongo
depends_on:
- mongo

redis:
restart: always
image: redis:7-alpine
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 10s
retries: 5
start_period: 40s
volumes:
- ./data/redis:/data
networks:
- redis

networks:
mongo:
internal: true
redis:
internal: true
public:
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.gitignore
.gitattributes
settings.json
.git
node_modules/
node_modules/
data/
22 changes: 22 additions & 0 deletions .env.production.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This is a sample configuration file. You will need to copy this file
# and fill in the appropriate values before attempting to run
# this in a production environment! This is important!

# This assumes usage of docker-compose.yml - this file is generally useless
# otherwise, and you can, ignore it should you choose.

# MongoDB
# -----
MONGO_INITDB_ROOT_USERNAME: del
MONGO_INITDB_ROOT_PASSWORD: h@ckm3 # CHANGE ME

# MongoDB-Express Admin Interface
# -----
ME_CONFIG_MONGODB_SERVER: mongo # Assumes mongo docker network
ME_CONFIG_MONGODB_ENABLE_ADMIN: false
ME_CONFIG_MONGODB_AUTH_USERNAME: del
ME_CONFIG_MONGODB_AUTH_PASSWORD: h@ckm3
ME_CONFIG_BASICAUTH_USERNAME: deluser
ME_CONFIG_BASICAUTH_PASSWORD: h@ckm3
ME_CONFIG_SITE_COOKIESECRET: 'cookiesecret' # CHANGE ME
ME_CONFIG_SITE_SESSIONSECRET: 'sessionsecret' # CHANGE ME
17 changes: 7 additions & 10 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@ on:
pull_request:

jobs:
node14:
name: node v17 - tsc
node18:
name: node v18 - tsc
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: install node v17
uses: actions/setup-node@v1
- uses: actions/checkout@v3
- name: install node v18
uses: actions/setup-node@v3
with:
node-version: 17
- name: install
run: npm install
node-version: 18
cache: 'npm'
- name: dependencies
run: npm ci
- name: settings
Expand All @@ -26,5 +25,3 @@ jobs:
uses: icrawl/action-tsc@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
job-name: tsc
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Login
run: echo "${{secrets.DOCKER_PASSWORD}}" | docker login ${{secrets.DOCKER_URL}} -u admin --password-stdin
- name: Build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ dist
.tern-port

# SSL & configuration files
.env.production
settings.json
.env
ssl/
Expand Down
9 changes: 8 additions & 1 deletion @types/del.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import type { UserFlags, APIChannel, APIRole, APIUser, APIApplicationCommand, RESTPostOAuth2AccessTokenResult, OAuth2Scopes, Snowflake } from 'discord-api-types/v10'
import type { UserFlags, APIChannel, APIRole, APIUser, APIApplicationCommand, RESTPostOAuth2AccessTokenResult, OAuth2Scopes, Snowflake } from 'discord.js'

declare global {
interface authUser extends RESTPostOAuth2AccessTokenResult {
Expand Down Expand Up @@ -247,6 +247,11 @@ declare global {
options: string;
server: string;
};
date?: {
submitted: number;
approved: number;
edited: number;
};
status: {
approved: boolean;
premium: boolean;
Expand All @@ -257,6 +262,8 @@ declare global {
};
}

type partialBot = Partial<Omit<delBot, 'status'> & { status: Partial<delBot["status"]> }>;

interface delServer {
_id: Snowflake;
inviteCode: string;
Expand Down
23 changes: 17 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
FROM node:17.9.0-alpine3.14
WORKDIR /app
RUN apk update && apk add git ca-certificates
COPY . .
RUN mv settings.example.json settings.json
# syntax=docker/dockerfile:1.4
# NOTE: You should have made a settings.json file before running docker compose.
# Node v17 is EOL, Node v18 is current
ARG NODE_VERSION="18.15.0-alpine3.16"
FROM node:${NODE_VERSION}
# Copy to-be-compiled files to container filesystem
COPY . /opt/del
# Set new working dir
WORKDIR /opt/del
# Run apt update & add needed packages
RUN apk update && \
apk add git ca-certificates
# Install node modules
RUN npm ci --production
# Compile new dist file
RUN npx tsc-transpile-only
RUN rm -rf src/ @types/ settings.json
# Remove non-dist files
RUN rm -rf src/ @types/ .env.production
# Start the process within the container
CMD ["npm", "start"]
Loading