Compare commits

...

8 Commits

Author SHA1 Message Date
a5da51fb2c
Merge dfa2401eea into 2006be0434 2024-08-25 20:22:56 +00:00
dfa2401eea aria check 2024-08-25 22:22:45 +02:00
ea58d89f98 cleanup 2024-08-25 22:22:13 +02:00
eaca1a981d cleanup 2024-08-25 22:21:45 +02:00
199755d18e timeout 2024-08-25 22:20:46 +02:00
724d0709d3 .env.dev 2024-08-25 22:20:29 +02:00
bd5acca97a use axum body limit 2024-08-25 22:19:41 +02:00
a0a99cd3cc cleanup status variable 2024-08-25 22:18:31 +02:00
12 changed files with 24 additions and 34 deletions

View File

View File

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

View File

@ -38,10 +38,6 @@ 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
@ -62,4 +58,8 @@ 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::Request,
extract::{DefaultBodyLimit, Request},
routing::{delete, get, post},
Router, ServiceExt,
};
@ -7,7 +7,6 @@ use dotenv::dotenv;
use tower::Layer;
use tower_http::{
compression::CompressionLayer,
limit::RequestBodyLimitLayer,
normalize_path::NormalizePathLayer,
services::{ServeDir, ServeFile},
};
@ -47,14 +46,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);
@ -62,9 +61,7 @@ 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>
<div on:click {...$$restProps}>
<button on:click {...$$restProps}>
{#if map[icon]}
<svelte:component this={map[icon]} />
{/if}
</div>
</button>
<style>
div {
button {
display: inline-block;
contain: strict;
box-sizing: content-box;
}
div > :global(svg) {
button > :global(svg) {
display: block;
fill: currentColor;
}

View File

@ -116,6 +116,7 @@ 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: 10_000,
timeout: 30_000,
fullyParallel: true,
webServer: {
@ -22,10 +22,6 @@ 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,10 +1,11 @@
import { test } from '@playwright/test'
import { basename } from 'node:path'
import { Files, getFileChecksum, rm, tmpFile } from '../../files'
import { rm } from 'node:fs/promises'
import { Files, getFileChecksum, tmpFile } from '../../files'
import { CLI, getLinkFromCLI } from '../../utils'
test.describe('file @cli', () => {
test('simple', async ({ page }) => {
test('simple', async () => {
const file = await tmpFile(Files.Image)
const checksum = await getFileChecksum(file)
const note = await CLI('send', 'file', file)
@ -17,7 +18,7 @@ test.describe('file @cli', () => {
test.expect(checksum).toBe(c)
})
test('simple with password', async ({ page }) => {
test('simple with password', async () => {
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 ({ page }) => {
test('simple', async () => {
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 ({ page }) => {
test('simple with password', async () => {
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,10 +1,5 @@
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)
import { createHash } from 'node:crypto'
import { cp, readFile } from 'node:fs/promises'
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]
const link = await createNote(page, { files, error: 'note is to big' })
await createNote(page, { files, error: 'note is to big' })
})
})