Migrated project into separate directories

This commit is contained in:
2023-09-07 21:05:32 -04:00
parent 359c6f0ac5
commit 17d7407f1b
52 changed files with 88 additions and 8987 deletions

7
.gitignore vendored
View File

@@ -1,7 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
node_modules
/.pnp
.pnp.js
@@ -9,7 +9,7 @@
/coverage
# next.js
/.next/
.next/
/out/
# production
@@ -36,5 +36,4 @@ yarn-error.log*
target/
dist/
/data/
.env
*.env

1
.nvmrc
View File

@@ -1 +0,0 @@
18.17.1

View File

@@ -1,17 +0,0 @@
version: '3'
services:
db:
image: postgres:latest
container_name: aviation_weather_db
env_file:
- .env
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgress}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB:-aviation_weather}
volumes:
- ./data:/var/lib/postgresql/data
ports:
- "5432:5432"
restart: unless-stopped

8926
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -269,30 +269,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "aviation-weather-backend"
version = "0.1.0"
dependencies = [
"actix-cors",
"actix-rt",
"actix-web",
"chrono",
"diesel",
"diesel_migrations",
"dotenv",
"env_logger",
"lazy_static",
"listenfd",
"log",
"quick-xml",
"r2d2",
"reqwest",
"serde",
"serde_json",
"tokio",
"uuid 1.4.1",
]
[[package]]
name = "backtrace"
version = "0.3.69"
@@ -1846,6 +1822,30 @@ version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1"
[[package]]
name = "weather-service"
version = "0.1.0"
dependencies = [
"actix-cors",
"actix-rt",
"actix-web",
"chrono",
"diesel",
"diesel_migrations",
"dotenv",
"env_logger",
"lazy_static",
"listenfd",
"log",
"quick-xml",
"r2d2",
"reqwest",
"serde",
"serde_json",
"tokio",
"uuid 1.4.1",
]
[[package]]
name = "web-sys"
version = "0.3.64"

View File

@@ -1,5 +1,5 @@
[package]
name = "aviation-weather-backend"
name = "weather-service"
version = "0.1.0"
edition = "2021"

29
weather-service/Makefile Normal file
View File

@@ -0,0 +1,29 @@
#!make
include .env
SHELL := /bin/bash
.PHONY: help build start stop lint
help: ## This info
@echo
@cat Makefile | grep -E '^[a-zA-Z\/_-]+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo
up:
docker compose up -d
down:
docker compose down
connect:
docker exec -it aviation_weather_db psql -U postgres
lint: ## Run the linter
npm run lint
clean-db: ## Remove database and Cargo packages
docker exec -i ${DATABASE_HOST} sh -c 'PGPASSWORD=${DATABASE_PASSWORD} psql -U ${DATABASE_USER} -d postgres -c "DROP DATABASE IF EXISTS \"${DATABASE_NAME}\";"' || true

View File

@@ -0,0 +1,22 @@
version: '3'
services:
db:
image: postgres:latest
container_name: weather.db
env_file:
- .env
environment:
POSTGRES_USER: ${DATABASE_USER}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
POSTGRES_DB: ${DATABASE_NAME}
volumes:
- db_weather:/var/lib/postgresql/data
- db_logs_weather:/var/log
ports:
- "5433:5432"
restart: unless-stopped
volumes:
db_weather:
db_logs_weather:

View File

@@ -1,4 +1,4 @@
CREATE TABLE "airports" (
CREATE TABLE IF NOT EXISTS airports (
id SERIAL PRIMARY KEY,
full_name TEXT NOT NULL,
icao TEXT NOT NULL,

View File

@@ -1,4 +1,4 @@
CREATE TABLE "metars" (
CREATE TABLE IF NOT EXISTS metars (
id SERIAL PRIMARY KEY,
icao TEXT NOT NULL,
raw_text TEXT NOT NULL,

View File

@@ -13,8 +13,11 @@ diesel_migrations::embed_migrations!();
lazy_static! {
static ref POOL: Pool = {
let db_url = env::var("DATABASE_URL").expect("Database url not set");
let manager = ConnectionManager::<PgConnection>::new(db_url);
let username = env::var("DATABASE_USER").expect("Database username is not set");
let password = env::var("DATABASE_PASSWORD").expect("Database password is not set");
let name = env::var("DATABASE_NAME").expect("Database name is not set");
let url = format!("postgres://{}:{}@localhost:5433/{}", username, password, name);
let manager = ConnectionManager::<PgConnection>::new(url);
Pool::new(manager).expect("Failed to create db pool")
};
}

View File

View File

@@ -16,19 +16,11 @@ build: ## Install the dependencies and build
npm run build
start: ## Start the dev instance
npm install
npm run dev
up:
docker compose up -d
down:
docker compose down
connect:
docker exec -it aviation_weather_db psql -U postgres
lint: ## Run the linter
npm run lint
clean: ## Remove node modules
rm -rf data node_modules backend/target
rm -rf node_modules

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB