This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules | |
out | |
.next | |
public | |
dist | |
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root = true | |
[*] | |
indent_style = space | |
indent_size = 2 | |
end_of_line = lf | |
charset = utf-8 | |
trim_trailing_whitespace = true | |
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use axum::{ | |
http::{StatusCode, Uri}, | |
response::IntoResponse, | |
}; | |
use tracing::info; | |
pub mod baidu; | |
pub async fn hello() -> &'static str { | |
"Hello World!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use crate::error::AppResult; | |
use anyhow::anyhow; | |
use axum::{ | |
body::Body, extract::Request, http::HeaderValue, middleware::Next, response::IntoResponse, | |
}; | |
/// Middleware for adding version information to each response's headers. | |
/// | |
/// This middleware takes an incoming `Request` and a `Next` handler, which represents the | |
/// subsequent middleware or route in the chain. It then asynchronously runs the next handler, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { existsSync, createReadStream, createWriteStream } from 'fs'; | |
import { Readable, Writable } from 'stream'; | |
import { afterEach, describe, it, vi } from 'vitest'; | |
vi.mock('fs', async (importOriginal) => ({ | |
...(await importOriginal<typeof import('fs')>()), | |
existsSync: vi.fn().mockImplementation(() => true), | |
createReadStream: vi.fn().mockImplementation(() => { | |
const stream = new Readable(); | |
stream.push('test'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const isWeChat = () => | |
/MicroMessenger/i.test(window.navigator.userAgent); | |
export const isWeChatSafari = navigator.userAgent.match( | |
/(?=iPhone|iPod)(?=.*(Safari|MicroMessenger))/i | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eu | |
if ! cargo fmt -- --check; then | |
echo "There are some code style issues." | |
echo "Run cargo fmt first." | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- build | |
variables: | |
APP_NAME: "cymo" | |
image: "rust:latest" | |
before_script: | |
- apt-get update -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use tower_http::trace::{ | |
DefaultMakeSpan, DefaultOnBodyChunk, DefaultOnEos, DefaultOnFailure, DefaultOnRequest, | |
DefaultOnResponse, TraceLayer, | |
}; | |
use tracing::Level; | |
/// Constructs a TraceLayer for Axum applications to enable logging and tracing of HTTP requests and responses. | |
/// | |
/// The TraceLayer is a middleware layer that integrates with Tower HTTP's tracing capabilities. | |
/// It provides detailed information about the execution of HTTP requests and responses, allowing for |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Find parents of all files | |
/// | |
/// ## Arguments | |
/// | |
/// `local_path`: local files path from params | |
/// | |
/// ## Return | |
/// | |
/// `Fn`: used for `fold()`'s callback | |
pub fn fold_parents(local_path: &String) -> impl Fn(Vec<PathBuf>, &PathBuf) -> Vec<PathBuf> { |