From a45f6a3772c243685bfbd24d77312105a8b41d4f Mon Sep 17 00:00:00 2001 From: Niccolo Borgioli Date: Fri, 23 Aug 2024 14:27:17 +0200 Subject: [PATCH 01/25] use 3000 port --- Cryptgeon.postman_collection.json | 1305 ++++++++++++++--------------- README_ES.md | 26 +- README_zh-CN.md | 4 +- docker-compose.dev.yaml | 2 +- packages/proxy/proxy.js | 4 +- playwright.config.ts | 4 +- test/utils.ts | 2 +- 7 files changed, 634 insertions(+), 713 deletions(-) diff --git a/Cryptgeon.postman_collection.json b/Cryptgeon.postman_collection.json index 08d3c44..655151f 100644 --- a/Cryptgeon.postman_collection.json +++ b/Cryptgeon.postman_collection.json @@ -1,693 +1,614 @@ { - "info": { - "_postman_id": "3aaeac19-4eac-4911-b3c8-912b17a48634", - "name": "Cryptgeon", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" - }, - "item": [ - { - "name": "Notes", - "item": [ - { - "name": "Preview", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{BASE}}/notes/:id", - "host": [ - "{{BASE}}" - ], - "path": [ - "notes", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "{{NOTE_ID}}", - "description": "Id of the Note" - } - ] - }, - "description": "This endpoint is to query wether a note exists, without actually opening it. No view limits are used here, as contents of the note are not available, only the `meta` field is returned, which is public." - }, - "response": [ - { - "name": "200", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "{{BASE}}/notes/:id", - "host": [ - "{{BASE}}" - ], - "path": [ - "notes", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "{{NOTE_ID}}", - "description": "Id of the Note" - } - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "transfer-encoding", - "value": "chunked" - }, - { - "key": "connection", - "value": "close" - }, - { - "key": "content-type", - "value": "application/json" - }, - { - "key": "content-encoding", - "value": "gzip" - }, - { - "key": "vary", - "value": "accept-encoding" - }, - { - "key": "date", - "value": "Tue, 23 May 2023 05:24:29 GMT" - } - ], - "cookie": [], - "body": "{}" - }, - { - "name": "404", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "{{BASE}}/notes/:id", - "host": [ - "{{BASE}}" - ], - "path": [ - "notes", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "{{NOTE_ID}}", - "description": "Id of the Note" - } - ] - } - }, - "status": "Not Found", - "code": 404, - "_postman_previewlanguage": "plain", - "header": [ - { - "key": "transfer-encoding", - "value": "chunked" - }, - { - "key": "connection", - "value": "close" - }, - { - "key": "vary", - "value": "accept-encoding" - }, - { - "key": "content-encoding", - "value": "gzip" - }, - { - "key": "date", - "value": "Tue, 23 May 2023 05:25:26 GMT" - } - ], - "cookie": [], - "body": "" - } - ] - }, - { - "name": "Create", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "const jsonData = pm.response.json();", - "pm.collectionVariables.set('NOTE_ID', jsonData.id)", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"contents\": \"Some encrypted content\",\n \"views\": 1,\n \"meta\": \"{\\\"type\\\":\\\"text\\\"}\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{BASE}}/notes/", - "host": [ - "{{BASE}}" - ], - "path": [ - "notes", - "" - ] - } - }, - "response": [ - { - "name": "Simple", - "originalRequest": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"contents\": \"Some encrypted content\",\n \"views\": 1,\n \"meta\": \"{\\\"type\\\":\\\"text\\\"}\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{BASE}}/notes/", - "host": [ - "{{BASE}}" - ], - "path": [ - "notes", - "" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "transfer-encoding", - "value": "chunked" - }, - { - "key": "connection", - "value": "close" - }, - { - "key": "content-encoding", - "value": "gzip" - }, - { - "key": "content-type", - "value": "application/json" - }, - { - "key": "vary", - "value": "accept-encoding" - }, - { - "key": "date", - "value": "Tue, 23 May 2023 05:31:54 GMT" - } - ], - "cookie": [], - "body": "{\n \"id\": \"1QeEWDQbQY9dOo8cDDQjykaEjouqugTR6A78sjgn4VMv\"\n}" - }, - { - "name": "5 Minutes", - "originalRequest": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"contents\": \"Some encrypted content\",\n \"expiration\": 5,\n \"meta\": \"{\\\"type\\\":\\\"text\\\"}\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{BASE}}/notes/", - "host": [ - "{{BASE}}" - ], - "path": [ - "notes", - "" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "transfer-encoding", - "value": "chunked" - }, - { - "key": "connection", - "value": "close" - }, - { - "key": "content-encoding", - "value": "gzip" - }, - { - "key": "content-type", - "value": "application/json" - }, - { - "key": "vary", - "value": "accept-encoding" - }, - { - "key": "date", - "value": "Tue, 23 May 2023 05:31:54 GMT" - } - ], - "cookie": [], - "body": "{\n \"id\": \"1QeEWDQbQY9dOo8cDDQjykaEjouqugTR6A78sjgn4VMv\"\n}" - }, - { - "name": "3 Views", - "originalRequest": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"contents\": \"Some encrypted content\",\n \"views\": 3,\n \"meta\": \"{\\\"type\\\":\\\"text\\\"}\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{BASE}}/notes/", - "host": [ - "{{BASE}}" - ], - "path": [ - "notes", - "" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "transfer-encoding", - "value": "chunked" - }, - { - "key": "connection", - "value": "close" - }, - { - "key": "content-encoding", - "value": "gzip" - }, - { - "key": "content-type", - "value": "application/json" - }, - { - "key": "vary", - "value": "accept-encoding" - }, - { - "key": "date", - "value": "Tue, 23 May 2023 05:31:54 GMT" - } - ], - "cookie": [], - "body": "{\n \"id\": \"1QeEWDQbQY9dOo8cDDQjykaEjouqugTR6A78sjgn4VMv\"\n}" - } - ] - }, - { - "name": "Read", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{BASE}}/notes/:id", - "host": [ - "{{BASE}}" - ], - "path": [ - "notes", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "{{NOTE_ID}}" - } - ] - }, - "description": "This endpoint gets the actual contents of a note. It's a `DELETE` endpoint, es it decreases the `view` counter, and deletes the note if `0` is reached." - }, - "response": [ - { - "name": "200", - "originalRequest": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{BASE}}/notes/:id", - "host": [ - "{{BASE}}" - ], - "path": [ - "notes", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "{{NOTE_ID}}" - } - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "transfer-encoding", - "value": "chunked" - }, - { - "key": "connection", - "value": "close" - }, - { - "key": "content-type", - "value": "application/json" - }, - { - "key": "vary", - "value": "accept-encoding" - }, - { - "key": "content-encoding", - "value": "gzip" - }, - { - "key": "date", - "value": "Tue, 23 May 2023 05:59:07 GMT" - } - ], - "cookie": [], - "body": "{\n \"meta\": \"{\\\"type\\\":\\\"text\\\"}\",\n \"contents\": \"Some encrypted content\"\n}" - }, - { - "name": "404", - "originalRequest": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{BASE}}/notes/:id", - "host": [ - "{{BASE}}" - ], - "path": [ - "notes", - ":id" - ], - "variable": [ - { - "key": "id", - "value": "{{NOTE_ID}}" - } - ] - } - }, - "status": "Not Found", - "code": 404, - "_postman_previewlanguage": "plain", - "header": [ - { - "key": "transfer-encoding", - "value": "chunked" - }, - { - "key": "connection", - "value": "close" - }, - { - "key": "vary", - "value": "accept-encoding" - }, - { - "key": "content-encoding", - "value": "gzip" - }, - { - "key": "date", - "value": "Tue, 23 May 2023 05:59:15 GMT" - } - ], - "cookie": [], - "body": "" - } - ] - } - ] - }, - { - "name": "Status", - "item": [ - { - "name": "Get server status", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{BASE}}/status/", - "host": [ - "{{BASE}}" - ], - "path": [ - "status", - "" - ] - } - }, - "response": [ - { - "name": "200", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "{{BASE}}/status/", - "host": [ - "{{BASE}}" - ], - "path": [ - "status", - "" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "transfer-encoding", - "value": "chunked" - }, - { - "key": "connection", - "value": "close" - }, - { - "key": "content-encoding", - "value": "gzip" - }, - { - "key": "vary", - "value": "accept-encoding" - }, - { - "key": "content-type", - "value": "application/json" - }, - { - "key": "date", - "value": "Tue, 23 May 2023 05:56:45 GMT" - } - ], - "cookie": [], - "body": "{\n \"version\": \"2.3.0-beta.4\",\n \"max_size\": 10485760,\n \"max_views\": 100,\n \"max_expiration\": 360,\n \"allow_advanced\": true,\n \"theme_image\": \"\",\n \"theme_text\": \"\",\n \"theme_page_title\": \"\",\n \"theme_favicon\": \"\"\n}" - } - ] - }, - { - "name": "Health Check", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{BASE}}/live/", - "host": [ - "{{BASE}}" - ], - "path": [ - "live", - "" - ] - }, - "description": "Return `200` for healthy service. `503` if service is unavailable." - }, - "response": [ - { - "name": "Healthy", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "{{BASE}}/live/", - "host": [ - "{{BASE}}" - ], - "path": [ - "live", - "" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "plain", - "header": [ - { - "key": "transfer-encoding", - "value": "chunked" - }, - { - "key": "vary", - "value": "accept-encoding" - }, - { - "key": "content-encoding", - "value": "gzip" - }, - { - "key": "date", - "value": "Thu, 22 Jun 2023 20:17:58 GMT" - } - ], - "cookie": [], - "body": null - }, - { - "name": "Service Unavilable", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "{{BASE}}/live/", - "host": [ - "{{BASE}}" - ], - "path": [ - "live", - "" - ] - } - }, - "status": "Service Unavailable", - "code": 503, - "_postman_previewlanguage": "plain", - "header": [ - { - "key": "transfer-encoding", - "value": "chunked" - }, - { - "key": "content-encoding", - "value": "gzip" - }, - { - "key": "vary", - "value": "accept-encoding" - }, - { - "key": "date", - "value": "Thu, 22 Jun 2023 20:18:55 GMT" - } - ], - "cookie": [], - "body": null - } - ] - } - ] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ], - "variable": [ - { - "key": "BASE", - "value": "http://localhost:1234/api", - "type": "default" - }, - { - "key": "NOTE_ID", - "value": "", - "type": "default" - } - ] -} \ No newline at end of file + "info": { + "_postman_id": "3aaeac19-4eac-4911-b3c8-912b17a48634", + "name": "Cryptgeon", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "Notes", + "item": [ + { + "name": "Preview", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{BASE}}/notes/:id", + "host": ["{{BASE}}"], + "path": ["notes", ":id"], + "variable": [ + { + "key": "id", + "value": "{{NOTE_ID}}", + "description": "Id of the Note" + } + ] + }, + "description": "This endpoint is to query wether a note exists, without actually opening it. No view limits are used here, as contents of the note are not available, only the `meta` field is returned, which is public." + }, + "response": [ + { + "name": "200", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{BASE}}/notes/:id", + "host": ["{{BASE}}"], + "path": ["notes", ":id"], + "variable": [ + { + "key": "id", + "value": "{{NOTE_ID}}", + "description": "Id of the Note" + } + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "transfer-encoding", + "value": "chunked" + }, + { + "key": "connection", + "value": "close" + }, + { + "key": "content-type", + "value": "application/json" + }, + { + "key": "content-encoding", + "value": "gzip" + }, + { + "key": "vary", + "value": "accept-encoding" + }, + { + "key": "date", + "value": "Tue, 23 May 2023 05:24:29 GMT" + } + ], + "cookie": [], + "body": "{}" + }, + { + "name": "404", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{BASE}}/notes/:id", + "host": ["{{BASE}}"], + "path": ["notes", ":id"], + "variable": [ + { + "key": "id", + "value": "{{NOTE_ID}}", + "description": "Id of the Note" + } + ] + } + }, + "status": "Not Found", + "code": 404, + "_postman_previewlanguage": "plain", + "header": [ + { + "key": "transfer-encoding", + "value": "chunked" + }, + { + "key": "connection", + "value": "close" + }, + { + "key": "vary", + "value": "accept-encoding" + }, + { + "key": "content-encoding", + "value": "gzip" + }, + { + "key": "date", + "value": "Tue, 23 May 2023 05:25:26 GMT" + } + ], + "cookie": [], + "body": "" + } + ] + }, + { + "name": "Create", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const jsonData = pm.response.json();", + "pm.collectionVariables.set('NOTE_ID', jsonData.id)", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"contents\": \"Some encrypted content\",\n \"views\": 1,\n \"meta\": \"{\\\"type\\\":\\\"text\\\"}\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{BASE}}/notes/", + "host": ["{{BASE}}"], + "path": ["notes", ""] + } + }, + "response": [ + { + "name": "Simple", + "originalRequest": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"contents\": \"Some encrypted content\",\n \"views\": 1,\n \"meta\": \"{\\\"type\\\":\\\"text\\\"}\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{BASE}}/notes/", + "host": ["{{BASE}}"], + "path": ["notes", ""] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "transfer-encoding", + "value": "chunked" + }, + { + "key": "connection", + "value": "close" + }, + { + "key": "content-encoding", + "value": "gzip" + }, + { + "key": "content-type", + "value": "application/json" + }, + { + "key": "vary", + "value": "accept-encoding" + }, + { + "key": "date", + "value": "Tue, 23 May 2023 05:31:54 GMT" + } + ], + "cookie": [], + "body": "{\n \"id\": \"1QeEWDQbQY9dOo8cDDQjykaEjouqugTR6A78sjgn4VMv\"\n}" + }, + { + "name": "5 Minutes", + "originalRequest": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"contents\": \"Some encrypted content\",\n \"expiration\": 5,\n \"meta\": \"{\\\"type\\\":\\\"text\\\"}\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{BASE}}/notes/", + "host": ["{{BASE}}"], + "path": ["notes", ""] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "transfer-encoding", + "value": "chunked" + }, + { + "key": "connection", + "value": "close" + }, + { + "key": "content-encoding", + "value": "gzip" + }, + { + "key": "content-type", + "value": "application/json" + }, + { + "key": "vary", + "value": "accept-encoding" + }, + { + "key": "date", + "value": "Tue, 23 May 2023 05:31:54 GMT" + } + ], + "cookie": [], + "body": "{\n \"id\": \"1QeEWDQbQY9dOo8cDDQjykaEjouqugTR6A78sjgn4VMv\"\n}" + }, + { + "name": "3 Views", + "originalRequest": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"contents\": \"Some encrypted content\",\n \"views\": 3,\n \"meta\": \"{\\\"type\\\":\\\"text\\\"}\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{BASE}}/notes/", + "host": ["{{BASE}}"], + "path": ["notes", ""] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "transfer-encoding", + "value": "chunked" + }, + { + "key": "connection", + "value": "close" + }, + { + "key": "content-encoding", + "value": "gzip" + }, + { + "key": "content-type", + "value": "application/json" + }, + { + "key": "vary", + "value": "accept-encoding" + }, + { + "key": "date", + "value": "Tue, 23 May 2023 05:31:54 GMT" + } + ], + "cookie": [], + "body": "{\n \"id\": \"1QeEWDQbQY9dOo8cDDQjykaEjouqugTR6A78sjgn4VMv\"\n}" + } + ] + }, + { + "name": "Read", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{BASE}}/notes/:id", + "host": ["{{BASE}}"], + "path": ["notes", ":id"], + "variable": [ + { + "key": "id", + "value": "{{NOTE_ID}}" + } + ] + }, + "description": "This endpoint gets the actual contents of a note. It's a `DELETE` endpoint, es it decreases the `view` counter, and deletes the note if `0` is reached." + }, + "response": [ + { + "name": "200", + "originalRequest": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{BASE}}/notes/:id", + "host": ["{{BASE}}"], + "path": ["notes", ":id"], + "variable": [ + { + "key": "id", + "value": "{{NOTE_ID}}" + } + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "transfer-encoding", + "value": "chunked" + }, + { + "key": "connection", + "value": "close" + }, + { + "key": "content-type", + "value": "application/json" + }, + { + "key": "vary", + "value": "accept-encoding" + }, + { + "key": "content-encoding", + "value": "gzip" + }, + { + "key": "date", + "value": "Tue, 23 May 2023 05:59:07 GMT" + } + ], + "cookie": [], + "body": "{\n \"meta\": \"{\\\"type\\\":\\\"text\\\"}\",\n \"contents\": \"Some encrypted content\"\n}" + }, + { + "name": "404", + "originalRequest": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{BASE}}/notes/:id", + "host": ["{{BASE}}"], + "path": ["notes", ":id"], + "variable": [ + { + "key": "id", + "value": "{{NOTE_ID}}" + } + ] + } + }, + "status": "Not Found", + "code": 404, + "_postman_previewlanguage": "plain", + "header": [ + { + "key": "transfer-encoding", + "value": "chunked" + }, + { + "key": "connection", + "value": "close" + }, + { + "key": "vary", + "value": "accept-encoding" + }, + { + "key": "content-encoding", + "value": "gzip" + }, + { + "key": "date", + "value": "Tue, 23 May 2023 05:59:15 GMT" + } + ], + "cookie": [], + "body": "" + } + ] + } + ] + }, + { + "name": "Status", + "item": [ + { + "name": "Get server status", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{BASE}}/status/", + "host": ["{{BASE}}"], + "path": ["status", ""] + } + }, + "response": [ + { + "name": "200", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{BASE}}/status/", + "host": ["{{BASE}}"], + "path": ["status", ""] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "transfer-encoding", + "value": "chunked" + }, + { + "key": "connection", + "value": "close" + }, + { + "key": "content-encoding", + "value": "gzip" + }, + { + "key": "vary", + "value": "accept-encoding" + }, + { + "key": "content-type", + "value": "application/json" + }, + { + "key": "date", + "value": "Tue, 23 May 2023 05:56:45 GMT" + } + ], + "cookie": [], + "body": "{\n \"version\": \"2.3.0-beta.4\",\n \"max_size\": 10485760,\n \"max_views\": 100,\n \"max_expiration\": 360,\n \"allow_advanced\": true,\n \"theme_image\": \"\",\n \"theme_text\": \"\",\n \"theme_page_title\": \"\",\n \"theme_favicon\": \"\"\n}" + } + ] + }, + { + "name": "Health Check", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{BASE}}/live/", + "host": ["{{BASE}}"], + "path": ["live", ""] + }, + "description": "Return `200` for healthy service. `503` if service is unavailable." + }, + "response": [ + { + "name": "Healthy", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{BASE}}/live/", + "host": ["{{BASE}}"], + "path": ["live", ""] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "plain", + "header": [ + { + "key": "transfer-encoding", + "value": "chunked" + }, + { + "key": "vary", + "value": "accept-encoding" + }, + { + "key": "content-encoding", + "value": "gzip" + }, + { + "key": "date", + "value": "Thu, 22 Jun 2023 20:17:58 GMT" + } + ], + "cookie": [], + "body": null + }, + { + "name": "Service Unavilable", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{BASE}}/live/", + "host": ["{{BASE}}"], + "path": ["live", ""] + } + }, + "status": "Service Unavailable", + "code": 503, + "_postman_previewlanguage": "plain", + "header": [ + { + "key": "transfer-encoding", + "value": "chunked" + }, + { + "key": "content-encoding", + "value": "gzip" + }, + { + "key": "vary", + "value": "accept-encoding" + }, + { + "key": "date", + "value": "Thu, 22 Jun 2023 20:18:55 GMT" + } + ], + "cookie": [], + "body": null + } + ] + } + ] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "exec": [""] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [""] + } + } + ], + "variable": [ + { + "key": "BASE", + "value": "http://localhost:3000/api", + "type": "default" + }, + { + "key": "NOTE_ID", + "value": "", + "type": "default" + } + ] +} diff --git a/README_ES.md b/README_ES.md index 272494e..5febea8 100644 --- a/README_ES.md +++ b/README_ES.md @@ -59,19 +59,19 @@ se usa para guardar y recuperar la nota. Después la nota es encriptada con la < ## Variables de entorno -| Variable | Default | Descripción | -| ------------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `REDIS` | `redis://redis/` | Redis URL a la que conectarse. [Según el formato](https://docs.rs/redis/latest/redis/#connection-parameters) | +| Variable | Default | Descripción | +| ------------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `REDIS` | `redis://redis/` | Redis URL a la que conectarse. [Según el formato](https://docs.rs/redis/latest/redis/#connection-parameters) | | `SIZE_LIMIT` | `1 KiB` | Tamaño máximo. Valores aceptados según la [unidad byte](https://docs.rs/byte-unit/).
`512 MiB` es el máximo permitido.
El frontend mostrará ese número, incluyendo el ~35% de sobrecarga de codificación. | -| `MAX_VIEWS` | `100` | Número máximo de vistas. | -| `MAX_EXPIRATION` | `360` | Tiempo máximo de expiración en minutos. | -| `ALLOW_ADVANCED` | `true` | Permitir configuración personalizada. Si se establece en `false` todas las notas serán de una sola vista. | -| `ID_LENGTH` | `32` | Establece el tamaño en bytes de la `id` de la nota. Por defecto es de `32` bytes. Esto es util para reducir el tamaño del link. _Esta configuración no afecta el nivel de encriptación_. | -| `VERBOSITY` | `warn` | Nivel de verbosidad del backend. [Posibles valores](https://docs.rs/env_logger/latest/env_logger/#enabling-logging): `error`, `warn`, `info`, `debug`, `trace` | -| `THEME_IMAGE` | `""` | Imagen personalizada para reemplazar el logo. Debe ser accesible públicamente. | -| `THEME_TEXT` | `""` | Texto personalizado para reemplazar la descripción bajo el logo. | -| `THEME_PAGE_TITLE` | `""` | Texto personalizado para el título | -| `THEME_FAVICON` | `""` | Url personalizada para el favicon. Debe ser accesible públicamente. | +| `MAX_VIEWS` | `100` | Número máximo de vistas. | +| `MAX_EXPIRATION` | `360` | Tiempo máximo de expiración en minutos. | +| `ALLOW_ADVANCED` | `true` | Permitir configuración personalizada. Si se establece en `false` todas las notas serán de una sola vista. | +| `ID_LENGTH` | `32` | Establece el tamaño en bytes de la `id` de la nota. Por defecto es de `32` bytes. Esto es util para reducir el tamaño del link. _Esta configuración no afecta el nivel de encriptación_. | +| `VERBOSITY` | `warn` | Nivel de verbosidad del backend. [Posibles valores](https://docs.rs/env_logger/latest/env_logger/#enabling-logging): `error`, `warn`, `info`, `debug`, `trace` | +| `THEME_IMAGE` | `""` | Imagen personalizada para reemplazar el logo. Debe ser accesible públicamente. | +| `THEME_TEXT` | `""` | Texto personalizado para reemplazar la descripción bajo el logo. | +| `THEME_PAGE_TITLE` | `""` | Texto personalizado para el título | +| `THEME_FAVICON` | `""` | Url personalizada para el favicon. Debe ser accesible públicamente. | ## Despliegue @@ -169,7 +169,7 @@ Ejecutando `pnpm run dev` en la carpeta raíz iniciará lo siguiente: - client - cli -Puedes ver la app en [localhost:1234](http://localhost:1234). +Puedes ver la app en [localhost:3000](http://localhost:3000). > Existe una colección de Postman con algunas peticiones de ejemplo [disponible en el repo](./Cryptgeon.postman_collection.json) diff --git a/README_zh-CN.md b/README_zh-CN.md index e60182a..b8e88ab 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -14,7 +14,7 @@
-[EN](README.md) | 简体中文 | [ES](README_ES.md) +[EN](README.md) | 简体中文 | [ES](README_ES.md) ## 关于本项目 @@ -158,7 +158,7 @@ pnpm run dev - 无热重载的 rust 后端 - 可热重载的客户端 -你可以通过 1234 端口进入该应用,即 [localhost:1234](http://localhost:1234). +你可以通过 3000 端口进入该应用,即 [localhost:3000](http://localhost:3000). ## 测试 diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml index 679ffd9..e0ab06d 100644 --- a/docker-compose.dev.yaml +++ b/docker-compose.dev.yaml @@ -14,7 +14,7 @@ services: - redis restart: unless-stopped ports: - - 1234:8000 + - 3000:8000 healthcheck: test: ['CMD', 'curl', '--fail', 'http://127.0.0.1:8000/api/live/'] diff --git a/packages/proxy/proxy.js b/packages/proxy/proxy.js index 7e5292f..f434436 100644 --- a/packages/proxy/proxy.js +++ b/packages/proxy/proxy.js @@ -12,5 +12,5 @@ const server = http.createServer(function (req, res) { const target = req.url.startsWith('/api/') ? 'http://127.0.0.1:8000' : 'http://localhost:8001' proxy.web(req, res, { target, proxyTimeout: 250, timeout: 250 }) }) -server.listen(1234) -console.log('Proxy on http://localhost:1234') +server.listen(3000) +console.log('Proxy on http://localhost:3000') diff --git a/playwright.config.ts b/playwright.config.ts index 4a71394..da301aa 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -3,7 +3,7 @@ import { devices, type PlaywrightTestConfig } from '@playwright/test' const config: PlaywrightTestConfig = { use: { video: 'retain-on-failure', - baseURL: 'http://localhost:1234', + baseURL: 'http://localhost:3000', actionTimeout: 10_000, }, @@ -14,7 +14,7 @@ const config: PlaywrightTestConfig = { webServer: { command: 'docker compose -f docker-compose.dev.yaml up', - port: 1234, + port: 3000, reuseExistingServer: true, }, diff --git a/test/utils.ts b/test/utils.ts index bc04228..4292510 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -91,7 +91,7 @@ export async function CLI(...args: string[]) { return await exec('./packages/cli/dist/cli.cjs', args, { env: { ...process.env, - CRYPTGEON_SERVER: 'http://localhost:1234', + CRYPTGEON_SERVER: 'http://localhost:3000', }, }) } From c2b81bc04d94b897a666d463aea9312bad31114c Mon Sep 17 00:00:00 2001 From: Niccolo Borgioli Date: Fri, 23 Aug 2024 14:27:47 +0200 Subject: [PATCH 02/25] refactor to use axum --- packages/backend/Cargo.lock | 953 ++++++++------------------ packages/backend/Cargo.toml | 16 +- packages/backend/package.json | 2 +- packages/backend/src/api.rs | 14 - packages/backend/src/client.rs | 17 - packages/backend/src/health/mod.rs | 11 +- packages/backend/src/health/routes.rs | 16 - packages/backend/src/main.rs | 76 +- packages/backend/src/note/model.rs | 4 +- packages/backend/src/note/routes.rs | 103 +-- packages/backend/src/size.rs | 12 - packages/backend/src/status/mod.rs | 43 +- packages/backend/src/status/model.rs | 19 - packages/backend/src/status/routes.rs | 25 - 14 files changed, 466 insertions(+), 845 deletions(-) delete mode 100644 packages/backend/src/api.rs delete mode 100644 packages/backend/src/client.rs delete mode 100644 packages/backend/src/health/routes.rs delete mode 100644 packages/backend/src/size.rs delete mode 100644 packages/backend/src/status/model.rs delete mode 100644 packages/backend/src/status/routes.rs diff --git a/packages/backend/Cargo.lock b/packages/backend/Cargo.lock index f11f614..ae928f4 100644 --- a/packages/backend/Cargo.lock +++ b/packages/backend/Cargo.lock @@ -2,212 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "actix-codec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f7b0a21988c1bf877cf4759ef5ddaac04c1c9fe808c9142ecb78ba97d97a28a" -dependencies = [ - "bitflags", - "bytes", - "futures-core", - "futures-sink", - "memchr", - "pin-project-lite", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "actix-files" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0773d59061dedb49a8aed04c67291b9d8cf2fe0b60130a381aab53c6dd86e9be" -dependencies = [ - "actix-http", - "actix-service", - "actix-utils", - "actix-web", - "bitflags", - "bytes", - "derive_more", - "futures-core", - "http-range", - "log", - "mime", - "mime_guess", - "percent-encoding", - "pin-project-lite", - "v_htmlescape", -] - -[[package]] -name = "actix-http" -version = "3.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d48f96fc3003717aeb9856ca3d02a8c7de502667ad76eeacd830b48d2e91fac4" -dependencies = [ - "actix-codec", - "actix-rt", - "actix-service", - "actix-utils", - "ahash", - "base64", - "bitflags", - "brotli", - "bytes", - "bytestring", - "derive_more", - "encoding_rs", - "flate2", - "futures-core", - "h2", - "http", - "httparse", - "httpdate", - "itoa", - "language-tags", - "local-channel", - "mime", - "percent-encoding", - "pin-project-lite", - "rand", - "sha1", - "smallvec", - "tokio", - "tokio-util", - "tracing", - "zstd", -] - -[[package]] -name = "actix-macros" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "actix-router" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13d324164c51f63867b57e73ba5936ea151b8a41a1d23d1031eeb9f70d0236f8" -dependencies = [ - "bytestring", - "cfg-if", - "http", - "regex", - "regex-lite", - "serde", - "tracing", -] - -[[package]] -name = "actix-rt" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eda4e2a6e042aa4e55ac438a2ae052d3b5da0ecf83d7411e1a368946925208" -dependencies = [ - "futures-core", - "tokio", -] - -[[package]] -name = "actix-server" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ca2549781d8dd6d75c40cf6b6051260a2cc2f3c62343d761a969a0640646894" -dependencies = [ - "actix-rt", - "actix-service", - "actix-utils", - "futures-core", - "futures-util", - "mio", - "socket2", - "tokio", - "tracing", -] - -[[package]] -name = "actix-service" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b894941f818cfdc7ccc4b9e60fa7e53b5042a2e8567270f9147d5591893373a" -dependencies = [ - "futures-core", - "paste", - "pin-project-lite", -] - -[[package]] -name = "actix-utils" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a1dcdff1466e3c2488e1cb5c36a71822750ad43839937f85d2f4d9f8b705d8" -dependencies = [ - "local-waker", - "pin-project-lite", -] - -[[package]] -name = "actix-web" -version = "4.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9180d76e5cc7ccbc4d60a506f2c727730b154010262df5b910eb17dbe4b8cb38" -dependencies = [ - "actix-codec", - "actix-http", - "actix-macros", - "actix-router", - "actix-rt", - "actix-server", - "actix-service", - "actix-utils", - "actix-web-codegen", - "ahash", - "bytes", - "bytestring", - "cfg-if", - "cookie", - "derive_more", - "encoding_rs", - "futures-core", - "futures-util", - "impl-more", - "itoa", - "language-tags", - "log", - "mime", - "once_cell", - "pin-project-lite", - "regex", - "regex-lite", - "serde", - "serde_json", - "serde_urlencoded", - "smallvec", - "socket2", - "time", - "url", -] - -[[package]] -name = "actix-web-codegen" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f591380e2e68490b5dfaf1dd1aa0ebe78d84ba7067078512b4ea6e4492d622b8" -dependencies = [ - "actix-router", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "addr2line" version = "0.22.0" @@ -229,28 +23,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "getrandom", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - [[package]] name = "alloc-no-stdlib" version = "2.0.4" @@ -267,14 +39,30 @@ dependencies = [ ] [[package]] -name = "atty" -version = "0.2.14" +name = "async-compression" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +checksum = "bc2d0cfb2a7388d34f590e76686704c494ed7aaceed62ee1ba35cbf363abc2a5" dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", + "brotli", + "flate2", + "futures-core", + "memchr", + "pin-project-lite", + "tokio", + "zstd", + "zstd-safe", +] + +[[package]] +name = "async-trait" +version = "0.1.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -283,6 +71,61 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +[[package]] +name = "axum" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +dependencies = [ + "async-trait", + "axum-core", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper 1.0.1", + "tokio", + "tower 0.4.13", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper 0.1.2", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "backtrace" version = "0.3.73" @@ -300,9 +143,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.22.1" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "bitflags" @@ -310,20 +153,11 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - [[package]] name = "brotli" -version = "6.0.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f7971dbd9326d58187408ab83117d8ac1bb9c17b085fdacd1cf2f598719b6b" +checksum = "d640d25bc63c50fb1f0b545ffd80207d2e10a4c965530809b40ba3386825c391" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -332,9 +166,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "4.0.1" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a45bd2e4095a8b518033b128020dd4a55aab1c0a381ba4404a472630f4bc362" +checksum = "4e2e4afe60d7dd600fdd3de8d0f08c2b7ec039712e3b6137ff98b7004e82de4f" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -367,27 +201,12 @@ dependencies = [ "utf8-width", ] -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "bytes" version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" -[[package]] -name = "bytestring" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d80203ea6b29df88012294f62733de21cfeab47f17b41af3a38bc30a03ee72" -dependencies = [ - "bytes", -] - [[package]] name = "cc" version = "1.1.13" @@ -415,23 +234,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "cookie" -version = "0.16.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" -dependencies = [ - "percent-encoding", - "time", - "version_check", -] - [[package]] name = "core-foundation" version = "0.9.4" @@ -448,15 +250,6 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" -[[package]] -name = "cpufeatures" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" -dependencies = [ - "libc", -] - [[package]] name = "crc32fast" version = "1.4.2" @@ -470,61 +263,18 @@ dependencies = [ name = "cryptgeon" version = "2.7.0" dependencies = [ - "actix-files", - "actix-web", + "axum", "bs62", "byte-unit", "dotenv", - "env_logger", "lazy_static", - "log", - "mime", "redis", "ring", "serde", "serde_json", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "deranged" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" -dependencies = [ - "powerfmt", -] - -[[package]] -name = "derive_more" -version = "0.99.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "crypto-common", + "tokio", + "tower 0.5.0", + "tower-http", ] [[package]] @@ -533,34 +283,6 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" -[[package]] -name = "encoding_rs" -version = "0.8.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "env_logger" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - [[package]] name = "errno" version = "0.3.9" @@ -617,6 +339,15 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", +] + [[package]] name = "futures-core" version = "0.3.30" @@ -645,16 +376,7 @@ dependencies = [ "futures-task", "pin-project-lite", "pin-utils", -] - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", + "slab", ] [[package]] @@ -674,40 +396,6 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" -[[package]] -name = "h2" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.9" @@ -716,9 +404,9 @@ checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "http" -version = "0.2.12" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes", "fnv", @@ -726,10 +414,33 @@ dependencies = [ ] [[package]] -name = "http-range" -version = "0.1.5" +name = "http-body" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "http-range-header" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08a397c49fec283e3d6211adbe480be95aae5f304cfb923e9970e08956d5168a" [[package]] name = "httparse" @@ -744,10 +455,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] -name = "humantime" -version = "2.1.0" +name = "hyper" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", +] + +[[package]] +name = "hyper-util" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "tokio", +] [[package]] name = "idna" @@ -760,19 +499,13 @@ dependencies = [ ] [[package]] -name = "impl-more" -version = "0.1.6" +name = "iri-string" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206ca75c9c03ba3d4ace2460e57b189f39f43de612c2f85836e65c929701bb2d" - -[[package]] -name = "indexmap" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" +checksum = "7f5f6c2df22c009ac44f6f1499308e7a3ac7ba42cd2378475cc691510e1eef1b" dependencies = [ - "equivalent", - "hashbrown", + "memchr", + "serde", ] [[package]] @@ -799,12 +532,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "language-tags" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" - [[package]] name = "lazy_static" version = "1.5.0" @@ -823,23 +550,6 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" -[[package]] -name = "local-channel" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6cbc85e69b8df4b8bb8b89ec634e7189099cea8927a276b7384ce5488e53ec8" -dependencies = [ - "futures-core", - "futures-sink", - "local-waker", -] - -[[package]] -name = "local-waker" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d873d7c67ce09b42110d801813efbc9364414e356be9935700d368351657487" - [[package]] name = "lock_api" version = "0.4.12" @@ -856,6 +566,12 @@ version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + [[package]] name = "memchr" version = "2.7.4" @@ -902,9 +618,8 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", - "log", "wasi", "windows-sys 0.52.0", ] @@ -936,12 +651,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-conv" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" - [[package]] name = "num-integer" version = "0.1.46" @@ -1042,18 +751,32 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "paste" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" - [[package]] name = "percent-encoding" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "pin-project-lite" version = "0.2.14" @@ -1072,21 +795,6 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - -[[package]] -name = "ppv-lite86" -version = "0.2.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" -dependencies = [ - "zerocopy", -] - [[package]] name = "proc-macro2" version = "1.0.86" @@ -1105,36 +813,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - [[package]] name = "redis" version = "0.25.4" @@ -1160,41 +838,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "regex" -version = "1.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-lite" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" - -[[package]] -name = "regex-syntax" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" - [[package]] name = "ring" version = "0.16.20" @@ -1216,15 +859,6 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - [[package]] name = "rustix" version = "0.38.34" @@ -1238,6 +872,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustversion" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" + [[package]] name = "ryu" version = "1.0.18" @@ -1282,12 +922,6 @@ dependencies = [ "libc", ] -[[package]] -name = "semver" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" - [[package]] name = "serde" version = "1.0.208" @@ -1320,6 +954,16 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_path_to_error" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" +dependencies = [ + "itoa", + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -1332,17 +976,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "sha1_smol" version = "1.0.1" @@ -1406,6 +1039,18 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "tempfile" version = "3.12.0" @@ -1419,46 +1064,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "time" -version = "0.3.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" -dependencies = [ - "deranged", - "itoa", - "num-conv", - "powerfmt", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" - -[[package]] -name = "time-macros" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" -dependencies = [ - "num-conv", - "time-core", -] - [[package]] name = "tinyvec" version = "1.8.0" @@ -1488,9 +1093,21 @@ dependencies = [ "pin-project-lite", "signal-hook-registry", "socket2", + "tokio-macros", "windows-sys 0.52.0", ] +[[package]] +name = "tokio-macros" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tokio-util" version = "0.7.11" @@ -1504,6 +1121,75 @@ dependencies = [ "tokio", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36b837f86b25d7c0d7988f00a54e74739be6477f2aac6201b8f429a7569991b7" +dependencies = [ + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" +dependencies = [ + "async-compression", + "base64", + "bitflags", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "http-range-header", + "httpdate", + "iri-string", + "mime", + "mime_guess", + "percent-encoding", + "pin-project-lite", + "tokio", + "tokio-util", + "tower 0.4.13", + "tower-layer", + "tower-service", + "tracing", + "uuid", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + [[package]] name = "tracing" version = "0.1.40" @@ -1524,12 +1210,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - [[package]] name = "unicase" version = "2.7.0" @@ -1584,10 +1264,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" [[package]] -name = "v_htmlescape" -version = "0.15.8" +name = "uuid" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e8257fbc510f0a46eb602c10215901938b5c2a7d5e70fc11483b1d3c9b5b18c" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +dependencies = [ + "getrandom", +] [[package]] name = "vcpkg" @@ -1688,15 +1371,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" -dependencies = [ - "windows-sys 0.59.0", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -1785,27 +1459,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "byteorder", - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "zstd" version = "0.13.2" diff --git a/packages/backend/Cargo.toml b/packages/backend/Cargo.toml index e0760d8..746aafe 100644 --- a/packages/backend/Cargo.toml +++ b/packages/backend/Cargo.toml @@ -10,16 +10,18 @@ name = "cryptgeon" path = "src/main.rs" [dependencies] -actix-web = "4" -actix-files = "0.6" -serde = { version = "1.0", features = ["derive"] } +# Core +axum = "0.7.5" +serde = { version = "1.0.208", features = ["derive"] } +tokio = { version = "1.39.3", features = ["full"] } +tower = "0.5.0" +tower-http = { version = "0.5.2", features = ["full"] } +redis = { version = "0.25.2", features = ["tls-native-tls"] } + +# Utility serde_json = "1" lazy_static = "1" ring = "0.16" bs62 = "0.1" byte-unit = "4" dotenv = "0.15" -mime = "0.3" -env_logger = "0.9" -log = "0.4" -redis = { version = "0.25.2", features = ["tls-native-tls"] } diff --git a/packages/backend/package.json b/packages/backend/package.json index bcb0667..c75db96 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -4,7 +4,7 @@ "scripts": { "dev": "cargo watch -x 'run --bin cryptgeon'", "build": "cargo build --release", - "test:server": "SIZE_LIMIT=10MiB LISTEN_ADDR=0.0.0.0:1234 cargo run", + "test:server": "SIZE_LIMIT=10MiB LISTEN_ADDR=0.0.0.0:3000 cargo run", "test:prepare": "cargo build" } } diff --git a/packages/backend/src/api.rs b/packages/backend/src/api.rs deleted file mode 100644 index a29b256..0000000 --- a/packages/backend/src/api.rs +++ /dev/null @@ -1,14 +0,0 @@ -use actix_web::web; - -use crate::health; -use crate::note; -use crate::status; - -pub fn init(cfg: &mut web::ServiceConfig) { - cfg.service( - web::scope("/api") - .service(note::init()) - .service(status::init()) - .service(health::init()), - ); -} diff --git a/packages/backend/src/client.rs b/packages/backend/src/client.rs deleted file mode 100644 index f89501f..0000000 --- a/packages/backend/src/client.rs +++ /dev/null @@ -1,17 +0,0 @@ -use actix_files::{Files, NamedFile}; -use actix_web::{web, Result}; - -use crate::config; - -pub fn init(cfg: &mut web::ServiceConfig) { - cfg.service( - Files::new("/", config::FRONTEND_PATH.to_string()) - .index_file("index.html") - .use_etag(true), - ); -} - -pub async fn index() -> Result { - let index = format!("{}{}", config::FRONTEND_PATH.to_string(), "/index.html"); - Ok(NamedFile::open(index)?) -} diff --git a/packages/backend/src/health/mod.rs b/packages/backend/src/health/mod.rs index f5208e5..e54f8ac 100644 --- a/packages/backend/src/health/mod.rs +++ b/packages/backend/src/health/mod.rs @@ -1,3 +1,10 @@ -mod routes; +use crate::store; +use axum::http::StatusCode; -pub use routes::*; +pub async fn report_health() -> (StatusCode,) { + if store::can_reach_redis() { + return (StatusCode::OK,); + } else { + return (StatusCode::SERVICE_UNAVAILABLE,); + } +} diff --git a/packages/backend/src/health/routes.rs b/packages/backend/src/health/routes.rs deleted file mode 100644 index 5e985cc..0000000 --- a/packages/backend/src/health/routes.rs +++ /dev/null @@ -1,16 +0,0 @@ -use actix_web::{get, web, HttpResponse, Responder, Scope}; - -use crate::store; - -#[get("/")] -async fn get_live() -> impl Responder { - if store::can_reach_redis() { - return HttpResponse::Ok(); - } else { - return HttpResponse::ServiceUnavailable(); - } -} - -pub fn init() -> Scope { - web::scope("/live").service(get_live) -} diff --git a/packages/backend/src/main.rs b/packages/backend/src/main.rs index 54c79e7..65ffd7f 100644 --- a/packages/backend/src/main.rs +++ b/packages/backend/src/main.rs @@ -1,44 +1,70 @@ -use actix_web::{ - middleware::{self, Logger}, - web::{self}, - App, HttpServer, +use axum::{ + extract::Request, + routing::{delete, get, post}, + Router, ServiceExt, }; use dotenv::dotenv; -use log::error; +use tower::Layer; +use tower_http::{ + compression::CompressionLayer, + limit::RequestBodyLimitLayer, + normalize_path::NormalizePathLayer, + services::{ServeDir, ServeFile}, +}; #[macro_use] extern crate lazy_static; -mod api; -mod client; mod config; mod health; mod note; -mod size; mod status; mod store; -#[actix_web::main] -async fn main() -> std::io::Result<()> { +#[tokio::main] +async fn main() { dotenv().ok(); - env_logger::init_from_env(env_logger::Env::new().default_filter_or(config::VERBOSITY.as_str())); if !store::can_reach_redis() { - error!("cannot reach redis"); + println!("cannot reach redis"); panic!("canont reach redis"); } - return HttpServer::new(|| { - App::new() - .wrap(Logger::new("\"%r\" %s %b %T")) - .wrap(middleware::Compress::default()) - .wrap(middleware::DefaultHeaders::default()) - .configure(size::init) - .configure(api::init) - .configure(client::init) - .default_service(web::to(client::index)) - }) - .bind(config::LISTEN_ADDR.to_string())? - .run() - .await; + let notes_routes = Router::new() + .route("/", post(note::create)) + .route("/:id", delete(note::delete)) + .route("/:id", get(note::preview)); + let health_routes = Router::new().route("/live", get(health::report_health)); + let status_routes = Router::new().route("/status", get(status::get_status)); + let api_routes = Router::new() + .nest("/notes", notes_routes) + .nest("/", health_routes) + .nest("/", status_routes); + + let index = format!("{}{}", config::FRONTEND_PATH.to_string(), "/index.html"); + let serve_dir = + ServeDir::new(config::FRONTEND_PATH.to_string()).not_found_service(ServeFile::new(index)); + let app = Router::new() + .nest("/api", api_routes) + .fallback_service(serve_dir) + .layer( + CompressionLayer::new() + .br(true) + .deflate(true) + .gzip(true) + .zstd(true), + ) + .layer(RequestBodyLimitLayer::new(*config::LIMIT)); + + let app = NormalizePathLayer::trim_trailing_slash().layer(app); + + let listener = tokio::net::TcpListener::bind(config::LISTEN_ADDR.to_string()) + .await + .unwrap(); + println!("listening on {}", listener.local_addr().unwrap()); + println!("Config {}", *config::LIMIT); + axum::serve(listener, ServiceExt::::into_make_service(app)) + // axum::serve(listener, app) + .await + .unwrap(); } diff --git a/packages/backend/src/note/model.rs b/packages/backend/src/note/model.rs index 61271bd..8200b19 100644 --- a/packages/backend/src/note/model.rs +++ b/packages/backend/src/note/model.rs @@ -12,12 +12,12 @@ pub struct Note { pub expiration: Option, } -#[derive(Serialize, Deserialize, Clone)] +#[derive(Serialize)] pub struct NoteInfo { pub meta: String, } -#[derive(Serialize, Deserialize, Clone)] +#[derive(Serialize)] pub struct NotePublic { pub meta: String, pub contents: String, diff --git a/packages/backend/src/note/routes.rs b/packages/backend/src/note/routes.rs index b6a9c10..ee290dc 100644 --- a/packages/backend/src/note/routes.rs +++ b/packages/backend/src/note/routes.rs @@ -1,11 +1,16 @@ -use actix_web::{delete, get, post, web, HttpResponse, Responder, Scope}; +use axum::extract::Path; +use axum::http::StatusCode; +use axum::response::{IntoResponse, Response}; +use axum::Json; use serde::{Deserialize, Serialize}; use std::time::SystemTime; use crate::config; -use crate::note::{generate_id, Note, NoteInfo, NotePublic}; +use crate::note::{generate_id, Note, NoteInfo}; use crate::store; +use super::NotePublic; + pub fn now() -> u32 { SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH) @@ -13,20 +18,18 @@ pub fn now() -> u32 { .as_secs() as u32 } -#[derive(Serialize, Deserialize)] -struct NotePath { +#[derive(Deserialize)] +pub struct OneNoteParams { id: String, } -#[get("/{id}")] -async fn one(path: web::Path) -> impl Responder { - let p = path.into_inner(); - let note = store::get(&p.id); +pub async fn preview(Path(OneNoteParams { id }): Path) -> Response { + let note = store::get(&id); match note { - Ok(Some(n)) => HttpResponse::Ok().json(NoteInfo { meta: n.meta }), - Ok(None) => HttpResponse::NotFound().finish(), - Err(e) => HttpResponse::InternalServerError().body(e.to_string()), + Ok(Some(n)) => (StatusCode::OK, Json(NoteInfo { meta: n.meta })).into_response(), + Ok(None) => (StatusCode::NOT_FOUND).into_response(), + Err(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(), } } @@ -35,13 +38,16 @@ struct CreateResponse { id: String, } -#[post("/")] -async fn create(note: web::Json) -> impl Responder { - let mut n = note.into_inner(); +pub async fn create(Json(mut n): Json) -> Response { + // let mut n = note.into_inner(); let id = generate_id(); - let bad_req = HttpResponse::BadRequest().finish(); + // let bad_req = HttpResponse::BadRequest().finish(); if n.views == None && n.expiration == None { - return bad_req; + return ( + StatusCode::BAD_REQUEST, + "At least views or expiration must be set", + ) + .into_response(); } if !*config::ALLOW_ADVANCED { n.views = Some(1); @@ -50,7 +56,7 @@ async fn create(note: web::Json) -> impl Responder { match n.views { Some(v) => { if v > *config::MAX_VIEWS || v < 1 { - return bad_req; + return (StatusCode::BAD_REQUEST, "Invalid views").into_response(); } n.expiration = None; // views overrides expiration } @@ -58,8 +64,8 @@ async fn create(note: web::Json) -> impl Responder { } match n.expiration { Some(e) => { - if e > *config::MAX_EXPIRATION { - return bad_req; + if e > *config::MAX_EXPIRATION || e < 1 { + return (StatusCode::BAD_REQUEST, "Invalid expiration").into_response(); } let expiration = now() + (e * 60); n.expiration = Some(expiration); @@ -67,38 +73,40 @@ async fn create(note: web::Json) -> impl Responder { _ => {} } match store::set(&id.clone(), &n.clone()) { - Ok(_) => return HttpResponse::Ok().json(CreateResponse { id: id }), - Err(e) => return HttpResponse::InternalServerError().body(e.to_string()), + Ok(_) => (StatusCode::OK, Json(CreateResponse { id })).into_response(), + Err(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(), } } -#[delete("/{id}")] -async fn delete(path: web::Path) -> impl Responder { - let p = path.into_inner(); - let note = store::get(&p.id); +pub async fn delete(Path(OneNoteParams { id }): Path) -> Response { + let note = store::get(&id); match note { - Err(e) => HttpResponse::InternalServerError().body(e.to_string()), - Ok(None) => return HttpResponse::NotFound().finish(), + // Err(e) => HttpResponse::InternalServerError().body(e.to_string()), + // Ok(None) => return HttpResponse::NotFound().finish(), + Err(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(), + Ok(None) => (StatusCode::NOT_FOUND).into_response(), Ok(Some(note)) => { let mut changed = note.clone(); if changed.views == None && changed.expiration == None { - return HttpResponse::BadRequest().finish(); + return (StatusCode::BAD_REQUEST).into_response(); } match changed.views { Some(v) => { changed.views = Some(v - 1); - let id = p.id.clone(); + let id = id.clone(); if v <= 1 { match store::del(&id) { Err(e) => { - return HttpResponse::InternalServerError().body(e.to_string()) + return (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()) + .into_response(); } _ => {} } } else { match store::set(&id, &changed.clone()) { Err(e) => { - return HttpResponse::InternalServerError().body(e.to_string()) + return (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()) + .into_response(); } _ => {} } @@ -111,33 +119,26 @@ async fn delete(path: web::Path) -> impl Responder { match changed.expiration { Some(e) => { if e < n { - match store::del(&p.id.clone()) { - Ok(_) => return HttpResponse::BadRequest().finish(), + match store::del(&id.clone()) { + Ok(_) => return (StatusCode::BAD_REQUEST).into_response(), Err(e) => { - return HttpResponse::InternalServerError().body(e.to_string()) + return (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()) + .into_response() } } } } _ => {} } - return HttpResponse::Ok().json(NotePublic { - contents: changed.contents, - meta: changed.meta, - }); + + return ( + StatusCode::OK, + Json(NotePublic { + contents: changed.contents, + meta: changed.meta, + }), + ) + .into_response(); } } } - -#[derive(Serialize, Deserialize)] -struct Status { - version: String, - max_size: usize, -} - -pub fn init() -> Scope { - web::scope("/notes") - .service(one) - .service(create) - .service(delete) -} diff --git a/packages/backend/src/size.rs b/packages/backend/src/size.rs deleted file mode 100644 index 023da85..0000000 --- a/packages/backend/src/size.rs +++ /dev/null @@ -1,12 +0,0 @@ -use crate::config; -use actix_web::web; -use mime; - -pub fn init(cfg: &mut web::ServiceConfig) { - let json = web::JsonConfig::default().limit(*config::LIMIT); - let plain = web::PayloadConfig::default() - .limit(*config::LIMIT) - .mimetype(mime::STAR_STAR); - // cfg.app_data(plain); - cfg.app_data(json).app_data(plain); -} diff --git a/packages/backend/src/status/mod.rs b/packages/backend/src/status/mod.rs index 13bc006..f5e7e18 100644 --- a/packages/backend/src/status/mod.rs +++ b/packages/backend/src/status/mod.rs @@ -1,5 +1,40 @@ -mod model; -mod routes; +use crate::config; +use axum::http::StatusCode; +use axum::Json; +use serde::Serialize; -pub use model::*; -pub use routes::*; +#[derive(Serialize)] +pub struct Status { + // General + pub version: String, + // Config + pub max_size: u32, + pub max_views: u32, + 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 async fn get_status() -> (StatusCode, Json) { + let status = Status { + version: config::VERSION.to_string(), + max_size: *config::LIMIT as u32, + max_views: *config::MAX_VIEWS, + max_expiration: *config::MAX_EXPIRATION, + allow_advanced: *config::ALLOW_ADVANCED, + allow_files: *config::ALLOW_FILES, + theme_new_note_notice: *config::THEME_NEW_NOTE_NOTICE, + theme_image: config::THEME_IMAGE.to_string(), + theme_text: config::THEME_TEXT.to_string(), + theme_page_title: config::THEME_PAGE_TITLE.to_string(), + theme_favicon: config::THEME_FAVICON.to_string(), + }; + + (StatusCode::OK, Json(status)) +} diff --git a/packages/backend/src/status/model.rs b/packages/backend/src/status/model.rs deleted file mode 100644 index 6e77771..0000000 --- a/packages/backend/src/status/model.rs +++ /dev/null @@ -1,19 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize)] -pub struct Status { - // General - pub version: String, - // Config - pub max_size: u32, - pub max_views: u32, - 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, -} diff --git a/packages/backend/src/status/routes.rs b/packages/backend/src/status/routes.rs deleted file mode 100644 index 9f767a6..0000000 --- a/packages/backend/src/status/routes.rs +++ /dev/null @@ -1,25 +0,0 @@ -use actix_web::{get, web, HttpResponse, Responder, Scope}; - -use crate::config; -use crate::status::Status; - -#[get("/")] -async fn get_status() -> impl Responder { - return HttpResponse::Ok().json(Status { - version: config::VERSION.to_string(), - max_size: *config::LIMIT as u32, - max_views: *config::MAX_VIEWS, - max_expiration: *config::MAX_EXPIRATION, - allow_advanced: *config::ALLOW_ADVANCED, - allow_files: *config::ALLOW_FILES, - theme_new_note_notice: *config::THEME_NEW_NOTE_NOTICE, - theme_image: config::THEME_IMAGE.to_string(), - theme_text: config::THEME_TEXT.to_string(), - theme_page_title: config::THEME_PAGE_TITLE.to_string(), - theme_favicon: config::THEME_FAVICON.to_string(), - }); -} - -pub fn init() -> Scope { - web::scope("/status").service(get_status) -} From f9962c76c15e9a3cdee478293d7eacbaf8d3b61f Mon Sep 17 00:00:00 2001 From: Niccolo Borgioli Date: Fri, 23 Aug 2024 14:27:52 +0200 Subject: [PATCH 03/25] enable to big --- test/web/file/too-big.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/web/file/too-big.spec.ts b/test/web/file/too-big.spec.ts index 03ceec6..a441ea1 100644 --- a/test/web/file/too-big.spec.ts +++ b/test/web/file/too-big.spec.ts @@ -3,7 +3,7 @@ import { createNote } from '../../utils' import { Files } from '../../files' test.describe('@web', () => { - test.skip('to big zip', async ({ page }) => { + test('to big zip', async ({ page }) => { const files = [Files.Zip] const link = await createNote(page, { files, error: 'note is to big' }) }) From c3794fa2b662096b4788e217138737a6eb0148de Mon Sep 17 00:00:00 2001 From: Niccolo Borgioli Date: Fri, 23 Aug 2024 14:27:59 +0200 Subject: [PATCH 04/25] port 3000 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9fb2666..52e975e 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,7 @@ Running `pnpm run dev` in the root folder will start the following things: - client - cli -You can see the app under [localhost:1234](http://localhost:1234). +You can see the app under [localhost:3000](http://localhost:3000). > There is a Postman collection with some example requests [available in the repo](./Cryptgeon.postman_collection.json) From a0a99cd3cc1455197d9b8f5c8bdd593ba052f8aa Mon Sep 17 00:00:00 2001 From: Niccolo Borgioli Date: Sun, 25 Aug 2024 22:18:31 +0200 Subject: [PATCH 05/25] cleanup status variable --- packages/backend/src/config.rs | 8 ++++---- packages/backend/src/status/mod.rs | 2 +- packages/shared/src/api.ts | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/config.rs b/packages/backend/src/config.rs index e86e4da..1d86cd0 100644 --- a/packages/backend/src/config.rs +++ b/packages/backend/src/config.rs @@ -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(); } diff --git a/packages/backend/src/status/mod.rs b/packages/backend/src/status/mod.rs index f5e7e18..d02b092 100644 --- a/packages/backend/src/status/mod.rs +++ b/packages/backend/src/status/mod.rs @@ -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) { diff --git a/packages/shared/src/api.ts b/packages/shared/src/api.ts index bb89b69..e210f40 100644 --- a/packages/shared/src/api.ts +++ b/packages/shared/src/api.ts @@ -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() { From bd5acca97a1fe7a698032362626aea5c648e3a7e Mon Sep 17 00:00:00 2001 From: Niccolo Borgioli Date: Sun, 25 Aug 2024 22:19:41 +0200 Subject: [PATCH 06/25] use axum body limit --- packages/backend/src/main.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/main.rs b/packages/backend/src/main.rs index 65ffd7f..c74e105 100644 --- a/packages/backend/src/main.rs +++ b/packages/backend/src/main.rs @@ -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::::into_make_service(app)) - // axum::serve(listener, app) .await .unwrap(); } From 724d0709d33e0803c6ae71015d66f4c5573d3906 Mon Sep 17 00:00:00 2001 From: Niccolo Borgioli Date: Sun, 25 Aug 2024 22:20:29 +0200 Subject: [PATCH 07/25] .env.dev --- .dev.env => .env.dev | 0 docker-compose.dev.yaml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .dev.env => .env.dev (100%) diff --git a/.dev.env b/.env.dev similarity index 100% rename from .dev.env rename to .env.dev diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml index e0ab06d..5edebe8 100644 --- a/docker-compose.dev.yaml +++ b/docker-compose.dev.yaml @@ -9,7 +9,7 @@ services: app: build: . - env_file: .dev.env + env_file: .env.dev depends_on: - redis restart: unless-stopped From 199755d18e12b7edc35f7d5f62f6b9c70c59e8fa Mon Sep 17 00:00:00 2001 From: Niccolo Borgioli Date: Sun, 25 Aug 2024 22:20:46 +0200 Subject: [PATCH 08/25] timeout --- playwright.config.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index da301aa..039dbc7 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -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/] }, ], } From eaca1a981de231e80162b6d5654b3cfebfd67db6 Mon Sep 17 00:00:00 2001 From: Niccolo Borgioli Date: Sun, 25 Aug 2024 22:21:45 +0200 Subject: [PATCH 09/25] cleanup --- test/cli/file/simple.spec.ts | 7 ++++--- test/cli/text/simple.spec.ts | 4 ++-- test/web/file/too-big.spec.ts | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/test/cli/file/simple.spec.ts b/test/cli/file/simple.spec.ts index ac49191..2acf339 100644 --- a/test/cli/file/simple.spec.ts +++ b/test/cli/file/simple.spec.ts @@ -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) diff --git a/test/cli/text/simple.spec.ts b/test/cli/text/simple.spec.ts index 6286b4b..8e7d90f 100644 --- a/test/cli/text/simple.spec.ts +++ b/test/cli/text/simple.spec.ts @@ -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) diff --git a/test/web/file/too-big.spec.ts b/test/web/file/too-big.spec.ts index a441ea1..f677d55 100644 --- a/test/web/file/too-big.spec.ts +++ b/test/web/file/too-big.spec.ts @@ -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' }) }) }) From ea58d89f98a2d6a3ecdce6cc8c5867016af66a56 Mon Sep 17 00:00:00 2001 From: Niccolo Borgioli Date: Sun, 25 Aug 2024 22:22:13 +0200 Subject: [PATCH 10/25] cleanup --- test/files.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/test/files.ts b/test/files.ts index 4ef84e0..bcf392b 100644 --- a/test/files.ts +++ b/test/files.ts @@ -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', From dfa2401eea6f728c063e0ca8f6b28167cbbce1bb Mon Sep 17 00:00:00 2001 From: Niccolo Borgioli Date: Sun, 25 Aug 2024 22:22:45 +0200 Subject: [PATCH 11/25] aria check --- packages/frontend/src/lib/ui/Icon.svelte | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/frontend/src/lib/ui/Icon.svelte b/packages/frontend/src/lib/ui/Icon.svelte index cfad495..a2cbba4 100644 --- a/packages/frontend/src/lib/ui/Icon.svelte +++ b/packages/frontend/src/lib/ui/Icon.svelte @@ -18,19 +18,19 @@ export let icon: keyof typeof map -
+
+