Compare commits

..

1 Commits

Author SHA1 Message Date
49a44f6a1a
Merge c3794fa2b6 into 2006be0434 2024-08-25 20:59:38 +02:00
12 changed files with 34 additions and 24 deletions

View File

View File

@ -9,7 +9,7 @@ services:
app:
build: .
env_file: .env.dev
env_file: .dev.env
depends_on:
- redis
restart: unless-stopped

View File

@ -38,6 +38,10 @@ pub static ref ALLOW_FILES: bool = std::env::var("ALLOW_FILES")
.unwrap_or("true".to_string())
.parse()
.unwrap();
pub static ref THEME_NEW_NOTE_NOTICE: bool = std::env::var("THEME_NEW_NOTE_NOTICE")
.unwrap_or("true".to_string())
.parse()
.unwrap();
}
// THEME
@ -58,8 +62,4 @@ lazy_static! {
.unwrap_or("".to_string())
.parse()
.unwrap();
pub static ref THEME_NEW_NOTE_NOTICE: bool = std::env::var("THEME_NEW_NOTE_NOTICE")
.unwrap_or("true".to_string())
.parse()
.unwrap();
}

View File

@ -1,5 +1,5 @@
use axum::{
extract::{DefaultBodyLimit, Request},
extract::Request,
routing::{delete, get, post},
Router, ServiceExt,
};
@ -7,6 +7,7 @@ use dotenv::dotenv;
use tower::Layer;
use tower_http::{
compression::CompressionLayer,
limit::RequestBodyLimitLayer,
normalize_path::NormalizePathLayer,
services::{ServeDir, ServeFile},
};
@ -46,14 +47,14 @@ async fn main() {
let app = Router::new()
.nest("/api", api_routes)
.fallback_service(serve_dir)
.layer(DefaultBodyLimit::max(*config::LIMIT))
.layer(
CompressionLayer::new()
.br(true)
.deflate(true)
.gzip(true)
.zstd(true),
);
)
.layer(RequestBodyLimitLayer::new(*config::LIMIT));
let app = NormalizePathLayer::trim_trailing_slash().layer(app);
@ -61,7 +62,9 @@ async fn main() {
.await
.unwrap();
println!("listening on {}", listener.local_addr().unwrap());
println!("Config {}", *config::LIMIT);
axum::serve(listener, ServiceExt::<Request>::into_make_service(app))
// axum::serve(listener, app)
.await
.unwrap();
}

View File

@ -13,12 +13,12 @@ pub struct Status {
pub max_expiration: u32,
pub allow_advanced: bool,
pub allow_files: bool,
pub theme_new_note_notice: bool,
// Theme
pub theme_image: String,
pub theme_text: String,
pub theme_page_title: String,
pub theme_favicon: String,
pub theme_new_note_notice: bool,
}
pub async fn get_status() -> (StatusCode, Json<Status>) {

View File

@ -18,19 +18,19 @@
export let icon: keyof typeof map
</script>
<button on:click {...$$restProps}>
<div on:click {...$$restProps}>
{#if map[icon]}
<svelte:component this={map[icon]} />
{/if}
</button>
</div>
<style>
button {
div {
display: inline-block;
contain: strict;
box-sizing: content-box;
}
button > :global(svg) {
div > :global(svg) {
display: block;
fill: currentColor;
}

View File

@ -116,7 +116,6 @@ export type Status = {
theme_text: string
theme_favicon: string
theme_page_title: string
theme_new_note_notice: boolean
}
export async function status() {

View File

@ -9,7 +9,7 @@ const config: PlaywrightTestConfig = {
outputDir: './test-results',
testDir: './test',
timeout: 30_000,
timeout: 10_000,
fullyParallel: true,
webServer: {
@ -22,6 +22,10 @@ const config: PlaywrightTestConfig = {
{ name: 'chrome', use: { ...devices['Desktop Chrome'] } },
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
{ name: 'safari', use: { ...devices['Desktop Safari'] } },
{ name: 'cli', use: { ...devices['Desktop Chrome'] }, grep: [/@cli/] },
{ name: 'web', use: { ...devices['Desktop Chrome'] }, grep: [/@web/] },
{ name: 'cross', use: { ...devices['Desktop Chrome'] }, grep: [/@cross/] },
],
}

View File

@ -1,11 +1,10 @@
import { test } from '@playwright/test'
import { basename } from 'node:path'
import { rm } from 'node:fs/promises'
import { Files, getFileChecksum, tmpFile } from '../../files'
import { Files, getFileChecksum, rm, tmpFile } from '../../files'
import { CLI, getLinkFromCLI } from '../../utils'
test.describe('file @cli', () => {
test('simple', async () => {
test('simple', async ({ page }) => {
const file = await tmpFile(Files.Image)
const checksum = await getFileChecksum(file)
const note = await CLI('send', 'file', file)
@ -18,7 +17,7 @@ test.describe('file @cli', () => {
test.expect(checksum).toBe(c)
})
test('simple with password', async () => {
test('simple with password', async ({ page }) => {
const file = await tmpFile(Files.Image)
const password = 'password'
const checksum = await getFileChecksum(file)

View File

@ -2,7 +2,7 @@ import { test } from '@playwright/test'
import { CLI, getLinkFromCLI } from '../../utils'
test.describe('text @cli', () => {
test('simple', async () => {
test('simple', async ({ page }) => {
const text = `Endless prejudice endless play derive joy eternal-return selfish burying. Of decieve play pinnacle faith disgust. Spirit reason salvation burying strong of joy ascetic selfish against merciful sea truth. Ubermensch moral prejudice derive chaos mountains ubermensch justice philosophy justice ultimate joy ultimate transvaluation. Virtues convictions war ascetic eternal-return spirit. Ubermensch transvaluation noble revaluation sexuality intentions salvation endless decrepit hope noble fearful. Justice ideal ultimate snare god joy evil sexuality insofar gains oneself ideal.`
const note = await CLI('send', 'text', text)
const link = getLinkFromCLI(note.stdout)
@ -11,7 +11,7 @@ test.describe('text @cli', () => {
test.expect(retrieved.stdout.trim()).toBe(text)
})
test('simple with password', async () => {
test('simple with password', async ({ page }) => {
const text = `Endless prejudice endless play derive joy eternal-return selfish burying.`
const password = 'password'
const note = await CLI('send', 'text', text, '--password', password)

View File

@ -1,5 +1,10 @@
import { createHash } from 'node:crypto'
import { cp, readFile } from 'node:fs/promises'
import { createHash } from 'crypto'
import { cp as cpFN, rm as rmFN } from 'fs'
import { readFile } from 'fs/promises'
import { promisify } from 'util'
export const cp = promisify(cpFN)
export const rm = promisify(rmFN)
export const Files = {
PDF: 'test/assets/AES.pdf',

View File

@ -5,6 +5,6 @@ import { Files } from '../../files'
test.describe('@web', () => {
test('to big zip', async ({ page }) => {
const files = [Files.Zip]
await createNote(page, { files, error: 'note is to big' })
const link = await createNote(page, { files, error: 'note is to big' })
})
})