Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

ProxyFox v2.1 #20

Draft
wants to merge 149 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
3161a91
Set up handling for message interaction commands
Oliver-makes-code Oct 30, 2022
9273c56
Merge branch 'master' into dev/2.1
Ampflower Nov 6, 2022
37b6909
Initial API stuff
TibiNonEst Nov 9, 2022
b956713
Fix funni failure
TibiNonEst Nov 9, 2022
66bd124
More API stuff
TibiNonEst Nov 9, 2022
2c8d0e9
Messages et al.
TibiNonEst Nov 9, 2022
a973e26
Guild settings and API version
TibiNonEst Nov 9, 2022
dca836f
Misc API stuff
TibiNonEst Nov 10, 2022
0be4f9e
Initial API authentication
TibiNonEst Nov 10, 2022
fffe373
Fix casing
TibiNonEst Nov 11, 2022
f2d2002
Merge branch 'master' into dev/2.1
Oliver-makes-code Nov 14, 2022
5adaa39
Start move to proxyfox-command + start working on slash commands
Oliver-makes-code Nov 15, 2022
36dbc57
Apply licenses
Oliver-makes-code Nov 15, 2022
ad0f08d
Move SystemCommands and SwitchCommands fully to the new system + star…
Oliver-makes-code Nov 15, 2022
767ebe5
Misc fixes
Oliver-makes-code Nov 16, 2022
a7243f9
Finish slash command support
Oliver-makes-code Nov 16, 2022
5b6aa64
Remove dev.proxyfox.bot.string package as it's unused now
Oliver-makes-code Nov 16, 2022
80befbe
Fix build
Oliver-makes-code Nov 16, 2022
4670604
Fix fix build build
Oliver-makes-code Nov 17, 2022
0fa816c
Add initial group implementation to database, add TODO for future ref…
Oliver-makes-code Nov 20, 2022
7f013a0
Apply licenses to new files
Oliver-makes-code Nov 20, 2022
1b2f51e
aaaaaa
TibiNonEst Nov 21, 2022
5b6e20f
totally fixed
TibiNonEst Nov 21, 2022
1e93802
Add docker builds
TibiNonEst Nov 21, 2022
7a8989c
Fix name, publish with hash
TibiNonEst Nov 21, 2022
c737366
Bump proxyfox-command
TibiNonEst Nov 22, 2022
4a6cbcf
Merge branch 'dev/docker' into dev/2.1
TibiNonEst Nov 22, 2022
b8f2e6e
Pain
TibiNonEst Dec 17, 2022
a7b33dc
cursed
TibiNonEst Dec 17, 2022
eb5f784
Revert "cursed"
TibiNonEst Dec 17, 2022
64ebfcb
Revert "Pain"
TibiNonEst Dec 17, 2022
fe584ec
Revert "totally fixed"
TibiNonEst Dec 17, 2022
ccea77b
Finish database refactor
TibiNonEst Dec 21, 2022
b6036a7
Update versions of things
Oliver-makes-code Dec 25, 2022
2a1c444
Use Java 18
Oliver-makes-code Dec 25, 2022
c8714b3
Replace all references of JsonDatabase with InMemoryDatabase
Oliver-makes-code Dec 25, 2022
b706da3
Update Gradle to 7.6
Ampflower Jan 1, 2023
dbb9726
Provide immediate reason for inability to proxy if fixable by end user.
Ampflower Jan 1, 2023
201642a
Add far better logging of exceptions.
Ampflower Jan 2, 2023
4754fe5
Merge branch 'dev/2.0' into dev/2.1
Ampflower Jan 2, 2023
181e27c
Initial pluralkit sync setup
Oliver-makes-code Jan 5, 2023
4d0142b
Apply&update licenses
Oliver-makes-code Jan 5, 2023
49f7cdc
Initial use of Quilt Loader on ProxyFox
Ampflower Jan 6, 2023
759fb18
Most tests are fixed
TibiNonEst Jan 7, 2023
331d44c
Fix case sensitivity in PluralKitImporter
Ampflower Jan 7, 2023
25b2682
Fix birthday day/month flipping logic in PluralKitImporter
Ampflower Jan 7, 2023
f60f555
Use ConcurrentHashMap as the backing maps for InMemoryDatabase
Ampflower Jan 7, 2023
5a5fba7
Fix logic errors & mem leaks in InMemoryDatabase
Ampflower Jan 7, 2023
7d34dff
Harden ImporterTest to logic errors and its own assertions
Ampflower Jan 7, 2023
4432d1a
Add PolyIgnorePrimitive
Ampflower Jan 8, 2023
70cae0a
Fix Instant parsing
Ampflower Jan 8, 2023
b1e08f8
Merge remote-tracking branch 'origin/dev/2.1' into api-help-me
Ampflower Jan 8, 2023
8cef09d
Fix broken merge from dev/2.1
Ampflower Jan 8, 2023
12bed62
Default to port 8080 on ApiMain
Ampflower Jan 8, 2023
f606126
Add export test to Time Resolution
Ampflower Jan 8, 2023
ea16b6c
Merge remote-tracking branch 'origin/dev/2.1' into api-help-me
Ampflower Jan 8, 2023
27954db
Restore microsecond resolution of switches
Ampflower Jan 8, 2023
02abe43
Add explicit microsecond resolution test
Ampflower Jan 8, 2023
987d547
Remove redundant epoch string
Ampflower Jan 8, 2023
5472cce
Add nanosecond truncation test
Ampflower Jan 8, 2023
c4bad7e
Use Base64-encoded 24 bytes of secure random for generateToken
Ampflower Jan 8, 2023
947f6e3
Add micros & nanos test to ExporterTest
Ampflower Jan 8, 2023
f6bdc62
Fix Mongo record serialization to match production
Ampflower Jan 9, 2023
fe36748
Drop GSON in favour of Kotlin Serialization
Ampflower Jan 9, 2023
60d5b18
Force asynchronous registration of application commands
Ampflower Jan 9, 2023
1c5d45b
Convert ConversionMain.kt to Kotlin Serialization
Ampflower Jan 9, 2023
71dc8e1
Remove inapplicable tests for GSON.
Ampflower Jan 9, 2023
f5922c2
Undo DebugException being passed through to the error channel
Ampflower Jan 10, 2023
c2d5da4
Clarify comment.
Ampflower Jan 10, 2023
7b9f902
Correct typo in gradle.yml
Ampflower Jan 10, 2023
e148879
Remove dependency on Kotlin stdlib in Patch
Ampflower Jan 10, 2023
9ac901d
Setup shadowJar for Patch to bundle Quilt Loader & dependencies.
Ampflower Jan 10, 2023
d4563e6
Group poolRelease as build for ease of finding it in IntelliJ
Ampflower Jan 10, 2023
0721c9a
Decouple tokens from systems
Oliver-makes-code Jan 11, 2023
20bab0c
Move token stuff from SystemCommands to MiscCommands
Oliver-makes-code Jan 11, 2023
0031549
Implement trust levels
Oliver-makes-code Jan 16, 2023
3b95c4a
Reduce boilerplate across code
Oliver-makes-code Jan 16, 2023
484f4d4
h
Oliver-makes-code Jan 16, 2023
756f545
Misc code cleanups and deduplication
Oliver-makes-code Jan 16, 2023
4056930
Clean up code and fix compiler warnings
Oliver-makes-code Jan 16, 2023
6504d30
Start implementation of command menus
Oliver-makes-code Jan 16, 2023
4218348
a
Oliver-makes-code Jan 16, 2023
a090b2f
Defer chat input command registry + apply licenses
Oliver-makes-code Jan 16, 2023
7051da8
Implement message interaction command handlers
Oliver-makes-code Jan 16, 2023
3f763a4
Implement a server toggle for system tag enforcement
Oliver-makes-code Jan 17, 2023
bffdda4
Work on groups
Oliver-makes-code Jan 17, 2023
9c4e4ea
Apply licenses
Oliver-makes-code Jan 17, 2023
33cd92e
More API changes, feat: actual tokens
TibiNonEst Jan 17, 2023
fa5f19f
Apply licenses
TibiNonEst Jan 17, 2023
a85bead
Exporter now handles missing members in a way to not break importer.
Ampflower Jan 28, 2023
b5810bc
Merge tag 'dev/2.0-old' into HEAD
Ampflower Feb 1, 2023
79c9a45
Merge remote-tracking branch 'origin/master' into HEAD
Ampflower Feb 1, 2023
0451b2a
Fix merge conflicts n stuff
Oliver-makes-code Feb 1, 2023
94464c8
Migrate to MarKt
Oliver-makes-code Feb 11, 2023
41ae203
Preliminaries for PK Sync
Oliver-makes-code Feb 11, 2023
f969636
License header for DontExpose
Oliver-makes-code Feb 11, 2023
b85ab99
Bump Quilt Gradle Licenser
Oliver-makes-code Feb 11, 2023
4181464
Fix slash command registration taking eons
Oliver-makes-code Feb 17, 2023
8c61753
Refactor command registration
Oliver-makes-code Feb 17, 2023
ef57ef9
Bump MarKt version
Oliver-makes-code Feb 17, 2023
6b6a44c
add license header to CommandRegistrar.kt
Oliver-makes-code Feb 17, 2023
7322784
Properly implement menus
Oliver-makes-code Feb 17, 2023
a4f1789
Add Kord.onlyIf
Oliver-makes-code Feb 17, 2023
b0beff2
Remove unnecessary parameter
Oliver-makes-code Feb 17, 2023
b21947c
Pass in CommandParser in CommandRegistrar$registerTextCommands
Oliver-makes-code Feb 17, 2023
2aff215
Move TimedYesNoPrompt to DiscordContext
Oliver-makes-code Feb 17, 2023
c6e9046
Add visibility flag for interactionMenu
Oliver-makes-code Feb 17, 2023
7bfe052
Use ProxyFox-Command for terminal input
Oliver-makes-code Feb 18, 2023
710c564
fix build
Oliver-makes-code Feb 18, 2023
ef3655f
Merge branch 'master' into dev/2.1
Ampflower Feb 25, 2023
4fe3d79
Merge remote-tracking branch 'origin/dev/2.1' into dev/2.1
Ampflower Feb 25, 2023
2aee338
Add a CommonMessages enum to build common messages + add env-controll…
Oliver-makes-code Feb 25, 2023
fbaa830
Misc fixes
Oliver-makes-code Feb 25, 2023
672f812
Support suppressed errors in error handler
Oliver-makes-code Feb 25, 2023
5769517
Add the ability to defer responses
Oliver-makes-code Feb 25, 2023
88ad2b4
Fix default visibility of timed y/n
Oliver-makes-code Feb 25, 2023
0952085
More fixes with timed y/n
Oliver-makes-code Feb 25, 2023
c59a629
Update gitignore
Oliver-makes-code Feb 26, 2023
9a2cb00
Misc command refactors
Oliver-makes-code Feb 26, 2023
95fd406
Useragent + include more git properties
Oliver-makes-code Feb 27, 2023
ac2c662
Rearrange debug embed
Oliver-makes-code Feb 27, 2023
cd462c5
Move uptime to before shard id
Oliver-makes-code Feb 27, 2023
7fac04b
Tell people to report exceptions
Oliver-makes-code Feb 27, 2023
fc42f61
Misc fixes related to application commands
Oliver-makes-code Feb 27, 2023
8f3ad69
Fix import clashes by searching by member name before member id
Oliver-makes-code Feb 27, 2023
507e810
Merge branch 'master' into dev/2.1
Oliver-makes-code May 1, 2023
c902672
Bump kord version, support voice messages, keep track of deleted mess…
Oliver-makes-code May 1, 2023
a4ec815
Clean up duplicated code in DiscordContext
Oliver-makes-code May 1, 2023
17434af
Initial pluralkit sync implementation
Oliver-makes-code May 1, 2023
b613d4c
Better message deletion handling
Oliver-makes-code May 1, 2023
a860cd7
Update in-memory to match semantics change
Oliver-makes-code May 1, 2023
a50c73c
Refactor some API things
Oliver-makes-code May 1, 2023
cab2c3b
Remove unneeded indent
Oliver-makes-code May 1, 2023
21ab55f
Avoid unnecessary api lookups where possible
Oliver-makes-code May 2, 2023
910ea42
Bumb logback
Oliver-makes-code May 2, 2023
489af71
Fix pk sync's diff check
Oliver-makes-code May 2, 2023
3d38b3f
Check diff in pull sync
Oliver-makes-code May 2, 2023
a4d6c43
Token creation and deletion
Oliver-makes-code Jun 5, 2023
8a40ce5
Transfer systems using transfer tokens
Oliver-makes-code Jun 5, 2023
9ce6a59
Pager to use Menu from PF-C
Oliver-makes-code Jun 5, 2023
a83022f
Send file link as well on deleted system
Oliver-makes-code Jun 5, 2023
e2986fc
rip I used the wrong thing lol
Oliver-makes-code Jun 5, 2023
b324dac
Update dependencies
Ampflower Jul 11, 2023
0b07b1b
Improve error handling for overflowing messages
Ampflower Jul 11, 2023
b13ab66
Don't require name argument on member command
Ampflower Jul 11, 2023
56ebb7a
Merge remote-tracking branch 'origin/master' into dev/2.1
Ampflower Jul 12, 2023
8dbd287
:3
Oliver-makes-code Jul 12, 2023
22b67fe
[no ci] start migration to pf-c 2.0
Oliver-makes-code Jul 16, 2023
1334a56
fix some api stuff + documentation too
Oliver-makes-code Jul 26, 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
54 changes: 54 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Docker Build and Publish
on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Persist Gradle cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Setup JDK 18
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 18

- name: Build
run: ./gradlew build -x check -x test --no-daemon

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: Artifacts
path: |
build/libs/
module/**/build/libs/

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- run: docker build -t ghcr.io/the-proxyfox-group/proxyfox:latest -t ghcr.io/the-proxyfox-group/proxyfox:${GITHUB_SHA} .
- run: docker push ghcr.io/the-proxyfox-group/proxyfox:latest
- run: docker push ghcr.io/the-proxyfox-group/proxyfox:${GITHUB_SHA}
29 changes: 19 additions & 10 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,51 @@
name: Build
on: [pull_request, push]
on: [ pull_request, push ]

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

services:
mongo:
image: mongo
ports:
- 27017:27017

steps:
- name: checkout repository
- name: Checkout repository
uses: actions/checkout@v3
- name: validate gradle wrapper

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- uses: actions/cache@v3

- name: Persist Gradle cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: setup jdk 17

- name: Setup JDK 18
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: build
java-version: 18

- name: Build
run: ./gradlew build --no-daemon
- name: capture build artifacts

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: Artifacts
path: |
build/libs/
modules/**/build/libs/
- name: capture test reports on failure

- name: Capture test reports on failure
uses: actions/upload-artifact@v3
if: failure()
with:
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,34 @@ on:
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
- uses: actions/cache@v3
- name: Checkout repository
uses: actions/checkout@v3

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Persist Gradle cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
java-version: 18

- name: Build and publish with Gradle
run: ./gradlew poolRelease --no-daemon

- name: Upload build artifacts
uses: AButler/[email protected]
with:
files: 'build/pool/*'
repo-token: ${{secrets.GITHUB_TOKEN}}
repo-token: ${{ secrets.GITHUB_TOKEN }}
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ build/
out/
mods/
proxyfox.db.properties
systems.json
.env
.env
.pf-command-lock
.quilt/
config/
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM openjdk:17-jdk-slim

COPY modules/bot/build/libs/proxyfox-*.jar /usr/local/lib/ProxyFox.jar

RUN mkdir /bot

WORKDIR /bot

ENTRYPOINT ["java", "-Xms2G", "-Xmx2G", "-jar", "/usr/local/lib/ProxyFox.jar"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we should be specifying a hardcoded Xms & Xmx; it might be better to have an arguments input system for this, if Docker allows.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vps ProxyFox is hosted on also doesn't have 2G to spare

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats fair, I can look into that

6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ allprojects {
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_18
targetCompatibility = JavaVersion.VERSION_18
Comment on lines +46 to +47
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should jump to Java 19 instead; 18 is already EoL, although, there's a possibility that 20 might be available by the time this branch is ready to be deployed into production.

}

repositories {
mavenCentral()
maven("https://libraries.minecraft.net/")
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://maven.quiltmc.org/repository/release/")
maven("https://maven.quiltmc.org/repository/snapshot/")
maven("https://maven.fabricmc.net/")
maven("https://jitpack.io")
maven("https://maven.proxyfox.dev")
}

dependencies {
Expand Down
35 changes: 35 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: "3"

networks:
proxyfox:
external: false

services:
proxyfox:
image: ghcr.io/the-proxyfox-group/proxyfox:latest
container_name: proxyfox
restart: always
environment:
- PROXYFOX_KEY=<token>
- PROXYFOX_MONGO=mongodb://<username>:<password>@mongo
networks:
- proxyfox
depends_on:
- mongo

mongo:
image: mongo:latest
container_name: proxyfox_mongo
restart: always
environment:
- MONGO_INITDB_ROOT_USERNAME=<username>
- MONGO_INITDB_ROOT_PASSWORD=<password>
networks:
- proxyfox
volumes:
- proxyfox-mongo:/data/db
ports:
- 27017:27017

volumes:
proxyfox-mongo:
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
kotlin.code.style=official
group=dev.proxyfox
version=2.0.13
version=2.1.0
49 changes: 34 additions & 15 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,49 +1,68 @@
[versions]
guava = "31.1-jre"
logback = "1.2.11"
kord = "0.8.0-M16"
kotlin = "1.7.10"
kotlinx_coroutines = "1.6.4"
guava = "32.1.1-jre"
logback = "1.4.8"
kord = "0.10.0"
kotlin = "1.9.0"
kotlinx_coroutines = "1.7.2"

# Database-specific
# ProxyFox Libraries
proxyfox_command = "2.0"
pluralkt = "1.8"
markt = "1.4"

# Database
postgres = "42.3.3"
kjdbc = "0.5.2"
gson = "2.9.0"
kmongo = "4.6.0"
kotlinx_datetime = "0.4.0"

# API
ktor = "2.1.3"

# Testing
testng = "7.6.1"
mockk = "1.+"

# Plugins
shadow = "7.1.2"
licenser = "1.1.2"
licenser = "1.2.0"

[libraries]
guava = { module = "com.google.guava:guava", version.ref = "guava" }
kord = { module = "dev.kord:kord-core", version.ref = "kord" }
logback = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }

proxyfox_command = { module = "dev.proxyfox:proxyfox-command", version.ref = "proxyfox_command" }
pluralkt = { module = "dev.proxyfox:pluralkt", version.ref = "pluralkt" }
markt = { module = "dev.proxyfox:MarKt", version.ref = "markt" }

kotlin_stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
kotlinx_coroutines_core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx_coroutines" }

gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
kjdbc = { module = "com.vladsch.kotlin-jdbc:kotlin-jdbc", version.ref = "kjdbc" }
postgres = { module = "org.postgresql:postgresql", version.ref = "postgres" }
kmongo_base = { module = "org.litote.kmongo:kmongo", version.ref = "kmongo" }
kmongo_coroutine = { module = "org.litote.kmongo:kmongo-coroutine", version.ref = "kmongo" }
kmongo_async = { module = "org.litote.kmongo:kmongo-async", version.ref = "kmongo" }
kmongo_base = { module = "org.litote.kmongo:kmongo-serialization", version.ref = "kmongo" }
kmongo_coroutine = { module = "org.litote.kmongo:kmongo-coroutine-serialization", version.ref = "kmongo" }
kmongo_async = { module = "org.litote.kmongo:kmongo-async-serialization", version.ref = "kmongo" }
kotlinx_datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx_datetime" }

ktor_server = { module = "io.ktor:ktor-server-core", version.ref = "ktor" }
ktor_server_netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor" }
ktor_content_negotiation = { module = "io.ktor:ktor-server-content-negotiation", version.ref = "ktor" }
ktor_serialization = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }

testng = { module = "org.testng:testng", version.ref = "testng" }
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
kotlinx_coroutines_test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx_coroutines" }

[bundles]
base = ["guava", "logback", "kotlin_stdlib", "kotlinx_coroutines_core", "kord"]
base = ["guava", "logback", "kotlin_stdlib", "kotlinx_coroutines_core", "kord", "proxyfox_command", "pluralkt", "markt"]
database = ["kmongo_base", "kmongo_coroutine", "kmongo_async", "kotlinx_datetime"]
api = ["ktor_server", "ktor_server_netty", "ktor_content_negotiation", "ktor_serialization"]
test = ["testng", "kotlinx_coroutines_test", "mockk"]
database = ["gson", "kmongo_base", "kmongo_coroutine", "kmongo_async"]

[plugins]
kotlin_jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
licenser = { id = "org.quiltmc.gradle.licenser", version.ref = "licenser" }
licenser = { id = "org.quiltmc.gradle.licenser", version.ref = "licenser" }
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

package dev.proxyfox.api.server
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.shadow)
alias(libs.plugins.serialization)
}

fun main() = ServerMain.main()

object ServerMain {
fun main() {

}
dependencies {
api(project(":modules:common"))
api(project(":modules:database"))
api(libs.bundles.api)
}
43 changes: 43 additions & 0 deletions modules/api/src/main/kotlin/dev/proxyfox/api/ApiMain.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2022-2023, The ProxyFox Group
*
* This Source Code is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

package dev.proxyfox.api

import dev.proxyfox.api.routes.*
import io.ktor.serialization.kotlinx.json.*
import io.ktor.server.application.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import io.ktor.server.plugins.contentnegotiation.*
import io.ktor.server.routing.*

object ApiMain {
fun main() = embeddedServer(Netty, port = System.getenv("PORT")?.toIntOrNull() ?: 8080) {
configureRouting()
configurePlugins()
}.start()

private fun Application.configurePlugins() {
install(ContentNegotiation) {
json()
}
}

private fun Application.configureRouting() {
routing {
route("/v1") {
systemRoutes()
memberRoutes()
switchRoutes()
messageRoutes()
tokenRoutes()
coffeeRoutes()
}
}
}
}
Loading
Loading