commit
adad65f3c9
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"commonjs": true,
|
||||
"es2021": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"airbnb-base"
|
||||
],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 12
|
||||
},
|
||||
"rules": {
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
# This will be from codecov
|
|
@ -0,0 +1 @@
|
|||
# This is codeql with setup go and setup nodejs + lint + build
|
|
@ -1,3 +0,0 @@
|
|||
node_modules
|
||||
dist
|
||||
vendor
|
|
@ -0,0 +1,5 @@
|
|||
# Contributing Guide
|
||||
|
||||
First of all. Thank you for considering to contribute on Jokes Bapak2 API project. I hope this project will get better and we will become more bapak2 than ever.
|
||||
|
||||
The rest of this document is coming soon as it's still a work in progress.
|
25
LICENSE
25
LICENSE
|
@ -174,28 +174,3 @@
|
|||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2021 Reinaldy Rafli
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
52
README.md
52
README.md
|
@ -1,3 +1,53 @@
|
|||
# Jokes Bapak2 API
|
||||
|
||||
This is the nodejs version. Still a work in progress.
|
||||
⚠ Still work in progress
|
||||
|
||||
## Brief explanation of what is this
|
||||
|
||||
This project will be a website like icanhazdadjokes but in Indonesian version 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.
|
||||
* `client` - Front facing website (front end). Created with Vite.js
|
||||
|
||||
Anyway, later you can consume this API via a website (that will be created later on when this is finished) with a few endpoints:
|
||||
|
||||
* `/v1/` - Random jokes bapak2
|
||||
* `/v1/id/[number]` - Jokes bapak2 based on ID
|
||||
* `/v1/today` - Jokes bapak2 of the day
|
||||
|
||||
Currently I'm searching for an alternative for AWS S3 that I can use for free.
|
||||
|
||||
## Tech stacks
|
||||
|
||||
* Go
|
||||
* Node.js (for development on `client`)
|
||||
* Postgres
|
||||
* Redis
|
||||
|
||||
That's it.
|
||||
|
||||
## Development
|
||||
|
||||
Two ways of doing this:
|
||||
1. Install all the tech stack on your local machine
|
||||
2. Use docker-compose
|
||||
|
||||
See README files on each project directory for further instruction on how to run the development environment.
|
||||
|
||||
## License
|
||||
|
||||
Copyright 2021-present Jokes Bapak2 API Contributors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -0,0 +1,15 @@
|
|||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
vendor/
|
|
@ -0,0 +1,25 @@
|
|||
# Jokes Bapak2 API
|
||||
|
||||
Still work in progress
|
||||
|
||||
## Development
|
||||
|
||||
```bash
|
||||
# Install modules
|
||||
$ go install
|
||||
# or
|
||||
$ go mod vendor
|
||||
|
||||
# run the local server
|
||||
$ go run ./
|
||||
|
||||
# build everything
|
||||
$ go build ./
|
||||
```
|
||||
|
||||
## Modules
|
||||
|
||||
- https://github.com/Masterminds/squirrel
|
||||
- https://github.com/jackc/pgx
|
||||
- https://github.com/go-redis/redis/v8
|
||||
- https://github.com/unrolled/secure
|
|
@ -0,0 +1,8 @@
|
|||
module github.com/aldy505/jokes-bapak2-api/api
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/gin-gonic/gin v1.7.1
|
||||
github.com/rs/cors v1.7.0
|
||||
)
|
|
@ -0,0 +1,51 @@
|
|||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.7.1 h1:qC89GU3p8TvKWMAVhEpmpB2CIb1hnqt2UdKZaP93mS8=
|
||||
github.com/gin-gonic/gin v1.7.1/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY=
|
||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
|
||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
||||
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
|
||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||
github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=
|
||||
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
|
||||
github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=
|
||||
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
|
||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
@ -0,0 +1,18 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/aldy505/jokes-bapak2-api/api/routes"
|
||||
)
|
||||
|
||||
func main() {
|
||||
routes := routes.Setup()
|
||||
server := &http.Server{
|
||||
Addr: "localhost:3000",
|
||||
Handler: routes,
|
||||
}
|
||||
log.Printf("[info] Server is running on http://localhost:3000")
|
||||
server.ListenAndServe()
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package models
|
||||
|
||||
// Set up the database connection, create table if not exists
|
||||
func Setup() {
|
||||
//
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package models
|
||||
|
||||
// Connect to the database
|
||||
func Postgres() {
|
||||
//
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package models
|
||||
|
||||
// Connect to the database
|
||||
func Redis() {
|
||||
//
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package routes
|
||||
|
||||
import (
|
||||
v1 "github.com/aldy505/jokes-bapak2-api/api/routes/v1"
|
||||
"github.com/gin-gonic/gin"
|
||||
cors "github.com/rs/cors/wrapper/gin"
|
||||
)
|
||||
|
||||
func Setup() *gin.Engine {
|
||||
router := gin.Default()
|
||||
router.Use(cors.Default())
|
||||
|
||||
version1 := router.Group("/v1")
|
||||
{
|
||||
version1.GET("/", v1.SingleJoke)
|
||||
version1.GET("/today", v1.TodayJoke)
|
||||
version1.GET("/:id", v1.JokeByID)
|
||||
}
|
||||
|
||||
return router
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func SingleJoke(c *gin.Context) {
|
||||
// get a joke from db
|
||||
// fetch the image url
|
||||
// send the image as proxied file
|
||||
}
|
||||
|
||||
func TodayJoke(c *gin.Context) {
|
||||
// check from redis if today's joke already exists
|
||||
// send the joke if exists
|
||||
// get a new joke if it's not, then send it.
|
||||
}
|
||||
|
||||
func JokeByID(c *gin.Context) {
|
||||
// get a joke from db by id
|
||||
// fetch image url
|
||||
// send the image as proxied file
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
module.exports = {
|
||||
env: {
|
||||
browser: true,
|
||||
es2021: true,
|
||||
},
|
||||
extends: [
|
||||
'airbnb-base',
|
||||
],
|
||||
parserOptions: {
|
||||
ecmaVersion: 12,
|
||||
sourceType: 'module',
|
||||
},
|
||||
rules: {
|
||||
},
|
||||
};
|
|
@ -0,0 +1,5 @@
|
|||
node_modules
|
||||
.DS_Store
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
|
@ -0,0 +1,21 @@
|
|||
# Jokes Bapak2 Client
|
||||
|
||||
Still work in progress
|
||||
|
||||
## Development
|
||||
|
||||
Please install Yarn first by doing `npm i -g yarn`
|
||||
|
||||
```bash
|
||||
# install dependency
|
||||
$ yarn install
|
||||
|
||||
# run the local server
|
||||
$ yarn dev
|
||||
|
||||
# build the package
|
||||
$ yarn build
|
||||
|
||||
# preview it before deployment
|
||||
$ yarn preview
|
||||
```
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"name": "jokes-bapak2-api",
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"serve": "vite preview",
|
||||
"lint": "eslint --fix --ext .js --ignore-path .gitignore ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@rollup/plugin-eslint": "^8.0.1",
|
||||
"tailwindcss": "^2.1.2",
|
||||
"vite": "^2.2.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^10.2.5",
|
||||
"eslint": "^7.25.0",
|
||||
"eslint-config-airbnb-base": "^14.2.1",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"postcss": "^8.2.13"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
module.exports = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
|
@ -0,0 +1,15 @@
|
|||
<svg width="410" height="404" viewBox="0 0 410 404" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M399.641 59.5246L215.643 388.545C211.844 395.338 202.084 395.378 198.228 388.618L10.5817 59.5563C6.38087 52.1896 12.6802 43.2665 21.0281 44.7586L205.223 77.6824C206.398 77.8924 207.601 77.8904 208.776 77.6763L389.119 44.8058C397.439 43.2894 403.768 52.1434 399.641 59.5246Z" fill="url(#paint0_linear)"/>
|
||||
<path d="M292.965 1.5744L156.801 28.2552C154.563 28.6937 152.906 30.5903 152.771 32.8664L144.395 174.33C144.198 177.662 147.258 180.248 150.51 179.498L188.42 170.749C191.967 169.931 195.172 173.055 194.443 176.622L183.18 231.775C182.422 235.487 185.907 238.661 189.532 237.56L212.947 230.446C216.577 229.344 220.065 232.527 219.297 236.242L201.398 322.875C200.278 328.294 207.486 331.249 210.492 326.603L212.5 323.5L323.454 102.072C325.312 98.3645 322.108 94.137 318.036 94.9228L279.014 102.454C275.347 103.161 272.227 99.746 273.262 96.1583L298.731 7.86689C299.767 4.27314 296.636 0.855181 292.965 1.5744Z" fill="url(#paint1_linear)"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear" x1="6.00017" y1="32.9999" x2="235" y2="344" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#41D1FF"/>
|
||||
<stop offset="1" stop-color="#BD34FE"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear" x1="194.651" y1="8.81818" x2="236.076" y2="292.989" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FFEA83"/>
|
||||
<stop offset="0.0833333" stop-color="#FFDD35"/>
|
||||
<stop offset="1" stop-color="#FFA800"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite App</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" class="container mx-auto"></div>
|
||||
<script type="module" src="/main.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,6 @@
|
|||
import './style.css';
|
||||
|
||||
document.querySelector('#app').innerHTML = `
|
||||
<h1 class="text-3xl">Hello Vite!</h1>
|
||||
<a href="https://vitejs.dev/guide/features.html" target="_blank">Documentation</a>
|
||||
`;
|
|
@ -0,0 +1,40 @@
|
|||
function socialTags({
|
||||
title, description, url, image, keywords, author,
|
||||
}) {
|
||||
const meta = [];
|
||||
if (title) {
|
||||
meta.push({ property: 'og:title', content: title });
|
||||
meta.push({ name: 'twitter:title', content: title });
|
||||
}
|
||||
if (description) {
|
||||
meta.push({ property: 'og:description', content: description });
|
||||
meta.push({ name: 'twitter:description', content: description });
|
||||
}
|
||||
if (url) {
|
||||
meta.push({ property: 'og:url', content: url });
|
||||
meta.push({ name: 'twitter:url', content: url });
|
||||
}
|
||||
if (image) {
|
||||
meta.push({ property: 'og:image', content: image });
|
||||
meta.push({ name: 'twitter:image', content: image });
|
||||
}
|
||||
if (keywords) {
|
||||
meta.push({ name: 'keywords', content: keywords });
|
||||
}
|
||||
if (author) {
|
||||
meta.push({ property: 'og:author', content: author });
|
||||
meta.push({ name: 'twitter:author', content: author });
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
|
||||
function injectToHead(document, headItems) {
|
||||
const { head } = document;
|
||||
for (let i = 0; i < headItems.length; i += 1) {
|
||||
const meta = document.createElement('meta');
|
||||
meta.push(headItems[i]);
|
||||
head.appendChild(meta);
|
||||
}
|
||||
}
|
||||
|
||||
export default { injectToHead, socialTags };
|
|
@ -0,0 +1,3 @@
|
|||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
|
@ -0,0 +1,16 @@
|
|||
const colors = require('tailwindcss/colors');
|
||||
|
||||
module.exports = {
|
||||
purge: [],
|
||||
darkMode: 'media', // or 'media' or 'class'
|
||||
theme: {
|
||||
colors: {
|
||||
...colors,
|
||||
},
|
||||
extend: {},
|
||||
},
|
||||
variants: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
};
|
|
@ -0,0 +1,24 @@
|
|||
import { defineConfig } from 'vite';
|
||||
import { resolve } from 'path';
|
||||
import eslint from '@rollup/plugin-eslint';
|
||||
|
||||
export default defineConfig({
|
||||
publicDir: 'public',
|
||||
root: './src',
|
||||
server: {
|
||||
port: 8000,
|
||||
cors: false,
|
||||
},
|
||||
plugins: [
|
||||
eslint({
|
||||
fix: true,
|
||||
}),
|
||||
],
|
||||
build: {
|
||||
rollupOptions: {
|
||||
input: {
|
||||
main: resolve(__dirname, 'src/index.html'),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
51
package.json
51
package.json
|
@ -1,51 +0,0 @@
|
|||
{
|
||||
"name": "jokes-bapak2-api",
|
||||
"version": "0.1.0",
|
||||
"description": "Jokes Bapak2 API",
|
||||
"main": "dist/main.js",
|
||||
"scripts": {
|
||||
"test": "nyc npm run mocha",
|
||||
"dev": "nodemon --watch src/ src/main.js",
|
||||
"build": "babel --out-dir dist/ src/",
|
||||
"mocha": "mocha test/**/*.js --exit"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/aldy505/jokes-bapak2-api.git"
|
||||
},
|
||||
"keywords": [
|
||||
"jokes",
|
||||
"bapak2",
|
||||
"bapack2",
|
||||
"api",
|
||||
"rest",
|
||||
"api"
|
||||
],
|
||||
"author": "Reinaldy Rafli <hi@reinaldyrafli.com>",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/aldy505/jokes-bapak2-api/issues"
|
||||
},
|
||||
"homepage": "https://github.com/aldy505/jokes-bapak2-api#readme",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.12.16",
|
||||
"@babel/core": "^7.12.16",
|
||||
"@babel/preset-env": "^7.12.16",
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"eslint": "^7.20.0",
|
||||
"eslint-config-airbnb-base": "^14.2.1",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"mocha": "^8.3.0",
|
||||
"nodemon": "^2.0.7",
|
||||
"nyc": "^15.1.0",
|
||||
"supertest-fetch": "^1.4.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"cors": "^2.8.5",
|
||||
"express-rate-limit": "^5.2.5",
|
||||
"helmet": "^4.4.1",
|
||||
"pg": "^8.5.1",
|
||||
"polka": "^0.5.2",
|
||||
"validator": "^13.5.2"
|
||||
}
|
||||
}
|
12
src/main.js
12
src/main.js
|
@ -1,12 +0,0 @@
|
|||
const polka = require('polka')
|
||||
const cors = require('cors')
|
||||
const rateLimit = require('express-rate-limit')
|
||||
|
||||
|
||||
const app = polka()
|
||||
const limiter = rateLimit({
|
||||
windowMs: 15 * 60 * 1000, // 15 minutes
|
||||
max: 100 // limit each IP to 100 requests per windowMs
|
||||
});
|
||||
app.use(cors())
|
||||
app.use(limiter())
|
13
test/main.js
13
test/main.js
|
@ -1,13 +0,0 @@
|
|||
require('mocha')
|
||||
|
||||
describe('main test', () => {
|
||||
it('should output an image', async () => {
|
||||
//
|
||||
})
|
||||
it('should return error', async () => {
|
||||
//
|
||||
})
|
||||
it('should return too many request', async () => {
|
||||
//
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue