Initial commit: Clean workspace without heavy binaries
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
use jsonwebtoken::{encode, Header, EncodingKey};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
use chrono::{Utc, Duration};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Claims {
|
||||
pub sub: Uuid,
|
||||
pub exp: i64,
|
||||
pub role: String,
|
||||
}
|
||||
|
||||
pub fn create_jwt(user_id: Uuid, role: &str) -> Result<String, jsonwebtoken::errors::Error> {
|
||||
let expiration = Utc::now()
|
||||
.checked_add_signed(Duration::hours(24))
|
||||
.expect("valid timestamp")
|
||||
.timestamp();
|
||||
|
||||
let claims = Claims {
|
||||
sub: user_id,
|
||||
exp: expiration,
|
||||
role: role.to_string(),
|
||||
};
|
||||
|
||||
encode(&Header::default(), &claims, &EncodingKey::from_secret("secret".as_ref()))
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
pub mod models;
|
||||
pub mod auth;
|
||||
pub mod utils;
|
||||
@@ -0,0 +1,66 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
use chrono::{DateTime, Utc};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, sqlx::FromRow)]
|
||||
pub struct Course {
|
||||
pub id: Uuid,
|
||||
pub title: String,
|
||||
pub description: Option<String>,
|
||||
pub instructor_id: Uuid,
|
||||
pub start_date: Option<DateTime<Utc>>,
|
||||
pub end_date: Option<DateTime<Utc>>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, sqlx::FromRow)]
|
||||
pub struct Module {
|
||||
pub id: Uuid,
|
||||
pub course_id: Uuid,
|
||||
pub title: String,
|
||||
pub position: i32,
|
||||
pub created_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, sqlx::FromRow)]
|
||||
pub struct Lesson {
|
||||
pub id: Uuid,
|
||||
pub module_id: Uuid,
|
||||
pub title: String,
|
||||
pub content_type: String,
|
||||
pub content_url: Option<String>,
|
||||
pub transcription: Option<serde_json::Value>,
|
||||
pub metadata: Option<serde_json::Value>,
|
||||
pub position: i32,
|
||||
pub created_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, sqlx::FromRow)]
|
||||
pub struct AuditLog {
|
||||
pub id: Uuid,
|
||||
pub user_id: Uuid,
|
||||
pub action: String,
|
||||
pub entity_type: String,
|
||||
pub entity_id: Uuid,
|
||||
pub changes: serde_json::Value,
|
||||
pub created_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, sqlx::FromRow)]
|
||||
pub struct Enrollment {
|
||||
pub id: Uuid,
|
||||
pub user_id: Uuid,
|
||||
pub course_id: Uuid,
|
||||
pub enroled_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, sqlx::FromRow)]
|
||||
pub struct Asset {
|
||||
pub id: Uuid,
|
||||
pub filename: String,
|
||||
pub storage_path: String,
|
||||
pub mimetype: String,
|
||||
pub size_bytes: i64,
|
||||
pub created_at: DateTime<Utc>,
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Utility functions placeholder
|
||||
pub fn format_error() {
|
||||
// TODO: Implement error formatting
|
||||
}
|
||||
Reference in New Issue
Block a user