From 952e07a5ae836fdab3d81cd5b25dce18a8c5807c Mon Sep 17 00:00:00 2001 From: Reinaldy Rafli Date: Sun, 11 Feb 2024 19:59:53 +0700 Subject: [PATCH] chore: add funding --- .github/FUNDING.yml | 4 +- .github/workflows/ci.yml | 252 ++++++++++++++++++++------------------- .github/workflows/pr.yml | 212 ++++++++++++++++---------------- README.md | 168 +++++++++++++------------- 4 files changed, 320 insertions(+), 316 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 35ba041..80b4d50 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1,3 @@ -ko_fi: aldy505 \ No newline at end of file +github: aldy505 +ko_fi: aldy505 +liberapay: aldy505 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 911526b..5a7a74c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,125 +1,127 @@ -name: CI - -on: - push: - branches: [ "master" ] - -jobs: - api-build: - name: API - runs-on: ubuntu-latest - container: golang:1.21.0-bookworm - timeout-minutes: 15 - services: - bucket: - image: minio/minio:edge-cicd - env: - MINIO_ROOT_USER: root - MINIO_ROOT_PASSWORD: verysecurepassword - MINIO_ACCESS_KEY: minio_access_key - MINIO_SECRET_KEY: minio_access_key - ports: - - 9000:9000 - options: >- - --health-cmd "curl -f http://bucket:9000/minio/health/live" - --health-interval 45s - --health-timeout 30s - --health-retries 10 - --health-start-period 120s - volumes: - - minio-data:/data - redis: - image: redis:7.0.12-bookworm - ports: - - 6379:6379 - defaults: - run: - working-directory: ./api - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Installling dependencies - run: go mod download - - - name: Build - run: go build main.go - - - name: Run test & coverage - run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./... - env: - ENV: development - PORT: 5000 - MINIO_HOST: bucket:9000 - MINIO_ACCESS_ID: root - MINIO_SECRET_KEY: verysecurepassword - REDIS_URL: redis://@redis:6379 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: go - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 - - - name: Create Sentry release - uses: getsentry/action-release@v1 - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }} - SENTRY_ORG: ${{ secrets.SENTRY_ORG }} - SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT_API}} - with: - environment: production - set_commits: skip - version: ${{ github.sha }} - - - uses: codecov/codecov-action@v2 - with: - flags: api - - client-build: - name: Client - runs-on: ubuntu-latest - container: node:18.17.1-bookworm - timeout-minutes: 15 - defaults: - run: - working-directory: ./client - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Installling dependencies - run: npm install - - - name: Lint - run: npm run lint - - - name: Build - run: npm run build - env: - VITE_SENTRY_DSN: https://examplePublicKey@o0.ingest.sentry.io/0 - VITE_NODE_ENV: development - VITE_API_ENDPOINT: https://jokesbapak2.reinaldyrafli.com/api/v1 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: javascript - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 - - - name: Create Sentry release - uses: getsentry/action-release@v1 - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }} - SENTRY_ORG: ${{ secrets.SENTRY_ORG }} - SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT_CLIENT }} - with: - environment: production - set_commits: skip - version: ${{ github.sha }} +name: CI + +on: + push: + branches: [ "master" ] + +jobs: + api-build: + name: API + runs-on: ubuntu-latest + container: golang:1.21.0-bookworm + timeout-minutes: 15 + services: + bucket: + image: minio/minio:edge-cicd + env: + MINIO_ROOT_USER: root + MINIO_ROOT_PASSWORD: verysecurepassword + MINIO_ACCESS_KEY: minio_access_key + MINIO_SECRET_KEY: minio_access_key + ports: + - 9000:9000 + options: >- + --health-cmd "curl -f http://bucket:9000/minio/health/live" + --health-interval 45s + --health-timeout 30s + --health-retries 10 + --health-start-period 120s + volumes: + - minio-data:/data + redis: + image: redis:7.0.12-bookworm + ports: + - 6379:6379 + defaults: + run: + working-directory: ./api + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Installling dependencies + run: go mod download + + - name: Build + run: go build main.go + + - name: Run test & coverage + run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./... + env: + ENV: development + PORT: 5000 + MINIO_HOST: bucket:9000 + MINIO_ACCESS_ID: root + MINIO_SECRET_KEY: verysecurepassword + REDIS_URL: redis://@redis:6379 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: go + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + + - name: Create Sentry release + uses: getsentry/action-release@v1 + continue-on-error: true + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }} + SENTRY_ORG: ${{ secrets.SENTRY_ORG }} + SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT_API}} + with: + environment: production + set_commits: skip + version: ${{ github.sha }} + + - uses: codecov/codecov-action@v4 + with: + flags: api + + client-build: + name: Client + runs-on: ubuntu-latest + container: node:18.17.1-bookworm + timeout-minutes: 15 + defaults: + run: + working-directory: ./client + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Installling dependencies + run: npm install + + - name: Lint + run: npm run lint + + - name: Build + run: npm run build + env: + VITE_SENTRY_DSN: https://examplePublicKey@o0.ingest.sentry.io/0 + VITE_NODE_ENV: development + VITE_API_ENDPOINT: https://jokesbapak2.reinaldyrafli.com/api/v1 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: javascript + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + + - name: Create Sentry release + uses: getsentry/action-release@v1 + continue-on-error: true + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }} + SENTRY_ORG: ${{ secrets.SENTRY_ORG }} + SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT_CLIENT }} + with: + environment: production + set_commits: skip + version: ${{ github.sha }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 1b7841a..394a7f2 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,106 +1,106 @@ -name: PR - -on: - pull_request: - branches: [ "*" ] - -jobs: - client-build: - name: Client - runs-on: ubuntu-latest - container: node:18.17.1-bookworm - timeout-minutes: 15 - defaults: - run: - working-directory: ./client - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Install dependencies - run: npm install - - - name: Lint - run: npx eslint --ext .svelte,.js,.ts --ignore-path .gitignore . - - - name: Formatting - run: npx prettier --check --ignore-path .gitignore --plugin-search-dir=. "./**/*.(ts|json|js|svelte)" - - - name: Build - run: npm run build - env: - VITE_SENTRY_DSN: https://examplePublicKey@o0.ingest.sentry.io/0 - VITE_NODE_ENV: development - VITE_API_ENDPOINT: https://jokesbapak2.reinaldyrafli.com/api/v1 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: javascript - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 - - api-build: - name: API - runs-on: ubuntu-latest - container: golang:1.21.0-bookworm - timeout-minutes: 15 - services: - bucket: - image: minio/minio:edge-cicd - env: - MINIO_ROOT_USER: root - MINIO_ROOT_PASSWORD: verysecurepassword - MINIO_ACCESS_KEY: minio_access_key - MINIO_SECRET_KEY: minio_access_key - ports: - - 9000:9000 - options: >- - --health-cmd "curl -f http://bucket:9000/minio/health/live" - --health-interval 45s - --health-timeout 30s - --health-retries 10 - --health-start-period 120s - volumes: - - minio-data:/data - redis: - image: redis:7.0.12-bookworm - ports: - - 6379:6379 - defaults: - run: - working-directory: ./api - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Installling dependencies - run: go mod download - - - name: Build - run: go build main.go - - - name: Run test & coverage - run: go test -v -coverprofile=coverage.out -covermode=atomic ./... - env: - ENV: development - PORT: 5000 - MINIO_HOST: bucket:9000 - MINIO_ACCESS_ID: root - MINIO_SECRET_KEY: verysecurepassword - REDIS_URL: redis://@redis:6379 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: go - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 - - - uses: codecov/codecov-action@v2 - with: - flags: api +name: PR + +on: + pull_request: + branches: [ "*" ] + +jobs: + client-build: + name: Client + runs-on: ubuntu-latest + container: node:18.17.1-bookworm + timeout-minutes: 15 + defaults: + run: + working-directory: ./client + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies + run: npm install + + - name: Lint + run: npx eslint --ext .svelte,.js,.ts --ignore-path .gitignore . + + - name: Formatting + run: npx prettier --check --ignore-path .gitignore --plugin-search-dir=. "./**/*.(ts|json|js|svelte)" + + - name: Build + run: npm run build + env: + VITE_SENTRY_DSN: https://examplePublicKey@o0.ingest.sentry.io/0 + VITE_NODE_ENV: development + VITE_API_ENDPOINT: https://jokesbapak2.reinaldyrafli.com/api/v1 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: javascript + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + + api-build: + name: API + runs-on: ubuntu-latest + container: golang:1.21.0-bookworm + timeout-minutes: 15 + services: + bucket: + image: minio/minio:edge-cicd + env: + MINIO_ROOT_USER: root + MINIO_ROOT_PASSWORD: verysecurepassword + MINIO_ACCESS_KEY: minio_access_key + MINIO_SECRET_KEY: minio_access_key + ports: + - 9000:9000 + options: >- + --health-cmd "curl -f http://bucket:9000/minio/health/live" + --health-interval 45s + --health-timeout 30s + --health-retries 10 + --health-start-period 120s + volumes: + - minio-data:/data + redis: + image: redis:7.0.12-bookworm + ports: + - 6379:6379 + defaults: + run: + working-directory: ./api + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Installling dependencies + run: go mod download + + - name: Build + run: go build main.go + + - name: Run test & coverage + run: go test -v -coverprofile=coverage.out -covermode=atomic ./... + env: + ENV: development + PORT: 5000 + MINIO_HOST: bucket:9000 + MINIO_ACCESS_ID: root + MINIO_SECRET_KEY: verysecurepassword + REDIS_URL: redis://@redis:6379 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: go + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + + - uses: codecov/codecov-action@v4 + with: + flags: api diff --git a/README.md b/README.md index b3023e9..b56d8e7 100644 --- a/README.md +++ b/README.md @@ -1,85 +1,85 @@ -

-
- Jokes Bapak2 Heading -
-
- Jokes Bapak2 Image API -
-

- -👋 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! - -ou can access the front facing web on [jokesbapak2.reinaldyrafli.com](http://jokesbapak2.reinaldyrafli.com/). - -## 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 -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? - -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. - -## Project Directories - -* `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/). - -You can consume this API via a website (linked in the front facing web) with a few endpoints: - -* `/` - Random jokes bapak2 -* `/id/{number}` - Jokes bapak2 based on ID -* `/today` - Jokes bapak2 of the day -* `/total` - Total available jokes bapak2 - -Currently I'm (still) searching for an alternative for AWS S3 that I can use for free. - -## Tech stacks - -* Go (for `api` / back end) -* Node.js (for `client` / front end) -* Postgres -* Redis - -That's it. - -## Development - -Two ways of doing this: - -1. Install all the tech stack on your local machine -2. Using docker-compose - -See [CONTRIBUTING](./CONTRIBUTING.md) or README files on each project directory for further instruction on how to run -the development environment. - -## Thanks to - -* [Teknologi Umum](https://t.me/teknologi_umum) -* [Ronny Gunawan](https://github.com/ronnygunawan) for the caching concept & ideas -* [artileda](https://github.com/artileda) for the jokes submission -* [elianiva](https://github.com/elianiva) for solving my SvelteKit problems -* [kokizzu](https://github.com/kokizzu) for the dependency injection concept & ideas - -## 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. -Copyright (C) 2021-present Jokes Bapak2 Contributors - -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 -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . +

+
+ Jokes Bapak2 Heading +
+
+ Jokes Bapak2 Image API +
+

+ +👋 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! + +ou can access the front facing web on [jokesbapak2.reinaldyrafli.com](http://jokesbapak2.reinaldyrafli.com/). + +## 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 +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? + +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. + +## Project Directories + +* `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/). + +You can consume this API via a website (linked in the front facing web) with a few endpoints: + +* `/` - Random jokes bapak2 +* `/id/{number}` - Jokes bapak2 based on ID +* `/today` - Jokes bapak2 of the day +* `/total` - Total available jokes bapak2 + +Currently I'm (still) searching for an alternative for AWS S3 that I can use for free. + +## Tech stacks + +* Go (for `api` / back end) +* Node.js (for `client` / front end) +* Postgres +* Redis + +That's it. + +## Development + +Two ways of doing this: + +1. Install all the tech stack on your local machine +2. Using docker-compose + +See [CONTRIBUTING](./CONTRIBUTING.md) or README files on each project directory for further instruction on how to run +the development environment. + +## Thanks to + +* [Teknologi Umum](https://t.me/teknologi_umum) +* [Ronny Gunawan](https://github.com/ronnygunawan) for the caching concept & ideas +* [artileda](https://github.com/artileda) for the jokes submission +* [elianiva](https://github.com/elianiva) for solving my SvelteKit problems +* [kokizzu](https://github.com/kokizzu) for the dependency injection concept & ideas + +## 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. +Copyright (C) 2021-present Reinaldy Rafli + +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 +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . ``` \ No newline at end of file