Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
6f5b9d4106 | |||
15a203acf2 | |||
1c461ddb9d | |||
2487a0f421 | |||
cb6b182042 | |||
3cd6b6e8b3 |
@ -136,7 +136,8 @@ async fn main() {
|
|||||||
TraceLayer::new_for_http()
|
TraceLayer::new_for_http()
|
||||||
.make_span_with(trace::DefaultMakeSpan::new().level(tracing::Level::INFO))
|
.make_span_with(trace::DefaultMakeSpan::new().level(tracing::Level::INFO))
|
||||||
.on_response(trace::DefaultOnResponse::new().level(tracing::Level::INFO)),
|
.on_response(trace::DefaultOnResponse::new().level(tracing::Level::INFO)),
|
||||||
);
|
)
|
||||||
|
.fallback(routes::root::RootRoute::not_found);
|
||||||
// .layer(cors);
|
// .layer(cors);
|
||||||
//.layer(GovernorLayer {
|
//.layer(GovernorLayer {
|
||||||
// config: governor_conf,
|
// config: governor_conf,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use super::posts::{deserialize_datetime, serialize_datetime};
|
use crate::{datasources::comments::CommentsDatasource, state::AppState, utils::datetime::*};
|
||||||
use crate::{datasources::comments::CommentsDatasource, state::AppState};
|
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::{Path, State},
|
extract::{Path, State},
|
||||||
http::StatusCode,
|
http::StatusCode,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use std::collections::HashMap;
|
use crate::{
|
||||||
use std::fmt;
|
datasources::posts::PostsDatasource,
|
||||||
|
state::AppState,
|
||||||
use crate::utils::rss;
|
utils::{datetime::*, rss},
|
||||||
use crate::{datasources::posts::PostsDatasource, state::AppState};
|
};
|
||||||
use axum::http::{HeaderMap, HeaderValue};
|
use axum::http::{HeaderMap, HeaderValue};
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::{Path, State},
|
extract::{Path, State},
|
||||||
@ -13,7 +13,8 @@ use axum::{
|
|||||||
};
|
};
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use fred::types::Expiration;
|
use fred::types::Expiration;
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(sqlx::FromRow, Deserialize, Serialize, Debug, Clone)]
|
#[derive(sqlx::FromRow, Deserialize, Serialize, Debug, Clone)]
|
||||||
pub struct Post {
|
pub struct Post {
|
||||||
@ -359,56 +360,3 @@ impl PostsRoute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn serialize_datetime<S>(
|
|
||||||
date: &Option<chrono::DateTime<Utc>>,
|
|
||||||
serializer: S,
|
|
||||||
) -> Result<S::Ok, S::Error>
|
|
||||||
where
|
|
||||||
S: Serializer,
|
|
||||||
{
|
|
||||||
serializer.serialize_str(&date.unwrap().to_rfc3339())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn deserialize_datetime<'de, D>(
|
|
||||||
deserializer: D,
|
|
||||||
) -> Result<Option<chrono::DateTime<Utc>>, D::Error>
|
|
||||||
where
|
|
||||||
D: Deserializer<'de>,
|
|
||||||
{
|
|
||||||
struct DateTimeVisitor;
|
|
||||||
|
|
||||||
impl<'de> serde::de::Visitor<'de> for DateTimeVisitor {
|
|
||||||
type Value = Option<chrono::DateTime<Utc>>;
|
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
formatter.write_str("an ISO 8601 formatted date string or null")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
|
|
||||||
where
|
|
||||||
E: serde::de::Error,
|
|
||||||
{
|
|
||||||
match chrono::DateTime::parse_from_rfc3339(value) {
|
|
||||||
Ok(dt) => Ok(Some(dt.with_timezone(&Utc))),
|
|
||||||
Err(e) => Err(E::custom(format!("Failed to parse datetime: {}", e))),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_none<E>(self) -> Result<Self::Value, E>
|
|
||||||
where
|
|
||||||
E: serde::de::Error,
|
|
||||||
{
|
|
||||||
Ok(None)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
|
|
||||||
where
|
|
||||||
D: Deserializer<'de>,
|
|
||||||
{
|
|
||||||
deserializer.deserialize_str(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
deserializer.deserialize_option(DateTimeVisitor)
|
|
||||||
}
|
|
||||||
|
@ -8,15 +8,20 @@ use axum::{
|
|||||||
pub struct RootRoute;
|
pub struct RootRoute;
|
||||||
impl RootRoute {
|
impl RootRoute {
|
||||||
pub fn routes() -> Router {
|
pub fn routes() -> Router {
|
||||||
Router::new().route("/", get(RootRoute::root))
|
Router::new()
|
||||||
// .fallback(RootRoute::not_found)
|
.route("/", get(RootRoute::root))
|
||||||
|
.route("/health", get(RootRoute::health))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn root() -> Html<&'static str> {
|
async fn root() -> Html<&'static str> {
|
||||||
Html("<p>Copyright Wyatt J. Miller 2024</p>")
|
Html("<p>Copyright Wyatt J. Miller 2024</p>")
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn not_found() -> impl IntoResponse {
|
pub async fn not_found() -> impl IntoResponse {
|
||||||
(StatusCode::NOT_FOUND, "¯\\_(ツ)_/¯")
|
(StatusCode::NOT_FOUND, "¯\\_(ツ)_/¯")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn health() -> impl IntoResponse {
|
||||||
|
StatusCode::OK
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
56
backend/public/src/utils/datetime.rs
Normal file
56
backend/public/src/utils/datetime.rs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
use chrono::Utc;
|
||||||
|
use serde::{Deserializer, Serializer};
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
|
pub fn serialize_datetime<S>(
|
||||||
|
date: &Option<chrono::DateTime<Utc>>,
|
||||||
|
serializer: S,
|
||||||
|
) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: Serializer,
|
||||||
|
{
|
||||||
|
serializer.serialize_str(&date.unwrap().to_rfc3339())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn deserialize_datetime<'de, D>(
|
||||||
|
deserializer: D,
|
||||||
|
) -> Result<Option<chrono::DateTime<Utc>>, D::Error>
|
||||||
|
where
|
||||||
|
D: Deserializer<'de>,
|
||||||
|
{
|
||||||
|
struct DateTimeVisitor;
|
||||||
|
|
||||||
|
impl<'de> serde::de::Visitor<'de> for DateTimeVisitor {
|
||||||
|
type Value = Option<chrono::DateTime<Utc>>;
|
||||||
|
|
||||||
|
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
formatter.write_str("an ISO 8601 formatted date string or null")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
|
||||||
|
where
|
||||||
|
E: serde::de::Error,
|
||||||
|
{
|
||||||
|
match chrono::DateTime::parse_from_rfc3339(value) {
|
||||||
|
Ok(dt) => Ok(Some(dt.with_timezone(&Utc))),
|
||||||
|
Err(e) => Err(E::custom(format!("Failed to parse datetime: {}", e))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_none<E>(self) -> Result<Self::Value, E>
|
||||||
|
where
|
||||||
|
E: serde::de::Error,
|
||||||
|
{
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
|
||||||
|
where
|
||||||
|
D: Deserializer<'de>,
|
||||||
|
{
|
||||||
|
deserializer.deserialize_str(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deserializer.deserialize_option(DateTimeVisitor)
|
||||||
|
}
|
@ -1 +1,2 @@
|
|||||||
|
pub mod datetime;
|
||||||
pub mod rss;
|
pub mod rss;
|
||||||
|
921
backend/task/Cargo.lock
generated
921
backend/task/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -20,3 +20,4 @@ futures = "0.3.30"
|
|||||||
markdown = "1.0.0-alpha.20"
|
markdown = "1.0.0-alpha.20"
|
||||||
serde = {version = "*", features = ["derive"]}
|
serde = {version = "*", features = ["derive"]}
|
||||||
serde_yaml = "*"
|
serde_yaml = "*"
|
||||||
|
aws-sdk-s3 = "1.77.0"
|
||||||
|
@ -35,7 +35,7 @@ export default function Header() {
|
|||||||
return (
|
return (
|
||||||
<header>
|
<header>
|
||||||
<nav>
|
<nav>
|
||||||
<div class="bg-[#313244] flex justify-center space-x-6 p-4">
|
<div class="bg-[#313244] flex flex-wrap justify-center space-x-6 p-4">
|
||||||
{headerLinks.map((l) => {
|
{headerLinks.map((l) => {
|
||||||
const newTab = l.newTab ? "_blank" : "_self";
|
const newTab = l.newTab ? "_blank" : "_self";
|
||||||
return (
|
return (
|
||||||
|
@ -5,7 +5,7 @@ export const PostHeader = function PostHeader({ post }: PostHeaderOpts) {
|
|||||||
return (
|
return (
|
||||||
<div class="p-6 bg-[#313244] shadow-md">
|
<div class="p-6 bg-[#313244] shadow-md">
|
||||||
<div class="min-w-screen flex flex-col items-center justify-between bg-[#45475a] rounded-lg shadow-md">
|
<div class="min-w-screen flex flex-col items-center justify-between bg-[#45475a] rounded-lg shadow-md">
|
||||||
<div class="sm:mt-14 sm:mb-14 mt-12 mb-4 flex flex-col items-center gap-y-5 gap-x-10 md:flex-row">
|
<div class="sm:mt-14 sm:mb-14 mt-8 mb-8 flex flex-col items-center gap-y-5 gap-x-10 md:flex-row">
|
||||||
<div class="space-y-2 text-center md:text-left">
|
<div class="space-y-2 text-center md:text-left">
|
||||||
<p class="text-2xl text-[#f5e0dc] font-bold sm:text-4xl">
|
<p class="text-2xl text-[#f5e0dc] font-bold sm:text-4xl">
|
||||||
{post.title}
|
{post.title}
|
||||||
|
@ -13,7 +13,7 @@ export default function Error404() {
|
|||||||
The page you were looking for doesn't exist!
|
The page you were looking for doesn't exist!
|
||||||
</p>
|
</p>
|
||||||
<a
|
<a
|
||||||
href="/"
|
href={`${Deno.env.get("BASE_URI_WEB")}/`}
|
||||||
class="text-[#cdd6f4] transition-all duration-300 ease-in-out hover:text-[#cba6f7] hover:drop-shadow-[0_0_20px_rgba(96,165,250,0.7)] hover:scale-110 cursor-pointer"
|
class="text-[#cdd6f4] transition-all duration-300 ease-in-out hover:text-[#cba6f7] hover:drop-shadow-[0_0_20px_rgba(96,165,250,0.7)] hover:scale-110 cursor-pointer"
|
||||||
>
|
>
|
||||||
Go back home
|
Go back home
|
||||||
|
@ -27,7 +27,6 @@ export const handler: Handlers<PageData> = {
|
|||||||
|
|
||||||
export default function PostIdentifier({ data }: PageProps<PageData>) {
|
export default function PostIdentifier({ data }: PageProps<PageData>) {
|
||||||
const { postData } = data;
|
const { postData } = data;
|
||||||
console.log(postData);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user