Skip to content

Commit

Permalink
refactor: setup common types for service (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
kentSarmiento authored Jan 2, 2024
1 parent db48c47 commit e2778be
Show file tree
Hide file tree
Showing 35 changed files with 131 additions and 581 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[net]
git-fetch-with-cli = true
43 changes: 18 additions & 25 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
version: 2

updates:
- package-ecosystem: "cargo"
directory: "/link-for-later"
schedule:
interval: weekly
time: "00:00"
open-pull-requests-limit: 15
- package-ecosystem: "cargo"
directory: "/link-for-later"
schedule:
interval: weekly
time: "00:00"
open-pull-requests-limit: 15

- package-ecosystem: "cargo"
directory: "/link-for-later-axum"
schedule:
interval: weekly
time: "00:00"
open-pull-requests-limit: 15
- package-ecosystem: "cargo"
directory: "/link-for-later-lambda"
schedule:
interval: weekly
time: "00:00"
open-pull-requests-limit: 15

- package-ecosystem: "cargo"
directory: "/link-for-later-lambda"
schedule:
interval: weekly
time: "00:00"
open-pull-requests-limit: 15

- package-ecosystem: "cargo"
directory: "/link-for-later-shuttle"
schedule:
interval: weekly
time: "00:00"
open-pull-requests-limit: 15
- package-ecosystem: "cargo"
directory: "/link-for-later-shuttle"
schedule:
interval: weekly
time: "00:00"
open-pull-requests-limit: 15
16 changes: 16 additions & 0 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: de-vri-es/setup-git-credentials@v2
with:
credentials: "https://${{ github.repository_owner }}:${{ secrets.GIT_CREDENTIALS }}@github.com"

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
Expand All @@ -43,6 +47,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: de-vri-es/setup-git-credentials@v2
with:
credentials: "https://${{ github.repository_owner }}:${{ secrets.GIT_CREDENTIALS }}@github.com"

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
Expand All @@ -68,6 +76,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: de-vri-es/setup-git-credentials@v2
with:
credentials: "https://${{ github.repository_owner }}:${{ secrets.GIT_CREDENTIALS }}@github.com"

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -100,6 +112,10 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}

- uses: de-vri-es/setup-git-credentials@v2
with:
credentials: "https://${{ github.repository_owner }}:${{ secrets.GIT_CREDENTIALS }}@github.com"

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/lambda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: de-vri-es/setup-git-credentials@v2
with:
credentials: "https://${{ github.repository_owner }}:${{ secrets.GIT_CREDENTIALS }}@github.com"

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
Expand All @@ -31,6 +35,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: de-vri-es/setup-git-credentials@v2
with:
credentials: "https://${{ github.repository_owner }}:${{ secrets.GIT_CREDENTIALS }}@github.com"

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/shuttle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: shuttle-hq/deploy-action@main
- uses: de-vri-es/setup-git-credentials@v2
with:
credentials: "https://${{ github.repository_owner }}:${{ secrets.GIT_CREDENTIALS }}@github.com"

- name: Deploy using shuttle
uses: shuttle-hq/deploy-action@main
with:
deploy-key: ${{ secrets.SHUTTLE_API_KEY }}
no-test: "true"
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"rust-analyzer.linkedProjects": [
"./link-for-later/Cargo.toml",
"./link-for-later-lambda/Cargo.toml",
"./link-for-later-shuttle/Cargo.toml",
"./link-for-later-shuttle/Cargo.toml"
]
}
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions link-for-later/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ chrono = { version = "0.4.31", default-features = false, features=["clock", "ser
futures = "0.3.29"
http-body-util = "0.1.0"
jsonwebtoken = "9.2.0"
link-for-later-types = { git = "https://github.com/kentSarmiento/link-for-later-types", tag = "v0.1.0" }
mongodb = "2.8.0"
reqwest = { version = "0.11.23", default-features = false, features = ["json", "rustls-tls"] }
serde = { version = "1.0.193", features = ["derive"] }
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion link-for-later/src/controller/extractors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use axum_extra::{
};
use jsonwebtoken::{decode, DecodingKey, Validation};

use crate::{dto::Claims, types::AppError};
use crate::types::{AppError, Claims};

const JWT_SECRET_KEY: &str = "JWT_SECRET";

Expand Down
8 changes: 3 additions & 5 deletions link-for-later/src/controller/routes/links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ use axum::{
};
use validator::Validate;

use crate::{
dto::{Claims, LinkItemRequest, LinkQueryBuilder},
entity::LinkItemBuilder,
types::{AppError, AppState},
use crate::types::{
AppError, AppState, Claims, LinkItemBuilder, LinkItemRequest, LinkQueryBuilder,
};

pub fn router(state: AppState) -> Router<AppState> {
Expand Down Expand Up @@ -149,13 +147,13 @@ mod tests {
use serde_json::json;

use crate::{
entity::LinkItem,
repository::{MockLinks as MockLinksRepo, MockUsers as MockUsersRepo},
service::DynLinks as DynLinksService,
service::{
MockAnalysis as MockAnalysisService, MockLinks as MockLinksService,
MockUsers as MockUsersService,
},
types::LinkItem,
};

use super::*;
Expand Down
8 changes: 2 additions & 6 deletions link-for-later/src/controller/routes/users.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
use axum::{extract::State, http::StatusCode, response::IntoResponse, routing, Json, Router};
use validator::Validate;

use crate::{
dto::{LoginResponse, UserInfoRequest},
entity::UserInfoBuilder,
types::{AppError, AppState},
};
use crate::types::{AppError, AppState, LoginResponse, UserInfoBuilder, UserInfoRequest};

pub fn router(state: AppState) -> Router<AppState> {
Router::new()
Expand Down Expand Up @@ -78,13 +74,13 @@ mod tests {
use serde_json::json;

use crate::{
dto::Token,
repository::{MockLinks as MockLinksRepo, MockUsers as MockUsersRepo},
service::DynUsers as DynUsersService,
service::{
MockAnalysis as MockAnalysisService, MockLinks as MockLinksService,
MockUsers as MockUsersService,
},
types::Token,
};

use super::*;
Expand Down
12 changes: 0 additions & 12 deletions link-for-later/src/dto.rs

This file was deleted.

2 changes: 0 additions & 2 deletions link-for-later/src/dto/request.rs

This file was deleted.

108 changes: 0 additions & 108 deletions link-for-later/src/dto/request/links.rs

This file was deleted.

Loading

0 comments on commit e2778be

Please sign in to comment.