Compare commits

...

105 Commits

Author SHA1 Message Date
Jef Roosens d8b0d35c40 Merge pull request 'Update dependency eslint to v8' (#94) from renovate/eslint-8.x into develop
Reviewed-on: #94
2021-12-24 09:03:02 +01:00
Jef Roosens 6c7df4b30e Merge pull request 'Update Rust crate diesel to 1.4.8' (#89) from renovate/diesel-1.x into develop
Reviewed-on: #89
2021-12-24 09:02:39 +01:00
Jef Roosens 6ff4cef5d4 Merge pull request 'Update node Docker tag to v17' (#97) from renovate/node-17.x into develop
Reviewed-on: #97
2021-12-24 09:02:25 +01:00
Jef Roosens a1a0f38f74 Merge pull request 'Update postgres Docker tag to v14' (#98) from renovate/postgres-14.x into develop
Reviewed-on: #98
2021-12-24 09:02:15 +01:00
Renovate Bot 1d83ee4338 Update postgres Docker tag to v14 2021-12-24 08:01:32 +00:00
Renovate Bot 2f66ce4e22 Update node Docker tag to v17 2021-12-24 08:01:29 +00:00
Renovate Bot 9cbdfff62f Update dependency eslint to v8 2021-12-24 08:01:11 +00:00
Renovate Bot 7dfb3c0e20 Update Rust crate diesel to 1.4.8 2021-12-24 07:59:52 +00:00
Jef Roosens fe9c19f0e8 Merge pull request 'Update Rust crate diesel to 1.4.7' (#82) from renovate/diesel-1.x into develop
continuous-integration/drone the build was successful Details
Reviewed-on: https://git.roosens.me/Chewing_Bever/fej/pulls/82
2021-06-12 21:54:40 +02:00
Renovate Bot f4aba0c16f Update Rust crate diesel to 1.4.7
continuous-integration/drone the build was successful Details
2021-06-08 08:01:24 +00:00
Jef Roosens 7cebe510f7 Merge pull request 'Update Rust crate rocket_contrib to 0.4.10' (#81) from renovate/rocket_contrib-0.x into develop
continuous-integration/drone the build was successful Details
Reviewed-on: https://git.roosens.me/Chewing_Bever/fej/pulls/81
2021-05-22 18:05:44 +02:00
Renovate Bot d4872e9c48 Update Rust crate rocket_contrib to 0.4.10
continuous-integration/drone the build was successful Details
2021-05-22 08:00:55 +00:00
Jef Roosens a35b9a73f1 Merge pull request 'Update Rust crate rocket to 0.4.10' (#80) from renovate/rocket-0.x into develop
continuous-integration/drone the build was successful Details
Reviewed-on: https://git.roosens.me/Chewing_Bever/fej/pulls/80
2021-05-22 09:06:18 +02:00
Renovate Bot af8660f99e Update Rust crate rocket to 0.4.10
continuous-integration/drone the build was successful Details
2021-05-22 07:00:54 +00:00
Jef Roosens 8207e104ae Merge pull request 'Update Rust crate rocket to 0.4.9' (#77) from renovate/rocket-0.x into develop
continuous-integration/drone the build was successful Details
Reviewed-on: https://git.roosens.me/Chewing_Bever/fej/pulls/77
2021-05-20 14:46:22 +02:00
Renovate Bot 4e24ad8988 Update Rust crate rocket to 0.4.9
continuous-integration/drone the build was successful Details
2021-05-20 11:00:57 +00:00
Jef Roosens a826d4272a Merge pull request 'Update Rust crate rocket_contrib to 0.4.9' (#78) from renovate/rocket_contrib-0.x into develop [CI SKIP]
Reviewed-on: https://git.roosens.me/Chewing_Bever/fej/pulls/78
2021-05-20 12:02:55 +02:00
Renovate Bot f6faaf0db9 Update Rust crate rocket_contrib to 0.4.9
continuous-integration/drone the build was successful Details
2021-05-19 18:00:56 +00:00
Jef Roosens 204f8f0a56 Merge pull request 'Changed import scheme' (#75) from rework-imports into develop [CI SKIP]
Reviewed-on: https://git.roosens.me/Chewing_Bever/fej/pulls/75
2021-05-13 20:50:08 +02:00
Jef Roosens cc9ff7635c
Fixed faulty import line
continuous-integration/drone the build was successful Details
2021-05-13 15:51:44 +02:00
Jef Roosens 6d95ffd372
Changed import scheme
continuous-integration/drone the build failed Details
2021-05-13 15:42:05 +02:00
Jef Roosens 237568d5e4 Merge pull request 'Update Rust crate serde to 1.0.126' (#73) from renovate/serde-1.x into develop
continuous-integration/drone the build was successful Details
Reviewed-on: https://git.roosens.me/Chewing_Bever/fej/pulls/73
2021-05-13 10:56:58 +02:00
Jef Roosens be797de526 Merge branch 'develop' into renovate/serde-1.x
continuous-integration/drone the build was successful Details
2021-05-13 10:45:19 +02:00
Jef Roosens 03020fe798 Merge pull request 'CICD Upgrade' (#72) from 45-cicd into develop
continuous-integration/drone the build was successful Details
Reviewed-on: https://git.roosens.me/Chewing_Bever/fej/pulls/72
2021-05-13 10:44:15 +02:00
Renovate Bot 82bb4c6a6e Update Rust crate serde to 1.0.126
continuous-integration/drone the build was successful Details
2021-05-12 18:03:41 +00:00
Jef Roosens 4cf9152fc4
[#45] Hopefully made Cargo home available across steps
continuous-integration/drone the build was successful Details
2021-05-12 14:44:10 +02:00
Jef Roosens 8baeda4cae
[#45] Fixed clippy errors
continuous-integration/drone the build failed Details
2021-05-12 14:29:39 +02:00
Jef Roosens 2547434d95
[#45] Added cargo caching; made clippy more strict 2021-05-12 14:28:59 +02:00
Jef Roosens b9d0bb7aa5
[#45] Removed leftover comments 2021-05-12 14:12:29 +02:00
Jef Roosens faa4f713c8
[#45] Fixed clippy errors
continuous-integration/drone the build was successful Details
2021-05-11 22:11:35 +02:00
Jef Roosens c8bfc16af8
[#45] Moved tests to before linting 2021-05-11 22:03:44 +02:00
Jef Roosens 9dbb4c8804
[#45] Moved clippy call to lint phase
continuous-integration/drone the build failed Details
2021-05-11 21:58:49 +02:00
Jef Roosens 728e72e47c
[#45] Removed unnecessary clippy flag (and let's test the cache)
continuous-integration/drone the build failed Details
2021-05-11 21:51:54 +02:00
Jef Roosens 01aa4bae80
[#45] Re-ordered tasks to make them logical
continuous-integration/drone the build failed Details
2021-05-11 21:41:54 +02:00
Jef Roosens 2a14703097
[#45] Let's try some other env vars
continuous-integration/drone the build failed Details
2021-05-11 21:38:19 +02:00
Jef Roosens 81c0d5e00b
[#45] Changed root style
continuous-integration/drone the build failed Details
2021-05-11 21:19:18 +02:00
Jef Roosens 63316314aa
[#45] Another try at fixing the ci
continuous-integration/drone the build failed Details
2021-05-11 20:43:51 +02:00
Jef Roosens 0ec5e33860
[#45] Enabled debug logs for debugging
continuous-integration/drone the build failed Details
2021-05-10 22:22:51 +02:00
Jef Roosens 9d065c229e
[#45] Added path_style option
continuous-integration/drone the build failed Details
2021-05-10 22:21:56 +02:00
Jef Roosens b8f31aa337
[#45] Renamed root 2021-05-10 22:19:49 +02:00
Jef Roosens bd51b6ce14
[#45] More updates to cicd file
continuous-integration/drone the build failed Details
2021-05-10 22:15:05 +02:00
Jef Roosens 4666790784
[#45] Edited broken env vars
continuous-integration/drone the build failed Details
2021-05-10 21:57:15 +02:00
Jef Roosens 92c6e2c5cc
[#45] It's plugins/s3-cache dude
continuous-integration/drone the build failed Details
2021-05-10 21:54:56 +02:00
Jef Roosens ff1631b525
[#45] Fixed first of probably many errors
continuous-integration/drone the build failed Details
2021-05-10 21:54:03 +02:00
Jef Roosens cd4075d294
[#45] First attempt at using S3 cache 2021-05-10 21:52:24 +02:00
Jef Roosens 785acd5c2e Merge pull request 'Update Rust crate regex to 1.5.4' (#70) from renovate/regex-1.x into develop
continuous-integration/drone the build was successful Details
Reviewed-on: https://git.roosens.me/Chewing_Bever/fej/pulls/70
2021-05-07 23:15:48 +02:00
Renovate Bot 48802dbc3c Update Rust crate regex to 1.5.4
continuous-integration/drone the build was successful Details
2021-05-07 20:03:30 +00:00
Jef Roosens 487edf9ebd Merge pull request 'Update dependency vue-tsc to ^0.1.0' (#66) from renovate/vue-tsc-0.x into develop
continuous-integration/drone the build was successful Details
Reviewed-on: https://git.roosens.me/Chewing_Bever/fej/pulls/66
2021-05-03 14:42:07 +02:00
Renovate Bot d7ee53e62c Update dependency vue-tsc to ^0.1.0
continuous-integration/drone the build was successful Details
2021-05-02 22:02:21 +00:00
Jef Roosens f9da125b4a
Added .editorconfig file
continuous-integration/drone the build was successful Details
2021-05-02 16:12:05 +02:00
Jef Roosens 135e74e6e3 Merge pull request 'Update Rust crate regex to 1.5.3' (#62) from renovate/regex-1.5.x into develop
continuous-integration/drone the build was successful Details
Reviewed-on: https://git.roosens.me/Chewing_Bever/fej/pulls/62
2021-05-02 10:11:06 +02:00
Renovate Bot 5725b91c61 Update Rust crate regex to 1.5.3
continuous-integration/drone the build was successful Details
2021-05-02 01:03:26 +00:00
Jef Roosens 336ff25249
Disabled builder publish for now
continuous-integration/drone the build was successful Details
2021-05-01 22:49:05 +02:00
Jef Roosens 3bbc90ad60
Changed order of pipeline
continuous-integration/drone the build failed Details
2021-05-01 22:09:23 +02:00
Jef Roosens 472f890a98
Added job to deploy builder
continuous-integration/drone the build failed Details
2021-05-01 22:07:07 +02:00
Jef Roosens 3f5c0d038b
Added backend linting job
continuous-integration/drone the build was successful Details
2021-05-01 21:40:46 +02:00
Jef Roosens fd6b3ed134
Added yarn.lock file
continuous-integration/drone the build was successful Details
2021-05-01 21:34:41 +02:00
Jef Roosens 92a08a17af
Hopefully fixed dumb ci mistake
continuous-integration/drone the build was successful Details
2021-05-01 21:29:17 +02:00
Jef Roosens 9946aaf001
Added frontend linting to cicd
continuous-integration/drone the build failed Details
2021-05-01 21:24:16 +02:00
Jef Roosens 1da94c5211
Fixed eslint errors 2021-05-01 21:22:12 +02:00
Jef Roosens 6532fbebb1
Fixed frontend linter 2021-05-01 21:11:13 +02:00
Jef Roosens 0b86ed9254 Merge pull request 'Update dependency vue-tsc to ^0.0.26' (#59) from renovate/vue-tsc-0.0.x into develop
Reviewed-on: https://git.roosens.me/Chewing_Bever/fej/pulls/59
2021-05-01 21:01:00 +02:00
Jef Roosens d2e6028104 Merge pull request 'Update dependency eslint-plugin-promise to v5' (#60) from renovate/eslint-plugin-promise-5.x into develop
Reviewed-on: https://git.roosens.me/Chewing_Bever/fej/pulls/60
2021-05-01 21:00:48 +02:00
Renovate Bot 9f31c69777 Update dependency eslint-plugin-promise to v5 2021-05-01 18:00:34 +00:00
Renovate Bot 39ad811429 Update dependency vue-tsc to ^0.0.26 2021-05-01 18:00:28 +00:00
Jef Roosens bef7505631
Merge branch 'develop' of git.roosens.me:Chewing_Bever/fej into develop 2021-05-01 19:12:35 +02:00
Jef Roosens 5ce3f0bb39
Merge branch '58-js-linting' into develop (Closes #58) 2021-05-01 19:12:18 +02:00
Jef Roosens e67616baa1
[#58] Added ESLint & ran formatter 2021-05-01 19:09:58 +02:00
Jef Roosens 36bd27c919 Merge pull request 'Update Rust crate regex to 1.5.2' (#57) from renovate/regex-1.5.x into develop
Reviewed-on: https://git.roosens.me/Chewing_Bever/fej/pulls/57
2021-05-01 18:53:09 +02:00
Renovate Bot 1cf009c212 Update Rust crate regex to 1.5.2 2021-05-01 12:01:46 +00:00
Jef Roosens e179b1eadb Merge pull request 'Update Rust crate regex to 1.5.1' (#55) from renovate/regex-1.x into develop
Reviewed-on: https://git.roosens.me/Chewing_Bever/fej/pulls/55
2021-05-01 09:45:58 +02:00
Renovate Bot e5b872acdf Update Rust crate regex to 1.5.1 2021-05-01 01:05:14 +00:00
Jef Roosens a738951961 Merge pull request 'Update node Docker tag to v16' (#53) from renovate/node-16.x into develop
Reviewed-on: https://git.roosens.me/Chewing_Bever/fej/pulls/53
2021-04-30 13:34:02 +02:00
Renovate Bot 8e3425749f Update node Docker tag to v16 2021-04-30 08:00:41 +00:00
Jef Roosens f27775910f
Simplified Ivago API wrapper in frontend 2021-04-30 00:24:19 +02:00
Jef Roosens 4b3ae8a9a4
[Closes #44] Merge branch '44-migrate-frontend' into develop 2021-04-29 11:51:19 +02:00
Jef Roosens d2ad0591f6
[#44] Added some stuff to cicd file 2021-04-29 11:43:53 +02:00
Jef Roosens 28bb959c12
[#44] Fixed development .env file 2021-04-29 11:37:35 +02:00
Jef Roosens 5a95ee5270
[#44] Added frontend hosting using feature 2021-04-29 11:34:35 +02:00
Jef Roosens e0ac8ddd24
[#44] [#44] Release container now builds & packages frontend as well 2021-04-29 10:50:21 +02:00
Jef Roosens 628a918682
[#44] Fej can now easily startup a Vite development server 2021-04-29 10:23:07 +02:00
Jef Roosens 0055667877
[#44] [#44] Added proper Node.js gitignore 2021-04-29 10:04:18 +02:00
Jef Roosens 687632a704
[#44] Added frontend source code 2021-04-29 09:58:29 +02:00
Jef Roosens 659632eba5
Merge branch 'develop' of git.roosens.me:fej/backend into develop 2021-04-24 12:45:25 +02:00
Jef Roosens 77e04d5b6b
Added cicd restriction [CI SKIP] 2021-04-24 12:44:53 +02:00
Jef Roosens 2c75e29e1b Merge pull request 'Update Rust crate regex to 1.4.6' (#42) from renovate/rust-regex-1.x into develop
Reviewed-on: https://git.roosens.me/fej/backend/pulls/42
2021-04-24 10:23:05 +02:00
Jef Roosens 683e48281f Merge pull request 'Update alpine Docker tag to v3.13.5' (#43) from renovate/docker-alpine-3.x into develop
continuous-integration/drone the build failed Details
Reviewed-on: https://git.roosens.me/fej/backend/pulls/43
2021-04-24 10:14:03 +02:00
Renovate Bot caa92377f6 Update alpine Docker tag to v3.13.5
continuous-integration/drone the build was successful Details
2021-04-24 08:03:09 +00:00
Jef Roosens 3bdf79e824
Made builder root again
continuous-integration/drone the build was successful Details
2021-04-24 09:47:28 +02:00
Jef Roosens 0abfaca967
Added test cicd job
continuous-integration/drone the build failed Details
2021-04-24 09:33:42 +02:00
Jef Roosens 62738354a0
Just a commit
continuous-integration/drone the build was successful Details
2021-04-24 00:27:43 +02:00
Jef Roosens 2a4153d430
Merge branch 'develop' of git.roosens.me:fej/backend into develop 2021-04-24 00:20:34 +02:00
Jef Roosens 9e428b1882
Added test .drone.yml 2021-04-24 00:20:20 +02:00
Renovate Bot 0082076527 Update Rust crate regex to 1.4.6 2021-04-22 22:04:08 +00:00
Jef Roosens 7ccfe6eebf Merge pull request 'Update Rust crate reqwest to 0.11.3' (#36) from renovate/rust-reqwest-0.x into develop
Reviewed-on: https://git.roosens.me/fej/backend/pulls/36
2021-04-20 11:15:49 +02:00
Jef Roosens f1416aaa48 Merge pull request 'Update Rust crate serde to 1.0.125' (#37) from renovate/rust-serde-1.x into develop
Reviewed-on: https://git.roosens.me/fej/backend/pulls/37
2021-04-20 11:15:30 +02:00
Renovate Bot 26ec8b4eba Update Rust crate serde to 1.0.125 2021-04-20 09:09:29 +00:00
Renovate Bot b93d771372 Update Rust crate reqwest to 0.11.3 2021-04-20 09:09:25 +00:00
Jef Roosens e5b9c285fa Merge pull request 'Configure Renovate' (#35) from renovate/configure into develop
Reviewed-on: https://git.roosens.me/fej/backend/pulls/35
2021-04-20 10:07:09 +02:00
Renovate Bot bf8a0ae666 Add renovate.json 2021-04-20 08:00:45 +00:00
Jef Roosens ecec03134a
Added populate_ivago to crontab 2021-04-17 23:29:32 +02:00
Jef Roosens 5b0e595253
Merge branch '28-db-lib' into develop 2021-04-17 23:29:26 +02:00
Jef Roosens 85611e2d59
[#28] Added basic ivago scraper 2021-04-17 23:20:41 +02:00
Jef Roosens 0877cc590c
[#28] Moved db stuff to own module 2021-04-17 22:44:15 +02:00
Jef Roosens 91985a1710
[#28] Switched search_streets to database 2021-04-17 22:39:22 +02:00
49 changed files with 4527 additions and 116 deletions

View File

@ -1,20 +1,42 @@
*
# Source code
# =====BACKEND=====
## Source code
!src/
# Cargo files
## Cargo files
!Cargo.toml
!Cargo.lock
# Entrypoint for devop container
## Entrypoint for devop container
!docker/entrypoint_dev.sh
!docker/entrypoint.sh
# Config file
## Config file
!Rocket.toml
# Database migrations
## Database migrations
!migrations/
## Crontab for release container
!docker/crontab
# =====FRONTEND=====
## Source code
!web/src/
## Public assets
!web/public/
!web/index.html
## Production env file
!web/.env.production
## Package manager stuff
!web/package.json
!web/yarn.lock
## Project configs
!web/tsconfig.json
!web/vite.config.ts

7
.editorconfig 100644
View File

@ -0,0 +1,7 @@
root = true
[*]
end_of_line = lf
insert_final_newline = false
indent_style = space
indent_size = 4

91
.woodpecker.yml 100644
View File

@ -0,0 +1,91 @@
pipeline:
# Download the cache from S3
restore-cache:
image: plugins/s3-cache
pull: true
endpoint: https://s3.roosens.me
root: build-cache/
restore: true
secrets: [ cache_s3_access_key, cache_s3_secret_key ]
# =====BUILDING=====
build-frontend:
image: node:15-alpine3.13
pull: true
group: build
commands:
- cd web
- yarn install
- yarn run build
build-backend:
image: chewingbever/fej-builder:latest
pull: true
group: build
environment:
- CARGO_HOME=.cargo
commands:
- cargo build
# =====TESTING=====
test-backend:
image: chewingbever/fej-builder:latest
environment:
- CARGO_HOME=.cargo
commands:
- cargo test
# =====LINTING=====
lint-frontend:
image: node:15-alpine3.13
group: lint
commands:
- cd web
- yarn run lint
lint-backend:
image: chewingbever/fej-builder:latest
group: lint
environment:
- CARGO_HOME=.cargo
commands:
- cargo fmt -- --check
# This is run here because it requires compilation
- cargo clippy --all-targets -- -D warnings
# =====REBUILD & FLUSH CACHE=====
rebuild-cache:
image: plugins/s3-cache
endpoint: https://s3.roosens.me
root: build-cache/
rebuild: true
mount:
- target
- .cargo
- web/node_modules
secrets: [ cache_s3_access_key, cache_s3_secret_key ]
# Push the cache, even on failure
when:
status: [ success, failure ]
flush-cache:
image: plugins/s3-cache
endpoint: https://s3.roosens.me
root: build-cache/
flush: true
# Delete cache older than 30 days (might lower this)
flush_age: 14
secrets: [ cache_s3_access_key, cache_s3_secret_key ]
# Push the cache, even on failure
when:
status: [ success, failure ]

56
Cargo.lock generated
View File

@ -58,9 +58,9 @@ dependencies = [
[[package]]
name = "aho-corasick"
version = "0.7.15"
version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
dependencies = [
"memchr",
]
@ -98,12 +98,6 @@ dependencies = [
"safemem",
]
[[package]]
name = "base64"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
[[package]]
name = "base64"
version = "0.13.0"
@ -323,9 +317,9 @@ dependencies = [
[[package]]
name = "diesel"
version = "1.4.6"
version = "1.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "047bfc4d5c3bd2ef6ca6f981941046113524b9a9f9a7cbdfdd7ff40f58e6f542"
checksum = "b28135ecf6b7d446b43e27e225622a038cc4e2930a1022f51cdb97ada19b8e4d"
dependencies = [
"bitflags",
"byteorder",
@ -861,9 +855,9 @@ checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
[[package]]
name = "memchr"
version = "2.3.4"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc"
[[package]]
name = "migrations_internals"
@ -1342,9 +1336,9 @@ dependencies = [
[[package]]
name = "regex"
version = "1.4.5"
version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
dependencies = [
"aho-corasick",
"memchr",
@ -1353,9 +1347,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
version = "0.6.23"
version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "remove_dir_all"
@ -1406,12 +1400,12 @@ dependencies = [
[[package]]
name = "rocket"
version = "0.4.7"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7febfdfd4d43facfc7daba20349ebe2c310c6735bd6a2a9255ea8bc425b4cb13"
checksum = "4a7ab1dfdc75bb8bd2be381f37796b1b300c45a3c9145b34d86715e8dd90bf28"
dependencies = [
"atty",
"base64 0.12.3",
"base64 0.13.0",
"log 0.4.14",
"memchr",
"num_cpus",
@ -1427,9 +1421,9 @@ dependencies = [
[[package]]
name = "rocket_codegen"
version = "0.4.7"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ceac2c55b2c8b1cdc53add64332defa5fc227f64263b86b4114d1386286d42a3"
checksum = "1729e687d6d2cf434d174da84fb948f7fef4fac22d20ce94ca61c28b72dbcf9f"
dependencies = [
"devise",
"glob",
@ -1442,9 +1436,9 @@ dependencies = [
[[package]]
name = "rocket_contrib"
version = "0.4.7"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7954a707f9ca18aa74ca8c1f5d1f900f52a4dceb68e96e3112143f759cfd20e"
checksum = "6b6303dccab46dce6c7ac26c9b9d8d8cde1b19614b027c3f913be6611bff6d9b"
dependencies = [
"diesel",
"log 0.4.14",
@ -1458,9 +1452,9 @@ dependencies = [
[[package]]
name = "rocket_contrib_codegen"
version = "0.4.7"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30deb6dec53b91fac3538a2a3935cf13e0f462745f9f33bf27bedffbe7265b5d"
checksum = "a0f2cbcb6c09b3ac0acdf77682ff8c9d1f317361498a773ee50b32be7fddfe2b"
dependencies = [
"devise",
"quote 0.6.13",
@ -1470,9 +1464,9 @@ dependencies = [
[[package]]
name = "rocket_http"
version = "0.4.7"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce364100ed7a1bf39257b69ebd014c1d5b4979b0d365d8c9ab0aa9c79645493d"
checksum = "6131e6e6d38a9817f4a494ff5da95971451c2eb56a53915579fc9c80f6ef0117"
dependencies = [
"cookie 0.11.4",
"hyper 0.10.16",
@ -1580,18 +1574,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "serde"
version = "1.0.125"
version = "1.0.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171"
checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.125"
version = "1.0.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d"
checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43"
dependencies = [
"proc-macro2 1.0.26",
"quote 1.0.9",

View File

@ -4,6 +4,10 @@ version = "1.0.2"
authors = ["Jef Roosens <roosensjef@gmail.com>"]
edition = "2018"
[features]
# Enables hosting of the frontend
frontend = []
[lib]
name = "fej"
path = "src/fej/lib.rs"
@ -19,18 +23,26 @@ test = true
bench = true
doc = true
doctest = true
[[bin]]
name = "populate_ivago"
path = "src/populate_ivago.rs"
test = false
bench = false
doc = false
doctest = false
[dependencies]
rocket = "0.4.7"
serde = "1.0.124"
rocket = "0.4.10"
serde = "1.0.126"
chrono = "0.4.19"
chrono-tz = "0.5.3"
regex = "1.4.5"
reqwest = { version = "0.11.2", features = ["blocking", "json", "cookies"] }
diesel = { version = "1.4.6", features = ["postgres"] }
regex = "1.5.4"
reqwest = { version = "0.11.3", features = ["blocking", "json", "cookies"] }
diesel = { version = "1.4.8", features = ["postgres"] }
diesel_migrations = "1.4.0"
[dependencies.rocket_contrib]
version = "0.4.7"
version = "0.4.10"
default-features = false
features = ["json", "diesel_postgres_pool"]
features = ["json", "diesel_postgres_pool", "serve"]

View File

@ -2,4 +2,4 @@
# see diesel.rs/guides/configuring-diesel-cli
[print_schema]
file = "src/schema.rs"
file = "src/fej/schema.rs"

View File

@ -1,8 +1,8 @@
# vim: filetype=dockerfile
# Our entire toolchain runs in alpine
FROM alpine:latest AS builder
FROM alpine:3.13.5 AS builder
ENV PATH "$PATH:/app/.cargo/bin"
ENV PATH "$PATH:/root/.cargo/bin"
# Needed for proper compiling of openssl-dev
ENV RUSTFLAGS "-C target-feature=-crt-static"
@ -19,18 +19,7 @@ RUN addgroup -S builder && \
openssl-dev \
postgresql-dev
# Switch to the non-root user
USER builder
WORKDIR /app
# Install rustup in the new user's home
# Create mountpoints for volumes with correct permissions
RUN { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly; } && \
rustup target add x86_64-unknown-linux-musl --toolchain nightly && \
mkdir -p .cargo/registry target
# Copy source code over to builder
COPY --chown=builder:builder Cargo.toml Cargo.lock ./
COPY --chown=builder:builder src/ ./src/
COPY --chown=builder:builder migrations/ ./migrations/
rustup target add x86_64-unknown-linux-musl --toolchain nightly

View File

@ -3,6 +3,10 @@ FROM chewingbever/fej-builder:latest
ENV RUST_BACKTRACE 1
# Copy source code over to builder
COPY --chown=builder:builder Cargo.toml Cargo.lock ./
COPY --chown=builder:builder src/ ./src/
COPY --chown=builder:builder migrations/ ./migrations/
COPY --chown=builder:builder ./docker/entrypoint_dev.sh /entrypoint.sh
COPY --chown=builder:builder ./Rocket.toml /app/Rocket.toml

View File

@ -1,5 +1,9 @@
# vim: filetype=dockerfile
FROM chewingbever/fej-builder:latest AS builder
FROM chewingbever/fej-builder:latest AS backend-builder
COPY --chown=builder:builder Cargo.toml Cargo.lock ./
COPY --chown=builder:builder src/ ./src/
COPY --chown=builder:builder migrations/ ./migrations/
# And then finally, build the project
# Thank the lords that this article exists
@ -15,11 +19,22 @@ FROM chewingbever/fej-builder:latest AS builder
RUN cargo install \
--path . \
--root /app/output \
--target x86_64-unknown-linux-musl
--target x86_64-unknown-linux-musl \
--features frontend
FROM node:17-alpine3.13 AS frontend-builder
COPY ./web /app
WORKDIR /app
# Build the frontend
RUN yarn install && \
yarn run build
# Now, we create the actual image
FROM alpine:latest
FROM alpine:3.13.5
COPY ./docker/crontab /var/spool/cron/crontabs/fej
# Install some dynamic libraries needed for everything to work
@ -37,8 +52,9 @@ RUN apk update && \
# Switch to non-root user
USER fej:fej
# Copy binary over to final image
COPY --from=builder --chown=fej:fej /app/output/bin /app/bin
# Copy binary & frontend over to final image
COPY --from=backend-builder --chown=fej:fej /app/output/bin /app/bin
COPY --from=frontend-builder --chown=fej:fej /app/dist /app/dist
# Embed config file inside container
# The workdir is changed so that the config file is read properly

View File

@ -1 +1,2 @@
# This'll be filled up later
# Runs the ivago scraper
*/30 * * * * /app/bin/populate_ivago

View File

@ -13,7 +13,7 @@ services:
- 'DATABASE_URL=postgres://fej:fej@db:5432/fej'
db:
image: 'postgres:13-alpine'
image: 'postgres:14-alpine'
restart: 'always'
environment:

26
fejctl
View File

@ -1,6 +1,7 @@
#!/usr/bin/env bash
image='chewingbever/fej'
web_dir='web'
# Small wrapper around the docker-compose command
#
@ -18,16 +19,6 @@ function dc() {
done
shift $((OPTIND-1))
if [[ "$build_builder" -eq 1 ]]; then
# We always rebuild the builder before we run any compose command
DOCKER_BUILDKIT=1 docker build \
-f docker/Dockerfile.builder \
-t "$image-builder:latest" . || {
>&2 echo "Failed to build builder.";
exit 1;
}
fi
if [[ "$release" -eq 1 ]]; then
DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker-compose \
--file docker/docker-compose.yml \
@ -53,6 +44,18 @@ function dcr() {
--detach
}
# Publish the builder image
function publish_builder() {
DOCKER_BUILDKIT=1 docker build \
-f docker/Dockerfile.builder \
-t "$image-builder:latest" . || {
>&2 echo "Failed to build builder.";
exit 1;
}
docker push "$image-builder:latest"
}
# Tags & pushes the release version to Docker Hub
function publish() {
local branch=`git rev-parse --abbrev-ref HEAD`
@ -96,10 +99,12 @@ function main() {
# Building
b | build ) dcr build --bin "$bin" && dc -- logs -f app ;;
br | build-release ) dc -br build ;;
bf | build-frontend ) cd "$web_dir" && yarn run build ;;
# Running
r | run ) dcr run --bin "$bin" && dc -- logs -f app ;;
rr | run-release ) dc -br -- up --build --detach && dc -r -- logs -f app ;;
rf | run-frontend ) dcr run --bin server && cd "$web_dir" && yarn run dev ;;
s | stop ) dc down ;;
sr | stop-release ) dc -r stop ;;
@ -113,6 +118,7 @@ function main() {
l | logs ) dc -- logs -f app ;;
lint ) cargo fmt -- --check ;;
p | push | publish ) publish ;;
pb ) publish_builder ;;
t | test ) dcr -- test --no-fail-fast && dc -- logs -f app ;;
* ) >&2 echo "Invalid command."; exit 1 ;;
esac

View File

View File

@ -1,2 +1,2 @@
-- This file should undo anything in `up.sql`
DROP SCHEMA ivago CASCADE;
DROP table ivago_streets;

View File

@ -1,7 +1,4 @@
-- Your SQL goes here
CREATE SCHEMA ivago;
CREATE TABLE ivago.streets (
CREATE TABLE ivago_streets (
name TEXT NOT NULL,
city TEXT NOT NULL,

3
renovate.json 100644
View File

@ -0,0 +1,3 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
}

View File

@ -8,6 +8,7 @@ use rocket::http::Status;
pub enum FejError {
InvalidArgument,
FailedRequest,
DatabaseError,
}
// I'd love to move this over to the server binary, but right now, error E0117 is making that
@ -17,6 +18,7 @@ impl From<FejError> for Status {
match err {
FejError::InvalidArgument => Status::BadRequest,
FejError::FailedRequest => Status::InternalServerError,
FejError::DatabaseError => Status::InternalServerError,
}
}
}
@ -33,3 +35,9 @@ impl From<chrono::ParseError> for FejError {
FejError::InvalidArgument
}
}
impl From<diesel::result::Error> for FejError {
fn from(_: diesel::result::Error) -> FejError {
FejError::DatabaseError
}
}

View File

@ -1,11 +1,8 @@
use crate::errors::FejError;
use chrono::{DateTime, NaiveDate, TimeZone};
use chrono_tz::Europe::Brussels;
use chrono_tz::Tz;
use rocket::http::RawStr;
use rocket::request::FromFormValue;
use serde::ser::Serializer;
use serde::Serialize;
use chrono_tz::{Europe::Brussels, Tz};
use rocket::{http::RawStr, request::FromFormValue};
use serde::{ser::Serializer, Serialize};
use std::convert::TryFrom;
/// This class is a simple wrapper around chrono's DateTime. Its sole purpose

View File

@ -0,0 +1,10 @@
use super::Street;
use crate::{errors::FejError, schema::ivago_streets::dsl::*};
use {diesel::prelude::*, PgConnection};
pub fn search_streets(db_con: &PgConnection, search_term: &str) -> Result<Vec<Street>, FejError> {
Ok(ivago_streets
.filter(name.ilike(format!("%{}%", search_term)))
.or_filter(city.ilike(format!("%{}%", search_term)))
.load(db_con)?)
}

View File

@ -2,10 +2,13 @@ use crate::errors::FejError;
use chrono::DateTime;
use chrono_tz::Tz;
use reqwest::blocking as reqwest;
use std::collections::HashMap;
use std::convert::{From, TryFrom};
use std::{
collections::HashMap,
convert::{From, TryFrom},
};
mod basic_date;
pub mod db;
mod pickup_time;
mod street;

View File

@ -16,10 +16,7 @@ impl PickupTime {
/// * `date` - Date of pickup time
/// * `label` - Type of trash
pub fn new(date: BasicDate, label: String) -> PickupTime {
PickupTime {
date: date,
label: label,
}
PickupTime { date, label }
}
}

View File

@ -1,10 +1,13 @@
use crate::schema::ivago_streets;
use diesel::{Insertable, Queryable};
use regex::Regex;
use rocket::http::RawStr;
use rocket::request::FromFormValue;
use rocket::{http::RawStr, request::FromFormValue};
use serde::ser::{Serialize, SerializeStruct, Serializer};
use std::convert::TryFrom;
/// Represents a street in a given city
#[derive(Queryable, Insertable)]
#[table_name = "ivago_streets"]
pub struct Street {
name: String,
city: String,
@ -14,10 +17,7 @@ impl Street {
// This constructor just makes my life a bit easier during testing
#[cfg(test)]
fn new(name: String, city: String) -> Street {
Street {
name: name,
city: city,
}
Street { name, city }
}
}

View File

@ -1,7 +1,10 @@
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate diesel;
// Route modules
pub mod ivago;
// Helper modules
pub mod errors;
pub mod schema;

View File

@ -0,0 +1,6 @@
table! {
ivago_streets (name, city) {
name -> Text,
city -> Text,
}
}

View File

@ -0,0 +1,21 @@
use diesel::{insert_into, Connection, PgConnection, RunQueryDsl};
use fej::{ivago::search_streets, schema::ivago_streets::dsl::*};
const ABC: &str = "abcdefghijklmnopqrstuvwxyz";
fn main() {
let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let db_conn = PgConnection::establish(&database_url)
.unwrap_or_else(|_| panic!("Error connecting to {}", database_url));
// Doing this linearly is good enough I'd say
for c in ABC.chars() {
if let Ok(streets) = search_streets(&c.to_string()) {
insert_into(ivago_streets)
.values(streets)
.execute(&db_conn)
.expect("Failed to insert rows.");
}
}
}

View File

View File

@ -15,15 +15,18 @@ mod routes;
// Very temporary solution for CORS
// https://stackoverflow.com/questions/62412361/how-to-set-up-cors-or-options-for-rocket-rs
use rocket::fairing::AdHoc;
use rocket::fairing::{Fairing, Info, Kind};
use rocket::http::Header;
use rocket::{Request, Response, Rocket};
use rocket::{
fairing::{AdHoc, Fairing, Info, Kind},
http::Header,
Request, Response, Rocket,
};
use rocket_contrib::databases::diesel;
#[cfg(feature = "frontend")]
use rocket_contrib::serve::StaticFiles;
pub struct CORS;
pub struct Cors;
impl Fairing for CORS {
impl Fairing for Cors {
fn info(&self) -> Info {
Info {
name: "Add CORS headers to responses",
@ -47,7 +50,7 @@ embed_migrations!();
// This defines a connection to the database
#[database("postgres_fej")]
struct FejDbConn(diesel::PgConnection);
pub struct FejDbConn(diesel::PgConnection);
// I'd like to thank Stackoverflow for helping me with this
// https://stackoverflow.com/questions/61047355/how-to-run-diesel-migration-with-rocket-in-production
@ -55,17 +58,27 @@ fn run_db_migrations(rocket: Rocket) -> Result<Rocket, Rocket> {
let conn = FejDbConn::get_one(&rocket).expect("database connection");
match embedded_migrations::run(&*conn) {
Ok(()) => Ok(rocket),
Err(e) => Err(rocket),
Err(_) => Err(rocket),
}
}
fn rocket() -> rocket::Rocket {
rocket::ignite()
.attach(CORS)
// This needs to be muted for the frontend feature
#[allow(unused_mut)]
let mut rocket = rocket::ignite()
.attach(Cors)
.attach(FejDbConn::fairing())
.attach(AdHoc::on_attach("Database Migrations", run_db_migrations))
.mount("/ivago", routes::ivago())
.register(catchers![catchers::not_found])
.mount("/api/ivago", routes::ivago()) // /api being hardcoded is temporary
.register(catchers![catchers::not_found]);
// TODO make all of this not hard-coded
#[cfg(feature = "frontend")]
{
rocket = rocket.mount("/", StaticFiles::from("/app/dist"));
}
rocket
}
fn main() {

View File

@ -1,4 +1,5 @@
use fej::ivago::{get_pickup_times, search_streets, BasicDate, PickupTime, Street};
use crate::FejDbConn;
use fej::ivago::{db::search_streets, get_pickup_times, BasicDate, PickupTime, Street};
use rocket::http::Status;
use rocket_contrib::json::Json;
@ -9,8 +10,8 @@ use rocket_contrib::json::Json;
///
/// * `search_term` - Search term to use to look for streets
#[get("/search?<q>")]
pub fn route_search_streets(q: String) -> Result<Json<Vec<Street>>, Status> {
Ok(Json(search_streets(q.as_str())?))
pub fn route_search_streets(db_conn: FejDbConn, q: String) -> Result<Json<Vec<Street>>, Status> {
Ok(Json(search_streets(&db_conn.0, q.as_str())?))
}
/// Handles returning of pickup times for a specific address. It returns a list

View File

@ -1,6 +1,5 @@
/// In here, any non-unit tests are placed.
use rocket::http::Status;
use rocket::local::Client;
use rocket::{http::Status, local::Client};
fn rocket() -> rocket::Rocket {
rocket::ignite().mount("/", super::routes::ivago())

1
web/.env 100644
View File

@ -0,0 +1 @@
VITE_ENDPOINT=http://localhost:8000/api

View File

@ -0,0 +1 @@
VITE_ENDPOINT=https://fej.roosens.me/api

15
web/.eslintrc.yml 100644
View File

@ -0,0 +1,15 @@
env:
browser: true
es2021: true
extends:
- 'plugin:vue/essential'
- standard
parserOptions:
ecmaVersion: 12
parser: '@typescript-eslint/parser'
sourceType: module
plugins:
- vue
- '@typescript-eslint'
rules:
indent: ["error", 4]

130
web/.gitignore vendored 100644
View File

@ -0,0 +1,130 @@
# Created by https://www.toptal.com/developers/gitignore/api/node
# Edit at https://www.toptal.com/developers/gitignore?templates=node
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
.env*.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Storybook build outputs
.out
.storybook-out
storybook-static
# rollup.js default build output
dist/
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# Temporary folders
tmp/
temp/
# End of https://www.toptal.com/developers/gitignore/api/node

27
web/README.md 100644
View File

@ -0,0 +1,27 @@
# Vue 3 + Typescript + Vite
This template should help get you started developing with Vue 3 and Typescript in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Vetur](https://marketplace.visualstudio.com/items?itemName=octref.vetur). Make sure to enable `vetur.experimental.templateInterpolationService` in settings!
### If Using `<script setup>`
[`<script setup>`](https://github.com/vuejs/rfcs/pull/227) is a feature that is currently in RFC stage. To get proper IDE support for the syntax, use [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) instead of Vetur (and disable Vetur).
## Type Support For `.vue` Imports in TS
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can use the following:
### If Using Volar
Run `Volar: Switch TS Plugin on/off` from VSCode command palette.
### If Using Vetur
1. Install and add `@vuedx/typescript-plugin-vue` to the [plugins section](https://www.typescriptlang.org/tsconfig#plugins) in `tsconfig.json`
2. Delete `src/shims-vue.d.ts` as it is no longer needed to provide module info to Typescript
3. Open `src/main.ts` in VSCode
4. Open the VSCode command palette
5. Search and run "Select TypeScript version" -> "Use workspace version"

13
web/index.html 100644
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Fej</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

30
web/package.json 100644
View File

@ -0,0 +1,30 @@
{
"name": "fej-frontend",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"serve": "vite preview",
"lint": "eslint --ext .js,.vue src",
"format": "yarn run lint --fix"
},
"dependencies": {
"vue": "^3.0.5",
"vue-router": "^4.0.6"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"@vitejs/plugin-vue": "^1.2.1",
"@vue/compiler-sfc": "^3.0.5",
"eslint": "^8.0.0",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.0.0",
"eslint-plugin-vue": "^7.9.0",
"typescript": "^4.1.3",
"vite": "^2.2.1",
"vue-tsc": "^0.1.0"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

29
web/src/App.vue 100644
View File

@ -0,0 +1,29 @@
<template>
<div>
<Nav />
<router-view />
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import Nav from './components/Nav.vue'
export default defineComponent({
name: 'App',
components: {
Nav
}
})
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>

View File

@ -0,0 +1,18 @@
export interface Street {
name: string
city: string
}
export async function search (searchTerm: string): Promise<Street[]> {
const baseURL = import.meta.env.VITE_ENDPOINT as string
const r = await fetch(`${baseURL}/ivago/search?` + new URLSearchParams({
q: searchTerm
}))
if (!r.ok) {
return Promise.reject()
}
return r.json()
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -0,0 +1,15 @@
<template>
<div>
<h1>Fej</h1>
<p>Welcome to Fej, my frontend/backend combo.</p>
<p>If you can see this, the cicd worked!</p>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
name: 'Home'
})
</script>

View File

@ -0,0 +1,61 @@
<template>
<div>
<h1>Ivago</h1>
<input
v-model="query"
v-on:keyup.enter="search"
type="text"
placeholder="Street..." />
<div id="scroll-list">
<ul v-if="msg === ''">
<li
v-for="item in items"
v-bind:key="`${item.name} (${item.city})`" >
{{ item.name }} ({{ item.city }})
</li>
</ul>
<p v-else>{{ msg }}</p>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { Street, search as ivagoSearch } from '../api/ivago'
export default defineComponent({
name: 'Ivago',
data () {
return {
items: [] as Street[],
msg: '',
query: ''
}
},
methods: {
search () {
this.items = []
this.msg = 'Loading...'
if (this.query === '') {
this.msg = ''
return
}
ivagoSearch(this.query)
.then((res: Street[]) => {
this.items = res
this.msg = ''
})
}
}
})
</script>
<style scoped>
#scroll-list {
height: 200px;
overflow: hidden;
overflow-y: auto;
}
</style>

View File

@ -0,0 +1,43 @@
<template>
<div id="menu-wrapper">
<nav id="menu">
<router-link to="/">Home</router-link>
<router-link to="/ivago">Ivago</router-link>
</nav>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
name: 'Nav'
})
</script>
<style scoped>
#menu-wrapper {
position: fixed;
left: 0;
top: 0;
height: 100%;
width: 150px;
background-color: #242624;
text-align: center;
}
#menu {
margin: 20px;
}
#menu > a {
display: block;
width: 100%;
color: #5f635f;
text-decoration: none;
}
#menu > a:hover {
color: #c2ccc1;
}
</style>

8
web/src/main.ts 100644
View File

@ -0,0 +1,8 @@
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
const app = createApp(App)
app.use(router)
app.mount('#app')

21
web/src/router.ts 100644
View File

@ -0,0 +1,21 @@
import { createWebHistory, createRouter } from 'vue-router'
import Home from './components/Home.vue'
import Ivago from './components/Ivago.vue'
const routes = [
{
path: '/',
component: Home
},
{
path: '/ivago',
component: Ivago
}
]
const router = createRouter({
history: createWebHistory(),
routes
})
export default router

5
web/src/shims-vue.d.ts vendored 100644
View File

@ -0,0 +1,5 @@
declare module '*.vue' {
import { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}

15
web/tsconfig.json 100644
View File

@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["esnext", "dom"],
"types": ["vite/client"]
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
}

View File

@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()]
})

3772
web/yarn.lock 100644

File diff suppressed because it is too large Load Diff