Renamed service to api

This commit is contained in:
2024-09-03 17:15:48 -04:00
parent ec1661e048
commit 310d1eaad8
36 changed files with 46 additions and 46 deletions

6
.env
View File

@@ -1,4 +1,4 @@
RUST_LOG=warn,service=info
RUST_LOG=warn,api=info
DATABASE_CONTAINER=aviation-db
DATABASE_USER=aviation
@@ -16,8 +16,8 @@ MINIO_HOST=localhost
MINIO_PORT=9000
MINIO_PORT_INTERNAL=9001
SERVICE_HOST=localhost
SERVICE_PORT=5000
API_HOST=localhost
API_PORT=5000
UI_PORT=3000
NODE_ENV=development

View File

@@ -15,7 +15,7 @@ help: ## This info
@echo
format: ## Format code
@cd service && cargo fmt
@cd api && cargo fmt
@cd ui && npm run format
backend-up: ## Start Docker containers
@@ -29,7 +29,7 @@ backend-down: ## Stop Docker containers
down-backend: backend-down
run: ## Run the api
@cd service && cargo run
@cd api && cargo run
frontend-up: ## Start Docker containers
@docker compose --profile frontend up -d

View File

@@ -7,7 +7,7 @@
1. Copy `.env.TEMPLATE` to `.env`
2. Generate JWT RS256 (RSA Signature with SHA-256) Private/Public keys with `make generate`
3. Build the service and ui images with `make build`
3. Build the api and ui images with `make build`
4. Run the application with `make up`
## Decoding METARS

View File

@@ -369,6 +369,37 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "api"
version = "0.1.0"
dependencies = [
"actix-cors",
"actix-multipart",
"actix-web",
"actix-web-httpauth",
"argon2",
"chrono",
"diesel",
"diesel_migrations",
"dotenv",
"env_logger",
"futures-util",
"lazy_static",
"log",
"postgis_diesel",
"r2d2",
"rand",
"rand_chacha",
"redis",
"regex",
"reqwest",
"rust-s3",
"serde",
"serde_json",
"tokio",
"uuid",
]
[[package]]
name = "arc-swap"
version = "1.7.1"
@@ -2252,37 +2283,6 @@ dependencies = [
"serde",
]
[[package]]
name = "service"
version = "0.1.0"
dependencies = [
"actix-cors",
"actix-multipart",
"actix-web",
"actix-web-httpauth",
"argon2",
"chrono",
"diesel",
"diesel_migrations",
"dotenv",
"env_logger",
"futures-util",
"lazy_static",
"log",
"postgis_diesel",
"r2d2",
"rand",
"rand_chacha",
"redis",
"regex",
"reqwest",
"rust-s3",
"serde",
"serde_json",
"tokio",
"uuid",
]
[[package]]
name = "sha1"
version = "0.10.5"

View File

@@ -1,5 +1,5 @@
[package]
name = "service"
name = "api"
version = "0.1.0"
edition = "2021"
authors = ["Ben Sherriff <hello@bensherriff.com>"]

View File

@@ -27,10 +27,10 @@ RUN openssl rsa -in refresh.pem -pubout -outform PEM -out refresh.pem.pub
# Runtime
# =========
FROM keys as runtime
WORKDIR /service
WORKDIR /api
USER root
COPY --from=builder /builder/target/release/service /usr/local/bin/service
COPY --from=builder /builder/target/release/api /usr/local/bin/api
COPY --from=keys /keys /keys
CMD ["service"]
CMD ["api"]

View File

@@ -19,12 +19,12 @@ mod users;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
dotenv().ok();
env_logger::init_from_env(env_logger::Env::default().filter_or("RUST_LOG", "warn,service=info"));
env_logger::init_from_env(env_logger::Env::default().filter_or("RUST_LOG", "warn,api=info"));
db::init().await;
// scheduler::update_airports();
let host = env::var("SERVICE_HOST").unwrap_or("localhost".to_string());
let port = env::var("SERVICE_PORT").unwrap_or("5000".to_string());
let host = env::var("API_HOST").unwrap_or("localhost".to_string());
let port = env::var("API_PORT").unwrap_or("5000".to_string());
let server = match HttpServer::new(move || {
let cors = Cors::default()

View File

@@ -60,9 +60,9 @@ services:
container_name: aviation-api
env_file: *env
ports:
- "${SERVICE_PORT:-5000}:5000"
- "${API_PORT:-5000}:5000"
build:
context: service
context: api
depends_on:
- db
- redis