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> { |
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 { TableProps } from 'antd'; | |
import Table, { ColumnsType } from 'antd/es/table'; | |
import dynamic from 'next/dynamic'; | |
import { memo, useMemo, useState } from 'react'; | |
import { ResizeCallbackData } from 'react-resizable'; | |
import styles from 'styles/index.module.scss'; | |
const ResizableTitle = dynamic( | |
() => import('components/pages/resizable-title'), | |
); |
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
local function organize_imports() | |
local params = { | |
command = "_typescript.organizeImports", | |
arguments = { vim.api.nvim_buf_get_name(0) }, | |
} | |
vim.lsp.buf.execute_command(params) | |
end | |
lspconfig.tsserver.setup { | |
on_attach = on_attach, |
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, | |
response::{IntoResponse, Response}, | |
Json, | |
}; | |
use log::error; | |
use serde_json::json; | |
#[derive(thiserror::Error, Debug)] | |
pub enum AppError { |