chore: add funding

This commit is contained in:
Reinaldy Rafli 2024-02-11 19:59:53 +07:00
parent 9aedbc6648
commit 952e07a5ae
Signed by: aldy505
GPG Key ID: A3F8A7E23DA2AD94
4 changed files with 320 additions and 316 deletions

4
.github/FUNDING.yml vendored
View File

@ -1 +1,3 @@
ko_fi: aldy505 github: aldy505
ko_fi: aldy505
liberapay: aldy505

View File

@ -1,125 +1,127 @@
name: CI name: CI
on: on:
push: push:
branches: [ "master" ] branches: [ "master" ]
jobs: jobs:
api-build: api-build:
name: API name: API
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: golang:1.21.0-bookworm container: golang:1.21.0-bookworm
timeout-minutes: 15 timeout-minutes: 15
services: services:
bucket: bucket:
image: minio/minio:edge-cicd image: minio/minio:edge-cicd
env: env:
MINIO_ROOT_USER: root MINIO_ROOT_USER: root
MINIO_ROOT_PASSWORD: verysecurepassword MINIO_ROOT_PASSWORD: verysecurepassword
MINIO_ACCESS_KEY: minio_access_key MINIO_ACCESS_KEY: minio_access_key
MINIO_SECRET_KEY: minio_access_key MINIO_SECRET_KEY: minio_access_key
ports: ports:
- 9000:9000 - 9000:9000
options: >- options: >-
--health-cmd "curl -f http://bucket:9000/minio/health/live" --health-cmd "curl -f http://bucket:9000/minio/health/live"
--health-interval 45s --health-interval 45s
--health-timeout 30s --health-timeout 30s
--health-retries 10 --health-retries 10
--health-start-period 120s --health-start-period 120s
volumes: volumes:
- minio-data:/data - minio-data:/data
redis: redis:
image: redis:7.0.12-bookworm image: redis:7.0.12-bookworm
ports: ports:
- 6379:6379 - 6379:6379
defaults: defaults:
run: run:
working-directory: ./api working-directory: ./api
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v4
- name: Installling dependencies - name: Installling dependencies
run: go mod download run: go mod download
- name: Build - name: Build
run: go build main.go run: go build main.go
- name: Run test & coverage - name: Run test & coverage
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./... run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
env: env:
ENV: development ENV: development
PORT: 5000 PORT: 5000
MINIO_HOST: bucket:9000 MINIO_HOST: bucket:9000
MINIO_ACCESS_ID: root MINIO_ACCESS_ID: root
MINIO_SECRET_KEY: verysecurepassword MINIO_SECRET_KEY: verysecurepassword
REDIS_URL: redis://@redis:6379 REDIS_URL: redis://@redis:6379
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v1 uses: github/codeql-action/init@v2
with: with:
languages: go languages: go
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1 uses: github/codeql-action/analyze@v2
- name: Create Sentry release - name: Create Sentry release
uses: getsentry/action-release@v1 uses: getsentry/action-release@v1
env: continue-on-error: true
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }} env:
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT_API}} SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
with: SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT_API}}
environment: production with:
set_commits: skip environment: production
version: ${{ github.sha }} set_commits: skip
version: ${{ github.sha }}
- uses: codecov/codecov-action@v2
with: - uses: codecov/codecov-action@v4
flags: api with:
flags: api
client-build:
name: Client client-build:
runs-on: ubuntu-latest name: Client
container: node:18.17.1-bookworm runs-on: ubuntu-latest
timeout-minutes: 15 container: node:18.17.1-bookworm
defaults: timeout-minutes: 15
run: defaults:
working-directory: ./client run:
working-directory: ./client
steps:
- name: Checkout code steps:
uses: actions/checkout@v2 - name: Checkout code
uses: actions/checkout@v4
- name: Installling dependencies
run: npm install - name: Installling dependencies
run: npm install
- name: Lint
run: npm run lint - name: Lint
run: npm run lint
- name: Build
run: npm run build - name: Build
env: run: npm run build
VITE_SENTRY_DSN: https://examplePublicKey@o0.ingest.sentry.io/0 env:
VITE_NODE_ENV: development VITE_SENTRY_DSN: https://examplePublicKey@o0.ingest.sentry.io/0
VITE_API_ENDPOINT: https://jokesbapak2.reinaldyrafli.com/api/v1 VITE_NODE_ENV: development
VITE_API_ENDPOINT: https://jokesbapak2.reinaldyrafli.com/api/v1
- name: Initialize CodeQL
uses: github/codeql-action/init@v1 - name: Initialize CodeQL
with: uses: github/codeql-action/init@v2
languages: javascript with:
languages: javascript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1 - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Create Sentry release
uses: getsentry/action-release@v1 - name: Create Sentry release
env: uses: getsentry/action-release@v1
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }} continue-on-error: true
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} env:
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT_CLIENT }} SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }}
with: SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
environment: production SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT_CLIENT }}
set_commits: skip with:
version: ${{ github.sha }} environment: production
set_commits: skip
version: ${{ github.sha }}

View File

@ -1,106 +1,106 @@
name: PR name: PR
on: on:
pull_request: pull_request:
branches: [ "*" ] branches: [ "*" ]
jobs: jobs:
client-build: client-build:
name: Client name: Client
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: node:18.17.1-bookworm container: node:18.17.1-bookworm
timeout-minutes: 15 timeout-minutes: 15
defaults: defaults:
run: run:
working-directory: ./client working-directory: ./client
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v4
- name: Install dependencies - name: Install dependencies
run: npm install run: npm install
- name: Lint - name: Lint
run: npx eslint --ext .svelte,.js,.ts --ignore-path .gitignore . run: npx eslint --ext .svelte,.js,.ts --ignore-path .gitignore .
- name: Formatting - name: Formatting
run: npx prettier --check --ignore-path .gitignore --plugin-search-dir=. "./**/*.(ts|json|js|svelte)" run: npx prettier --check --ignore-path .gitignore --plugin-search-dir=. "./**/*.(ts|json|js|svelte)"
- name: Build - name: Build
run: npm run build run: npm run build
env: env:
VITE_SENTRY_DSN: https://examplePublicKey@o0.ingest.sentry.io/0 VITE_SENTRY_DSN: https://examplePublicKey@o0.ingest.sentry.io/0
VITE_NODE_ENV: development VITE_NODE_ENV: development
VITE_API_ENDPOINT: https://jokesbapak2.reinaldyrafli.com/api/v1 VITE_API_ENDPOINT: https://jokesbapak2.reinaldyrafli.com/api/v1
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v1 uses: github/codeql-action/init@v2
with: with:
languages: javascript languages: javascript
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1 uses: github/codeql-action/analyze@v2
api-build: api-build:
name: API name: API
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: golang:1.21.0-bookworm container: golang:1.21.0-bookworm
timeout-minutes: 15 timeout-minutes: 15
services: services:
bucket: bucket:
image: minio/minio:edge-cicd image: minio/minio:edge-cicd
env: env:
MINIO_ROOT_USER: root MINIO_ROOT_USER: root
MINIO_ROOT_PASSWORD: verysecurepassword MINIO_ROOT_PASSWORD: verysecurepassword
MINIO_ACCESS_KEY: minio_access_key MINIO_ACCESS_KEY: minio_access_key
MINIO_SECRET_KEY: minio_access_key MINIO_SECRET_KEY: minio_access_key
ports: ports:
- 9000:9000 - 9000:9000
options: >- options: >-
--health-cmd "curl -f http://bucket:9000/minio/health/live" --health-cmd "curl -f http://bucket:9000/minio/health/live"
--health-interval 45s --health-interval 45s
--health-timeout 30s --health-timeout 30s
--health-retries 10 --health-retries 10
--health-start-period 120s --health-start-period 120s
volumes: volumes:
- minio-data:/data - minio-data:/data
redis: redis:
image: redis:7.0.12-bookworm image: redis:7.0.12-bookworm
ports: ports:
- 6379:6379 - 6379:6379
defaults: defaults:
run: run:
working-directory: ./api working-directory: ./api
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v4
- name: Installling dependencies - name: Installling dependencies
run: go mod download run: go mod download
- name: Build - name: Build
run: go build main.go run: go build main.go
- name: Run test & coverage - name: Run test & coverage
run: go test -v -coverprofile=coverage.out -covermode=atomic ./... run: go test -v -coverprofile=coverage.out -covermode=atomic ./...
env: env:
ENV: development ENV: development
PORT: 5000 PORT: 5000
MINIO_HOST: bucket:9000 MINIO_HOST: bucket:9000
MINIO_ACCESS_ID: root MINIO_ACCESS_ID: root
MINIO_SECRET_KEY: verysecurepassword MINIO_SECRET_KEY: verysecurepassword
REDIS_URL: redis://@redis:6379 REDIS_URL: redis://@redis:6379
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v1 uses: github/codeql-action/init@v2
with: with:
languages: go languages: go
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1 uses: github/codeql-action/analyze@v2
- uses: codecov/codecov-action@v2 - uses: codecov/codecov-action@v4
with: with:
flags: api flags: api

168
README.md
View File

@ -1,85 +1,85 @@
<h1 align="center"> <h1 align="center">
<br> <br>
<img src=".github/images/header_github.png" alt="Jokes Bapak2 Heading" width="1000"> <img src=".github/images/header_github.png" alt="Jokes Bapak2 Heading" width="1000">
<br> <br>
<br> <br>
Jokes Bapak2 Image API Jokes Bapak2 Image API
<br> <br>
</h1> </h1>
👋 Hey there! Always a work in progress, if you'd like to contribute this while this repo is still growing, that would be 👋 Hey there! Always a work in progress, if you'd like to contribute this while this repo is still growing, that would be
so great! so great!
ou can access the front facing web on [jokesbapak2.reinaldyrafli.com](http://jokesbapak2.reinaldyrafli.com/). ou can access the front facing web on [jokesbapak2.reinaldyrafli.com](http://jokesbapak2.reinaldyrafli.com/).
## Brief explanation of what is this ## Brief explanation of what is this
Jokes Bapak2 is an image API that you can use for free! I've been seeing lots and lots of Indonesian dad jokes on Jokes Bapak2 is an image API that you can use for free! I've been seeing lots and lots of Indonesian dad jokes on
Twitter, Facebook and Instagram on early 2020. In a month, I made a Discord bot that provides the jokes. But I thought, Twitter, Facebook and Instagram on early 2020. In a month, I made a Discord bot that provides the jokes. But I thought,
why not make it as an API? why not make it as an API?
This is some kind of [icanhazdadjokes](https://icanhazdadjoke.com/) but it's Indonesian and it's not text, it's images. This is some kind of [icanhazdadjokes](https://icanhazdadjoke.com/) but it's Indonesian and it's not text, it's images.
Dad jokes in Indonesia is somewhat a bit different than in US/UK because, I guess, here, it's a lot dumber. Dad jokes in Indonesia is somewhat a bit different than in US/UK because, I guess, here, it's a lot dumber.
## Project Directories ## Project Directories
* `api` - REST API service. Created with Go with [Fiber](https://gofiber.io/) framework. * `api` - REST API service. Created with Go with [Fiber](https://gofiber.io/) framework.
* `client` - Front facing website (front end). Created with [Svelte Kit](https://kit.svelte.dev/). * `client` - Front facing website (front end). Created with [Svelte Kit](https://kit.svelte.dev/).
You can consume this API via a website (linked in the front facing web) with a few endpoints: You can consume this API via a website (linked in the front facing web) with a few endpoints:
* `/` - Random jokes bapak2 * `/` - Random jokes bapak2
* `/id/{number}` - Jokes bapak2 based on ID * `/id/{number}` - Jokes bapak2 based on ID
* `/today` - Jokes bapak2 of the day * `/today` - Jokes bapak2 of the day
* `/total` - Total available jokes bapak2 * `/total` - Total available jokes bapak2
Currently I'm (still) searching for an alternative for AWS S3 that I can use for free. Currently I'm (still) searching for an alternative for AWS S3 that I can use for free.
## Tech stacks ## Tech stacks
* Go (for `api` / back end) * Go (for `api` / back end)
* Node.js (for `client` / front end) * Node.js (for `client` / front end)
* Postgres * Postgres
* Redis * Redis
That's it. That's it.
## Development ## Development
Two ways of doing this: Two ways of doing this:
1. Install all the tech stack on your local machine 1. Install all the tech stack on your local machine
2. Using docker-compose 2. Using docker-compose
See [CONTRIBUTING](./CONTRIBUTING.md) or README files on each project directory for further instruction on how to run See [CONTRIBUTING](./CONTRIBUTING.md) or README files on each project directory for further instruction on how to run
the development environment. the development environment.
## Thanks to ## Thanks to
* [Teknologi Umum](https://t.me/teknologi_umum) * [Teknologi Umum](https://t.me/teknologi_umum)
* [Ronny Gunawan](https://github.com/ronnygunawan) for the caching concept & ideas * [Ronny Gunawan](https://github.com/ronnygunawan) for the caching concept & ideas
* [artileda](https://github.com/artileda) for the jokes submission * [artileda](https://github.com/artileda) for the jokes submission
* [elianiva](https://github.com/elianiva) for solving my SvelteKit problems * [elianiva](https://github.com/elianiva) for solving my SvelteKit problems
* [kokizzu](https://github.com/kokizzu) for the dependency injection concept & ideas * [kokizzu](https://github.com/kokizzu) for the dependency injection concept & ideas
## License ## License
Jokes Bapak2 API is licensed under [GNU GENERAL PUBLIC LICENSE v3 license](./LICENSE) Jokes Bapak2 API is licensed under [GNU GENERAL PUBLIC LICENSE v3 license](./LICENSE)
``` ```
Jokes Bapak2 API is a free-to-use image API of Indonesian dad jokes. Jokes Bapak2 API is a free-to-use image API of Indonesian dad jokes.
Copyright (C) 2021-present Jokes Bapak2 Contributors Copyright (C) 2021-present Reinaldy Rafli <aldy505@proton.me>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
``` ```