Compare commits
6 Commits
main
...
7ba9cd2c73
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ba9cd2c73 | |||
| bec8abfe47 | |||
| 7fcae49700 | |||
| b561c92f07 | |||
| 38cac0b257 | |||
| 5b08ca0dd2 |
@ -41,22 +41,7 @@ jobs:
|
||||
run: cargo build --release --locked
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
container: git.molloy.xyz/fergus-molloy/ubuntu:rust-nextest
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:17-alpine
|
||||
ports:
|
||||
- "5432:5432"
|
||||
env:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DATABASE: nuchat_test
|
||||
options: >-
|
||||
--health-cmd pg_isready
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
runs-on: rust-nextest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./backend
|
||||
@ -74,10 +59,6 @@ jobs:
|
||||
run: cargo build --locked --bin nuchat
|
||||
- name: Run Tests
|
||||
run: ./scripts/test.sh
|
||||
env:
|
||||
POSTGRES_URL: "postgresql://postgres:postgres@postgres:5432"
|
||||
DATABASE_URL: "postgresql://postgres:postgres@postgres:5432"
|
||||
SKIP_DOCKER: "1"
|
||||
- name: Upload Test Logs
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
|
||||
@ -1,72 +0,0 @@
|
||||
name: Frontend Actions
|
||||
run-name: ${{ gitea.actor }} is running frontend actions
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./ui
|
||||
steps:
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '24'
|
||||
- uses: actions/checkout@v4
|
||||
- name: Load Cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
ui/node_modules
|
||||
key: ${{ runner.os }}-node-check-${{ hashFiles('ui/package-lock.json') }}
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
- name: Run Eslint
|
||||
run: npm run lint
|
||||
- name: Run Prettier
|
||||
run: npm run fmt -- . --check
|
||||
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./ui
|
||||
steps:
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '24'
|
||||
- uses: actions/checkout@v4
|
||||
- name: Load Cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
ui/node_modules
|
||||
key: ${{ runner.os }}-node-build-${{ hashFiles('ui/package-lock.json') }}
|
||||
- run: node --version
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
- name: Build UI
|
||||
run: npm run build
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./ui
|
||||
steps:
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '24'
|
||||
- uses: actions/checkout@v4
|
||||
- name: Load Cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
ui/node_modules
|
||||
key: ${{ runner.os }}-node-test-${{ hashFiles('ui/package-lock.json') }}
|
||||
- run: node --version
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
- name: Run tests
|
||||
run: npm run test
|
||||
55
.gitea/workflows/release.yaml
Normal file
55
.gitea/workflows/release.yaml
Normal file
@ -0,0 +1,55 @@
|
||||
name: Backend Actions
|
||||
run-name: ${{ gitea.actor }} is running backend actions
|
||||
on: [push]
|
||||
# push:
|
||||
# tags:
|
||||
# - 'v[0-9]+\.[0-9]+\.[0-9]+'
|
||||
|
||||
jobs:
|
||||
package:
|
||||
runs-on: rust-latest
|
||||
steps:
|
||||
- run: echo ${{ github.ref }}
|
||||
- uses: actions/checkout@v4
|
||||
- name: Create Output Directory
|
||||
run: mkdir package
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '24'
|
||||
- name: Load Cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
backend/target
|
||||
ui/node_modules
|
||||
key: ${{ runner.os }}-package-${{ hashFiles('backend/Cargo.lock') }}-${{ hashFiles('ui/package-lock.json') }}
|
||||
|
||||
- name: Install UI Dependencies
|
||||
working-directory: ui
|
||||
run: npm ci
|
||||
- name: Build UI
|
||||
working-directory: ui
|
||||
run: npm run build
|
||||
- name: Copy Output
|
||||
run: cp -rv ui/.output package/ui
|
||||
|
||||
|
||||
- name: Build Backend
|
||||
working-directory: backend
|
||||
run: cargo build --release --locked
|
||||
- name: Copy Binary
|
||||
run: cp -v backend/target/release/nuchat package/
|
||||
|
||||
- name: Package Output
|
||||
run: tar -cf - package | zstd -19 -T0 -o package.tar.zst
|
||||
|
||||
- name: Upload Package
|
||||
run: |-
|
||||
curl -X PUT \
|
||||
-H 'Authorization: token ${{ secrets.PACKAGE_API_KEY }}' \
|
||||
--upload-file package.tar.zst \
|
||||
'https://git.molloy.xyz/api/packages/fergus-molloy/generic/nuchat/0.0.2/nuchat.tar.zst'
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
.env
|
||||
package/
|
||||
*.tar.zst
|
||||
package.tar.zst
|
||||
|
||||
@ -1,23 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO messages (id, contents, created_at) VALUES($1, $2, current_timestamp) RETURNING id",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Uuid"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "060e058f46bf96f6505fb8a1d1b305c062c5c8a7ada56b34d6c9c229de3b9b34"
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT id, contents, created_at FROM messages",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "contents",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "created_at",
|
||||
"type_info": "Timestamptz"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": []
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "5af6cb153161fced4a308b34b5c303f6907a9e06021bbeca31d41de236514589"
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "select exists(SELECT datname FROM pg_catalog.pg_database WHERE datname = $1);",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "exists",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Name"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "6060467ee8046709f486ab35233e43eb849de082aa86c4d877b0c0818e27c104"
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT id, name, created_at FROM servers WHERE id = $1",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "name",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "created_at",
|
||||
"type_info": "Timestamptz"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "66b1dcdcbc9eae32237b1f712c32498003efb42d843b5bb7d33668d5cc3199a7"
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT id, contents, created_at FROM messages WHERE id = $1",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "contents",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "created_at",
|
||||
"type_info": "Timestamptz"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "a86c7ef23b4f356ffccb0be2af40e6fbbde85dd57fd2a37b6654279c55d441e3"
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT id, name, created_at FROM servers",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "name",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "created_at",
|
||||
"type_info": "Timestamptz"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": []
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "cc8f315cf11481ed3ef0cf8f08c54fe508833afc74b18b4b47a7b7ee217a2439"
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO servers (id, name, created_at) VALUES($1, $2, current_timestamp) RETURNING id",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Uuid"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "d6d5a09a7a6849b4610269cdc1a121caedd1b8853f7de70b02a8ed5a9c5615aa"
|
||||
}
|
||||
1012
backend/Cargo.lock
generated
1012
backend/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -4,18 +4,14 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
axum = { version = "0.8.4", features = [] }
|
||||
chrono = { version = "0.4.41", features = ["serde"] }
|
||||
axum = "0.8.4"
|
||||
clap = { version = "4.5.41", features = ["derive"] }
|
||||
futures = "0.3.31"
|
||||
http = "1.3.1"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0.141"
|
||||
sqlx = { version = "0.8.6", features = ["postgres", "macros", "runtime-tokio", "uuid", "chrono"] }
|
||||
tap = "1.0.1"
|
||||
tokio = { version = "1.0", features = ["full"] }
|
||||
tower = { version = "0.5.2", features = ["full"] }
|
||||
tower-http = { version = "0.6.6", features = ["timeout", "trace", "auth", "request-id"] }
|
||||
tower-http = { version = "0.6.6", features = ["timeout", "trace", "auth"] }
|
||||
tower-http-util = "0.1.0"
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
@ -35,9 +31,3 @@ name ="nuchat"
|
||||
default = [ "shutdown" ]
|
||||
all = ["shutdown"]
|
||||
shutdown = []
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1
|
||||
lto = "fat"
|
||||
panic = "abort"
|
||||
strip = "symbols"
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
-- Add migration script here
|
||||
CREATE TABLE servers (
|
||||
id uuid NOT NULL,
|
||||
PRIMARY KEY(id),
|
||||
name TEXT NOT NULL,
|
||||
created_at timestamptz NOT NULL
|
||||
)
|
||||
@ -1,7 +0,0 @@
|
||||
-- Add migration script here
|
||||
CREATE TABLE messages (
|
||||
id uuid NOT NULL,
|
||||
PRIMARY KEY(id),
|
||||
contents TEXT NOT NULL,
|
||||
created_at timestamptz NOT NULL
|
||||
)
|
||||
@ -1,34 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
POSTGRES_URL=${POSTGRES_URL:-"postgresql://postgres:postgres@localhost:5432"}
|
||||
|
||||
if ! command -v cargo-nextest > /dev/null 2>&1; then
|
||||
echo "Command not found cargo-nextest"
|
||||
echo "Try installing with cargo install cargo-nextest"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v sqlx > /dev/null 2>&1; then
|
||||
echo "Command not found sqlx"
|
||||
echo "Try installing with cargo install sqlx-cli"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export DATABASE_URL="$POSTGRES_URL/nuchat_dev"
|
||||
|
||||
if [ -z "$SKIP_DOCKER" ]; then
|
||||
# force restart database so no connections
|
||||
# prevent database from being dropped
|
||||
docker compose -f ../docker-compose.yml down
|
||||
docker compose -f ../docker-compose.yml up -d db
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
# recreate database and tables
|
||||
sqlx database drop -y
|
||||
sqlx database create
|
||||
sqlx migrate run
|
||||
|
||||
if [ ! -d logs ]; then
|
||||
mkdir logs
|
||||
fi
|
||||
@ -37,8 +14,7 @@ fi
|
||||
curl -s -X POST localhost:7001/admin/shutdown 2>&1 > /dev/null
|
||||
|
||||
# start server
|
||||
cargo run -- --port 7001 --postgres-url "$POSTGRES_URL" --database "nuchat_dev" 2>&1 > logs/nuchat.log &
|
||||
cargo run -- --port 7001 2>&1 > logs/nuchat.log &
|
||||
|
||||
sleep 1
|
||||
# run tests
|
||||
cargo nextest run --color=always --no-fail-fast 2>&1 | tee logs/test-output.log
|
||||
cargo nextest run --color=always 2>&1 | tee logs/test-output.log
|
||||
|
||||
@ -3,6 +3,4 @@ pub struct Config {
|
||||
pub port: u32,
|
||||
pub host: String,
|
||||
pub admin_secret: Option<String>,
|
||||
pub postgres_url: String,
|
||||
pub database_name: String,
|
||||
}
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
mod config;
|
||||
mod router;
|
||||
mod state;
|
||||
|
||||
pub use config::Config;
|
||||
pub use router::app;
|
||||
pub use state::{AppState, NuState};
|
||||
|
||||
@ -1,12 +1,8 @@
|
||||
use std::sync::mpsc;
|
||||
|
||||
use clap::Parser;
|
||||
use nuchat::AppState;
|
||||
use nuchat::Config;
|
||||
use nuchat::NuState;
|
||||
use nuchat::app;
|
||||
use sqlx::Pool;
|
||||
use sqlx::Postgres;
|
||||
use tokio::net::TcpListener;
|
||||
use tokio::signal;
|
||||
use tracing::info;
|
||||
@ -26,14 +22,6 @@ struct Args {
|
||||
/// Admin secret to use, leave blank to disable
|
||||
#[arg(long)]
|
||||
admin_secret: Option<String>,
|
||||
|
||||
/// postgres base url, should container users and host info
|
||||
#[arg(long, default_value = "postgres://postgres:postgres@localhost:5432")]
|
||||
postgres_url: String,
|
||||
|
||||
/// name of database to use
|
||||
#[arg(long, default_value = "nuchat_dev")]
|
||||
database: String,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
@ -49,26 +37,16 @@ async fn main() {
|
||||
.with(tracing_subscriber::fmt::layer().with_target(false))
|
||||
.init();
|
||||
|
||||
let database_url = format!("{}/{}", config.0.postgres_url, config.0.database_name);
|
||||
info!("Connecting to database: {database_url}");
|
||||
let pool = Pool::<Postgres>::connect(&database_url)
|
||||
.await
|
||||
.expect("Could not connect to database");
|
||||
|
||||
let listener = TcpListener::bind(format!("{}:{}", config.0.host, config.0.port))
|
||||
.await
|
||||
.unwrap();
|
||||
tracing::debug!("listening on {}", listener.local_addr().unwrap());
|
||||
|
||||
let state = AppState::new(NuState::new(pool.clone(), config.0));
|
||||
let (app, rx) = app(&state);
|
||||
axum::serve(listener, app.with_state(state))
|
||||
let (app, rx) = app(&config.0);
|
||||
axum::serve(listener, app)
|
||||
.with_graceful_shutdown(shutdown_signal(rx))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
pool.close().await;
|
||||
|
||||
info!("Server stopped");
|
||||
}
|
||||
|
||||
@ -113,8 +91,6 @@ impl BinConfig {
|
||||
port: args.port,
|
||||
host: args.host,
|
||||
admin_secret: args.admin_secret,
|
||||
postgres_url: args.postgres_url,
|
||||
database_name: args.database,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,64 +1,33 @@
|
||||
mod admin;
|
||||
mod healthcheck;
|
||||
mod messages;
|
||||
mod servers;
|
||||
use std::sync::mpsc;
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::AppState;
|
||||
use crate::config;
|
||||
use axum::extract::Request;
|
||||
use axum::routing::get;
|
||||
use axum::{Router, body::Body};
|
||||
use http::{HeaderName, HeaderValue};
|
||||
use tower::ServiceBuilder;
|
||||
use tower_http::request_id::{MakeRequestId, RequestId, SetRequestIdLayer};
|
||||
use tower_http::timeout::TimeoutLayer;
|
||||
use tower_http::trace::TraceLayer;
|
||||
use tracing::Level;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct RequestIdLayer;
|
||||
|
||||
impl MakeRequestId for RequestIdLayer {
|
||||
fn make_request_id<B>(&mut self, _: &http::Request<B>) -> Option<RequestId> {
|
||||
let id = Uuid::now_v7().to_string();
|
||||
|
||||
Some(RequestId::new(id.parse().unwrap()))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn app(state: &AppState) -> (Router<AppState>, mpsc::Receiver<bool>) {
|
||||
pub fn app(config: &config::Config) -> (Router, mpsc::Receiver<bool>) {
|
||||
let (tx, rx) = mpsc::channel();
|
||||
(
|
||||
Router::new()
|
||||
.with_state(state.clone())
|
||||
.route("/healthcheck", get(healthcheck::healthcheck))
|
||||
.route(
|
||||
"/servers",
|
||||
get(servers::get_servers).post(servers::create_server),
|
||||
)
|
||||
.route("/servers/{id}", get(servers::get_server_by_id))
|
||||
.route(
|
||||
"/messages",
|
||||
get(messages::get_messages).post(messages::create_message),
|
||||
)
|
||||
.route("/messages/{id}", get(messages::get_message_by_id))
|
||||
.nest("/admin", admin::router(tx, state))
|
||||
.route("/forever", get(std::future::pending::<()>))
|
||||
.nest("/admin", admin::router(tx, config))
|
||||
.layer(
|
||||
ServiceBuilder::new()
|
||||
.layer(SetRequestIdLayer::new(
|
||||
HeaderName::from_static("x-request-id"),
|
||||
RequestIdLayer,
|
||||
))
|
||||
.layer(
|
||||
TraceLayer::new_for_http().make_span_with(|req: &Request<Body>| {
|
||||
let default = HeaderValue::from_static("<missing>");
|
||||
let req_id = req.headers().get("x-request-id").unwrap_or(&default);
|
||||
tracing::span!(
|
||||
Level::DEBUG,
|
||||
"request",
|
||||
req_id = req_id.to_str().unwrap(),
|
||||
trace_id = Uuid::now_v7().to_string(),
|
||||
method = format!("{}", req.method()),
|
||||
uri = format!("{}", req.uri()),
|
||||
)
|
||||
|
||||
@ -7,17 +7,13 @@ use http::StatusCode;
|
||||
use tower_http::validate_request::ValidateRequestHeaderLayer;
|
||||
use tracing::{info, warn};
|
||||
|
||||
use crate::AppState;
|
||||
|
||||
pub fn router(tx: mpsc::Sender<bool>, state: &AppState) -> Router<AppState> {
|
||||
let r = Router::new()
|
||||
.with_state(state.clone())
|
||||
.route("/", get(async || StatusCode::OK));
|
||||
pub fn router(tx: mpsc::Sender<bool>, config: &crate::Config) -> Router {
|
||||
let r = Router::new().route("/", get(async || StatusCode::OK));
|
||||
|
||||
let r = add_shutdown_endpoint(r, tx);
|
||||
if let Some(secret) = &state.config.admin_secret {
|
||||
if let Some(secret) = config.admin_secret.clone() {
|
||||
info!("Enabled admin authorization");
|
||||
r.layer(ValidateRequestHeaderLayer::bearer(secret))
|
||||
r.layer(ValidateRequestHeaderLayer::bearer(&secret))
|
||||
} else {
|
||||
warn!("Admin authorization disabled");
|
||||
r
|
||||
@ -25,7 +21,7 @@ pub fn router(tx: mpsc::Sender<bool>, state: &AppState) -> Router<AppState> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "shutdown")]
|
||||
fn add_shutdown_endpoint(r: Router<AppState>, tx: mpsc::Sender<bool>) -> Router<AppState> {
|
||||
fn add_shutdown_endpoint(r: Router, tx: mpsc::Sender<bool>) -> Router {
|
||||
r.route(
|
||||
"/shutdown",
|
||||
post(async move || {
|
||||
@ -48,21 +44,17 @@ fn add_shutdown_endpoint(r: Router, _: mpsc::Sender<bool>) -> Router {
|
||||
mod test {
|
||||
use axum::{body::Body, http::Request};
|
||||
use http::header;
|
||||
use sqlx::PgPool;
|
||||
use tower::ServiceExt;
|
||||
|
||||
use crate::{config, state::NuState};
|
||||
use crate::config;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[sqlx::test]
|
||||
async fn test_authorization_disables_when_no_secret_set(pool: PgPool) {
|
||||
#[tokio::test]
|
||||
async fn test_authorization_disables_when_no_secret_set() {
|
||||
let (tx, _) = mpsc::channel();
|
||||
|
||||
let state = AppState::new(NuState::new(pool, config::Config::default()));
|
||||
|
||||
let resp = router(tx, &state)
|
||||
.with_state(state)
|
||||
let resp = router(tx, &config::Config::default())
|
||||
.oneshot(Request::builder().uri("/").body(Body::empty()).unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
@ -70,8 +62,8 @@ mod test {
|
||||
assert_eq!(resp.status(), StatusCode::OK);
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
async fn test_authorization_unauthorized_no_bearer_token(pool: PgPool) {
|
||||
#[tokio::test]
|
||||
async fn test_authorization_unauthorized_no_bearer_token() {
|
||||
let (tx, _) = mpsc::channel();
|
||||
|
||||
let conf = config::Config {
|
||||
@ -79,10 +71,7 @@ mod test {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let state = AppState::new(NuState::new(pool, conf));
|
||||
|
||||
let resp = router(tx, &state)
|
||||
.with_state(state)
|
||||
let resp = router(tx, &conf)
|
||||
.oneshot(Request::builder().uri("/").body(Body::empty()).unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
@ -90,8 +79,8 @@ mod test {
|
||||
assert_eq!(resp.status(), StatusCode::UNAUTHORIZED);
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
async fn test_authorization_unauthorized_invalid_bearer_token(pool: PgPool) {
|
||||
#[tokio::test]
|
||||
async fn test_authorization_unauthorized_invalid_bearer_token() {
|
||||
let (tx, _) = mpsc::channel();
|
||||
|
||||
let conf = config::Config {
|
||||
@ -99,10 +88,7 @@ mod test {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let state = AppState::new(NuState::new(pool, conf));
|
||||
|
||||
let resp = router(tx, &state)
|
||||
.with_state(state)
|
||||
let resp = router(tx, &conf)
|
||||
.oneshot(
|
||||
Request::builder()
|
||||
.uri("/")
|
||||
@ -116,8 +102,8 @@ mod test {
|
||||
assert_eq!(resp.status(), StatusCode::UNAUTHORIZED);
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
async fn test_authorization_authorized_valid_bearer_token(pool: PgPool) {
|
||||
#[tokio::test]
|
||||
async fn test_authorization_authorized_valid_bearer_token() {
|
||||
let (tx, _) = mpsc::channel();
|
||||
|
||||
let conf = config::Config {
|
||||
@ -125,10 +111,7 @@ mod test {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let state = AppState::new(NuState::new(pool, conf));
|
||||
|
||||
let resp = router(tx, &state)
|
||||
.with_state(state)
|
||||
let resp = router(tx, &conf)
|
||||
.oneshot(
|
||||
Request::builder()
|
||||
.uri("/")
|
||||
|
||||
@ -1,78 +1,6 @@
|
||||
use axum::extract::{self, State};
|
||||
use axum::response::Json;
|
||||
use http::StatusCode;
|
||||
use serde_json::{Value, json};
|
||||
use tracing::error;
|
||||
|
||||
use crate::AppState;
|
||||
|
||||
pub async fn healthcheck(State(s): extract::State<AppState>) -> Result<Json<Value>, StatusCode> {
|
||||
sqlx::query!(
|
||||
"select exists(SELECT datname FROM pg_catalog.pg_database WHERE datname = $1);",
|
||||
s.config.database_name
|
||||
)
|
||||
.fetch_one(&s.db)
|
||||
.await
|
||||
.and_then(|x| x.exists.ok_or(sqlx::Error::RowNotFound))
|
||||
.and_then(|db| {
|
||||
if db {
|
||||
Ok(Json(json!({"healthy": db})))
|
||||
} else {
|
||||
error!("Could not find configured database in postgres");
|
||||
Err(sqlx::Error::RowNotFound)
|
||||
}
|
||||
})
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use axum::{Router, body::Body, routing::get};
|
||||
use http::Request;
|
||||
use sqlx::PgPool;
|
||||
use tower::ServiceExt;
|
||||
|
||||
use crate::{Config, NuState};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[sqlx::test]
|
||||
async fn healthcheck_passes_with_db_connection(pool: PgPool) {
|
||||
let state = AppState::new(NuState::new(
|
||||
pool,
|
||||
Config {
|
||||
database_name: String::from("nuchat_dev"),
|
||||
..Config::default()
|
||||
},
|
||||
));
|
||||
|
||||
let resp = Router::new()
|
||||
.route("/", get(healthcheck))
|
||||
.with_state(state)
|
||||
.oneshot(Request::builder().uri("/").body(Body::empty()).unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(resp.status(), StatusCode::OK);
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
async fn healthcheck_fails_db_doesnt_exist(pool: PgPool) {
|
||||
let state = AppState::new(NuState::new(
|
||||
pool,
|
||||
Config {
|
||||
database_name: String::from("asdfasdfasdf"),
|
||||
..Config::default()
|
||||
},
|
||||
));
|
||||
|
||||
let resp = Router::new()
|
||||
.route("/", get(healthcheck))
|
||||
.with_state(state)
|
||||
.oneshot(Request::builder().uri("/").body(Body::empty()).unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(resp.status(), StatusCode::INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
pub async fn healthcheck() -> Json<Value> {
|
||||
Json(json!({"healthy": true}))
|
||||
}
|
||||
|
||||
@ -1,68 +0,0 @@
|
||||
use axum::{
|
||||
Form, Json,
|
||||
body::Body,
|
||||
extract::{Path, State},
|
||||
response::{IntoResponse, Response},
|
||||
};
|
||||
use http::StatusCode;
|
||||
use sqlx::types::chrono;
|
||||
use tracing::info;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::AppState;
|
||||
|
||||
#[derive(serde::Deserialize, serde::Serialize, Debug)]
|
||||
pub struct Message {
|
||||
pub contents: String,
|
||||
pub id: Uuid,
|
||||
pub created_at: chrono::DateTime<chrono::Utc>,
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct CreateMessage {
|
||||
pub contents: String,
|
||||
}
|
||||
|
||||
pub async fn get_messages(State(s): State<AppState>) -> Result<Json<Vec<Message>>, StatusCode> {
|
||||
sqlx::query_as!(Message, r#"SELECT id, contents, created_at FROM messages"#)
|
||||
.fetch_all(&s.db)
|
||||
.await
|
||||
.map(Json)
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
|
||||
}
|
||||
|
||||
pub async fn create_message(
|
||||
State(s): State<AppState>,
|
||||
Form(message): Form<CreateMessage>,
|
||||
) -> Result<Response<Body>, StatusCode> {
|
||||
info!("Creating new message with name: {}", message.contents);
|
||||
let id = Uuid::now_v7();
|
||||
|
||||
sqlx::query!(
|
||||
r"INSERT INTO messages (id, contents, created_at) VALUES($1, $2, current_timestamp) RETURNING id",
|
||||
id,
|
||||
message.contents
|
||||
).fetch_one(&s.db).await
|
||||
.map(|row| {
|
||||
let mut resp = Json(row.id).into_response();
|
||||
let status = resp.status_mut();
|
||||
*status = StatusCode::CREATED;
|
||||
info!("Successfully created message Message[{}, {}]", row.id, message.contents);
|
||||
resp
|
||||
}).map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
|
||||
}
|
||||
|
||||
pub async fn get_message_by_id(
|
||||
Path(id): Path<Uuid>,
|
||||
State(s): State<AppState>,
|
||||
) -> Result<Json<Message>, StatusCode> {
|
||||
sqlx::query_as!(
|
||||
Message,
|
||||
r#"SELECT id, contents, created_at FROM messages WHERE id = $1"#,
|
||||
id
|
||||
)
|
||||
.fetch_optional(&s.db)
|
||||
.await
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
|
||||
.and_then(|mayber_message| mayber_message.map(Json).ok_or(StatusCode::NOT_FOUND))
|
||||
}
|
||||
@ -1,68 +0,0 @@
|
||||
use axum::{
|
||||
Form, Json,
|
||||
body::Body,
|
||||
extract::{Path, State},
|
||||
response::{IntoResponse, Response},
|
||||
};
|
||||
use http::StatusCode;
|
||||
use sqlx::types::chrono;
|
||||
use tracing::info;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::AppState;
|
||||
|
||||
#[derive(serde::Deserialize, serde::Serialize, Debug)]
|
||||
pub struct Server {
|
||||
pub name: String,
|
||||
pub id: Uuid,
|
||||
pub created_at: chrono::DateTime<chrono::Utc>,
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct CreateServer {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
pub async fn get_servers(State(s): State<AppState>) -> Result<Json<Vec<Server>>, StatusCode> {
|
||||
sqlx::query_as!(Server, r#"SELECT id, name, created_at FROM servers"#)
|
||||
.fetch_all(&s.db)
|
||||
.await
|
||||
.map(Json)
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
|
||||
}
|
||||
|
||||
pub async fn create_server(
|
||||
State(s): State<AppState>,
|
||||
Form(server): Form<CreateServer>,
|
||||
) -> Result<Response<Body>, StatusCode> {
|
||||
info!("Creating new server with name: {}", server.name);
|
||||
let id = Uuid::now_v7();
|
||||
|
||||
sqlx::query!(
|
||||
r"INSERT INTO servers (id, name, created_at) VALUES($1, $2, current_timestamp) RETURNING id",
|
||||
id,
|
||||
server.name
|
||||
).fetch_one(&s.db).await
|
||||
.map(|row| {
|
||||
let mut resp = Json(row.id).into_response();
|
||||
let status = resp.status_mut();
|
||||
*status = StatusCode::CREATED;
|
||||
info!("Successfully created server Server[{}, {}]", row.id, server.name);
|
||||
resp
|
||||
}).map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
|
||||
}
|
||||
|
||||
pub async fn get_server_by_id(
|
||||
Path(id): Path<Uuid>,
|
||||
State(s): State<AppState>,
|
||||
) -> Result<Json<Server>, StatusCode> {
|
||||
sqlx::query_as!(
|
||||
Server,
|
||||
r#"SELECT id, name, created_at FROM servers WHERE id = $1"#,
|
||||
id
|
||||
)
|
||||
.fetch_optional(&s.db)
|
||||
.await
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
|
||||
.and_then(|mayber_server| mayber_server.map(Json).ok_or(StatusCode::NOT_FOUND))
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use sqlx::PgPool;
|
||||
|
||||
use crate::Config;
|
||||
|
||||
pub type AppState = Arc<NuState>;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct NuState {
|
||||
pub db: sqlx::PgPool,
|
||||
pub config: Config,
|
||||
}
|
||||
impl NuState {
|
||||
#[must_use]
|
||||
pub fn new(db: PgPool, config: Config) -> Self {
|
||||
Self { db, config }
|
||||
}
|
||||
}
|
||||
@ -6,20 +6,11 @@ services:
|
||||
command: --host 0.0.0.0
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
frontend:
|
||||
build: ./ui
|
||||
ports:
|
||||
- "3000:3000"
|
||||
command: --host 0.0.0.0
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
db:
|
||||
image: postgres:17-alpine
|
||||
environment:
|
||||
POSTGRES_USER: $POSTGRES_USER
|
||||
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
|
||||
POSTGRES_DB: nuchat_dev
|
||||
POSTGRES_DB: nuchat
|
||||
ports:
|
||||
- "5432:5432"
|
||||
|
||||
16
package.sh
Executable file
16
package.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
mkdir package
|
||||
|
||||
pushd backend
|
||||
cargo build --release
|
||||
cp -v target/release/nuchat ../package/
|
||||
popd
|
||||
|
||||
pushd ui
|
||||
pnpm run build
|
||||
cp -rv .output ../package/ui
|
||||
popd
|
||||
|
||||
tar -cf - package/ | zstd -19 -T0 -o package.tar.zst
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function check_tags() {
|
||||
TAGS="$(git tag --points-at HEAD)"
|
||||
if [ -n "$TAGS" ]; then
|
||||
TAG=$(echo "$TAGS" | grep -E '^v[0-9]+.[0-9]+.[0-9]+$' | sort -V | tail -1)
|
||||
else
|
||||
echo "No release tag found"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function package() {
|
||||
PACKAGE_DIR="${PACKAGE_DIR:-package}"
|
||||
mkdir "$PACKAGE_DIR" > /dev/null 2>&1
|
||||
|
||||
pushd backend
|
||||
cargo build --release
|
||||
cp -v target/release/nuchat ../package/
|
||||
popd
|
||||
|
||||
pushd ui
|
||||
npm ci
|
||||
npm run build
|
||||
cp -rv .output ../package/ui
|
||||
popd
|
||||
|
||||
|
||||
OUT_FILE="${OUT_FILE:-package.tar.zst}"
|
||||
if [ -f "$OUT_FILE" ]; then
|
||||
rm "$OUT_FILE" > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
tar -cf - package/ | zstd -19 -T0 -o "${OUT_DIR}${OUT_FILE}"
|
||||
}
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
. ./scripts/environ.sh
|
||||
|
||||
check_tags
|
||||
if [ -n "$TAG" ]; then
|
||||
echo "Found tag $TAG"
|
||||
RELEASE_VERSION=$(echo "$TAG" | sed 's/v//')
|
||||
echo "Releasing $RELEASE_VERSION"
|
||||
echo ""
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
package
|
||||
|
||||
if [ ! -f package.tar.zst ]; then
|
||||
echo "failed to generate package"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
curl -s -X PUT \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
--upload-file "$OUT_DIR$OUT_FILE" \
|
||||
"https://git.molloy.xyz/api/packages/fergus-molloy/generic/nuchat/$RELEASE_VERSION/nuchat.tar.zst"
|
||||
@ -1,24 +0,0 @@
|
||||
# Nuxt dev/build outputs
|
||||
.output
|
||||
.data
|
||||
.nuxt
|
||||
.nitro
|
||||
.cache
|
||||
dist
|
||||
|
||||
# Node dependencies
|
||||
node_modules
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
# Misc
|
||||
.DS_Store
|
||||
.fleet
|
||||
.idea
|
||||
|
||||
# Local env files
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
@ -1,15 +0,0 @@
|
||||
FROM node:24-alpine AS base
|
||||
|
||||
FROM base AS build
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
FROM base AS prod
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/.output ./ui
|
||||
ENV PORT=3000
|
||||
|
||||
ENTRYPOINT [ "node", "/app/ui/server/index.mjs" ]
|
||||
@ -1,8 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<NuxtRouteAnnouncer />
|
||||
<NuxtLayout>
|
||||
<NuxtPage />
|
||||
</NuxtLayout>
|
||||
<NuxtWelcome />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -1 +0,0 @@
|
||||
@import "tailwindcss";
|
||||
@ -1,7 +0,0 @@
|
||||
<template>
|
||||
<div class="bg-sky-900 text-white p-4 mt-auto">
|
||||
<div class="text-center text-sm opacity-75">
|
||||
© 2025 NuChat. All rights reserved.
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -1,5 +0,0 @@
|
||||
<template>
|
||||
<div class="text-2xl bold bg-sky-900 text-white p-2">
|
||||
<NuxtLink to="/">NuChat</NuxtLink>
|
||||
</div>
|
||||
</template>
|
||||
@ -1,14 +0,0 @@
|
||||
<template>
|
||||
<RouterLink
|
||||
:to="`/servers/${id}`"
|
||||
class="block p-3 hover:bg-sky-100 rounded-lg transition-colors duration-200 border border-transparent hover:border-sky-300"
|
||||
>
|
||||
<slot />
|
||||
</RouterLink>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
defineProps<{
|
||||
id: string | number;
|
||||
}>();
|
||||
</script>
|
||||
@ -1,38 +0,0 @@
|
||||
<template>
|
||||
<div class="h-full border-2 border-sky-300 flex flex-col p-4 bg-gray-50">
|
||||
<h2 class="text-lg font-semibold text-gray-800 mb-4">Servers</h2>
|
||||
<div class="space-y-2">
|
||||
<ServerLink
|
||||
v-for="server in serversWithFallback"
|
||||
:id="server.id"
|
||||
:key="server.id"
|
||||
class="text-gray-700 hover:text-sky-800"
|
||||
>
|
||||
{{ server.name }}
|
||||
</ServerLink>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
interface Server {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
const { data: servers, error } = await useFetch<Server[]>("/api/servers");
|
||||
|
||||
if (error.value) {
|
||||
console.error("Failed to fetch servers:", error.value);
|
||||
}
|
||||
|
||||
const serversWithFallback = computed(() => {
|
||||
return (
|
||||
servers.value || [
|
||||
{ id: "1", name: "General" },
|
||||
{ id: "2", name: "Gaming" },
|
||||
{ id: "3", name: "Tech Talk" },
|
||||
]
|
||||
);
|
||||
});
|
||||
</script>
|
||||
@ -1,12 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<AppHeader />
|
||||
<div class="grid grid-cols-12">
|
||||
<ServerSidebar class="col-span-2" />
|
||||
<div class="col-span-10">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
<AppFooter />
|
||||
</div>
|
||||
</template>
|
||||
@ -1,14 +0,0 @@
|
||||
// @noErrors
|
||||
import { it, expect } from "vitest";
|
||||
// ---cut---
|
||||
// tests/components/SomeComponents.nuxt.spec.ts
|
||||
import { mountSuspended } from "@nuxt/test-utils/runtime";
|
||||
import Index from "~/pages/index.vue";
|
||||
|
||||
// tests/App.nuxt.spec.ts
|
||||
it("can also mount an app", async () => {
|
||||
const component = await mountSuspended(Index, { route: "/test" });
|
||||
expect(component.html()).toMatchInlineSnapshot(`
|
||||
"<h1>Hello World</h1>"
|
||||
`);
|
||||
});
|
||||
@ -1,3 +0,0 @@
|
||||
<template>
|
||||
<h1>Hello World</h1>
|
||||
</template>
|
||||
@ -1,9 +1,6 @@
|
||||
// @ts-check
|
||||
import withNuxt from "./.nuxt/eslint.config.mjs";
|
||||
import withNuxt from './.nuxt/eslint.config.mjs'
|
||||
|
||||
export default withNuxt({
|
||||
rules: {
|
||||
"prefer-const": "warn",
|
||||
"no-unexpected-multiline": 0,
|
||||
},
|
||||
});
|
||||
export default withNuxt(
|
||||
// Your custom configs here
|
||||
)
|
||||
|
||||
@ -1,20 +1,6 @@
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
|
||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||
export default defineNuxtConfig({
|
||||
compatibilityDate: "2025-07-15",
|
||||
compatibilityDate: '2025-07-15',
|
||||
devtools: { enabled: true },
|
||||
modules: [
|
||||
"@nuxt/eslint",
|
||||
"@nuxt/icon",
|
||||
"@nuxt/test-utils",
|
||||
"@nuxt/test-utils/module",
|
||||
],
|
||||
css: ["~/assets/css/main.css"],
|
||||
vite: {
|
||||
plugins: [tailwindcss()],
|
||||
},
|
||||
nitro: {
|
||||
preset: "node-server",
|
||||
},
|
||||
});
|
||||
modules: ['@nuxt/eslint', '@nuxt/icon', '@nuxt/test-utils']
|
||||
})
|
||||
|
||||
1340
ui/package-lock.json
generated
1340
ui/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -7,33 +7,14 @@
|
||||
"dev": "nuxt dev",
|
||||
"generate": "nuxt generate",
|
||||
"preview": "nuxt preview",
|
||||
"postinstall": "nuxt prepare",
|
||||
"test": "vitest run",
|
||||
"watch": "vitest watch",
|
||||
"lint": "eslint",
|
||||
"fmt": "prettier"
|
||||
"postinstall": "nuxt prepare"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nuxt/eslint": "1.6.0",
|
||||
"@nuxt/icon": "^1.15.0",
|
||||
"@tailwindcss/vite": "^4.1.11",
|
||||
"@nuxt/test-utils": "^3.19.2",
|
||||
"nuxt": "^4.0.1",
|
||||
"tailwindcss": "^4.1.11",
|
||||
"vue": "^3.5.17",
|
||||
"vue-router": "^4.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/css": "^0.10.0",
|
||||
"@eslint/js": "^9.32.0",
|
||||
"@nuxt/test-utils": "^3.19.2",
|
||||
"@vue/test-utils": "^2.4.6",
|
||||
"eslint": "^9.32.0",
|
||||
"eslint-plugin-vue": "^10.3.0",
|
||||
"globals": "^16.3.0",
|
||||
"happy-dom": "^18.0.1",
|
||||
"playwright-core": "^1.54.1",
|
||||
"prettier": "3.6.2",
|
||||
"typescript-eslint": "^8.38.0",
|
||||
"vitest": "^3.2.4"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
import { defineVitestConfig } from "@nuxt/test-utils/config";
|
||||
|
||||
export default defineVitestConfig({
|
||||
test: {
|
||||
environment: "nuxt",
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user