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
fn de_str<'de, D>(deserializer: D) -> Result<i64, D::Error> | |
where | |
D: serde::de::Deserializer<'de>, | |
{ | |
Ok(match Value::deserialize(deserializer)? { | |
Value::String(s) => s.parse().map_err(de::Error::custom)?, | |
Value::Number(num) => num.as_i64().ok_or(de::Error::custom("Invalide number"))?, | |
_ => return Err(de::Error::custom("wrong type")), | |
}) | |
} |
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::{ | |
access_db, | |
api::{parse_booth_url, types::BoothExamples}, | |
}; | |
use anyhow::Result; | |
use sqlx::{Postgres, QueryBuilder}; | |
pub struct BoothUrls(Vec<String>); | |
impl BoothUrls { |
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
pub async fn record_post(urls: Vec<String>) -> Result<()> { | |
let pool = access_db().await; | |
let mut query_builder: QueryBuilder<Postgres> = | |
QueryBuilder::new("INSERT INTO post_record (url) "); | |
query_builder.push_values(urls, |mut b, url| { | |
b.push_bind(url); | |
}); | |
let query = query_builder.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
static DB: OnceCell<Pool<Postgres>> = OnceCell::const_new(); | |
async fn access_db() -> &'static Pool<Postgres> { | |
let initer = || async { | |
let db_url = env::var("SPIO_DB").expect("db host url must be set"); | |
let pool = PgPoolOptions::new() | |
.max_connections(20) | |
.acquire_timeout(Duration::from_secs(3)) | |
.connect(&db_url) | |
.await; | |
match pool { |
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 { AppThunk, RootState } from '@/store'; | |
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; | |
import { notification } from 'antd'; | |
import { ZegoUser } from 'zego-express-engine-webrtc/sdk/src/common/zego.entity'; | |
import type { ZegoRoomStateChangedReason } from 'zego-express-engine-webrtm/sdk/code/zh/ZegoExpressEntity'; | |
import { ZegoBroadcastMessageInfo } from 'zego-express-engine-webrtm/sdk/code/zh/ZegoExpressEntity'; | |
/** | |
* 是否是房间类消息 | |
*/ |
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
package middlewares | |
import ( | |
"github.com/gin-gonic/gin" | |
) | |
func CORSMiddleware() gin.HandlerFunc { | |
return func(c *gin.Context) { | |
c.Writer.Header().Set("Access-Control-Allow-Origin", "*") | |
c.Writer.Header().Set("Access-Control-Allow-Credentials", "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
NAME=exre | |
VERSION=0.0.1 | |
.PHONY: build | |
## build: Compile the packages. | |
build: | |
@go build -buildvcs=false -o $(NAME) | |
.PHONY: run | |
## run: Build and Run in development mode. |
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
useEffect(() => { | |
(async () => { | |
const result = await decrypt_from_url(VIDEO_PATH); | |
if (!ref.current) return; | |
const video = ref.current; | |
const source = new MediaSource(); | |
video.src = URL.createObjectURL(source); | |
source.addEventListener("sourceopen", (e) => { | |
const target = e.target as MediaSource; |
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
{ | |
"scripts": { | |
"pretty": "prettier --write \"./**/*.{js,jsx,ts,tsx,json,md,mdx,css}\" --ignore-unknown", | |
"pretty-check": "prettier \"./**/*.{js,jsx,ts,tsx,json,md,mdx,css}\" --ignore-unknown --check", | |
"prepare": "husky install" | |
} | |
} |
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 |