From 40377cb4f450555637851b091a3c4c5c7cf67fd3 Mon Sep 17 00:00:00 2001 From: adb Date: Sat, 30 Jan 2021 20:49:43 +0000 Subject: [PATCH 1/3] init README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..9d94816 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# RandomRedditMemesAPI + +an API that returns random Reddit Submissions written in Java \ No newline at end of file From 584b851b4cb4e07bfee93474eced0c9fb2408182 Mon Sep 17 00:00:00 2001 From: adb Date: Sat, 30 Jan 2021 21:07:18 +0000 Subject: [PATCH 2/3] add build and run instructions --- README.md | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d94816..3d8614e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,32 @@ # RandomRedditMemesAPI -an API that returns random Reddit Submissions written in Java \ No newline at end of file +an API that returns random Reddit Submissions written in Java + +## build and run + +### build project +first make sure you're using Gradle 6.8 and openjdk-jdk8 + +to build the project just run: +``` +gradle build +``` + +### run +to execute the .jar archive you built before run: +``` +java -jar ./build/libs/RandomRedditMemesAPI.jar +``` + +### run inside docker +to execute the .jar file inside docker use docker-compose: +``` +docker-compose -p RandomRedditMemesAPI up -docker +``` + +### build docker image +if you want to build a full docker image run: +``` +docker build . +``` +alternatively you can use `./docker/docker-compose.yml` From e7578e3fc33047f73147ce989048fa68751b3c27 Mon Sep 17 00:00:00 2001 From: adb Date: Sat, 30 Jan 2021 21:38:52 +0000 Subject: [PATCH 3/3] add API description --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index 3d8614e..598894e 100644 --- a/README.md +++ b/README.md @@ -30,3 +30,37 @@ if you want to build a full docker image run: docker build . ``` alternatively you can use `./docker/docker-compose.yml` + +## API + +the baseurl for the API is: `http://127.0.0.1/api/v1` + +### subreddits + +subreddit syntax `[baseurl]/r/[subreddit]/[type]` + +[type] syntax +* `all` - returns the first 100 submissions of the subreddits page +* `random` - returns one random submission of the first 100 +* `[0-99]` - returns a specific one +* if undefined returns random + +the response looks like: +``` +{ + "subs":[{ + "score": Integer, + "nsfw": Boolean, + "author": String, + "text": String, + "time": Integer, + "title": String, + "downvotes": Integer, + "permalink": String, + "subreddit": String, + "url": String, + }], + "error": Boolean/String, + "type":String +} +``` \ No newline at end of file