From 9dfd6aa77518b3a1e6bfd926a3b7719c32a8c97f Mon Sep 17 00:00:00 2001 From: kartofen Date: Mon, 24 Oct 2022 23:19:33 +0300 Subject: use the new api --- README.md | 23 ++--- docker-compose.yaml | 18 ++++ package-lock.json | 29 +----- package.json | 4 +- run.sh | 11 --- src/components/Form.astro | 16 ++-- src/components/Post.astro | 9 +- src/components/Thread.astro | 25 +++--- src/lib/api.ts | 17 ++-- src/lib/image.ts | 42 +++------ src/lib/thread.ts | 169 +++++++++++++++-------------------- src/lib/util.ts | 27 ++---- src/models/Thread.ts | 26 +++--- src/pages/board/[board].astro | 2 - src/pages/board/[board]/[tid].astro | 4 +- src/pages/create/[board].astro | 4 +- src/pages/create/[board]/[tid].astro | 2 +- src/pages/create/comment.ts | 14 ++- src/pages/create/thread.ts | 14 ++- src/styles/thread.css | 3 + 20 files changed, 186 insertions(+), 273 deletions(-) create mode 100644 docker-compose.yaml delete mode 100755 run.sh diff --git a/README.md b/README.md index 375e724..975962f 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,15 @@ ### Scale -This is scale webapp made using astro, its faster and better, because i know what i am doing this time. Its just better. +This the scale project. This is the frotend of a simple image board. +You can find the API [here](https://git.batnako.net/scale-api.git/). -### Build +### Build and Run -To build and run see `run.sh`. +For development I use: `NODE_TLS_REJECT_UNAUTHORIZED=0 DEV=1 npm run dev` +To delpoy it with docker: `docker-compose up scale` -For deploying only the `dist/` directory (genereted by `npm run build`) -is needed and the 'server.mjs' file. -Using the nodejs command in `run.sh`. +### What can it do? -Note: When running with node the image saving wont work properly -because of different directories with images. - -### What can it do - -It can do whatever the -[scale app made with svelte](https://gitlab.com/scale-project/scale) -can, but faster and better, for info about the project see its readme. +You can post images and text into threads and comments, and quote other people. +It is a image board, what did you expect? +It uses Astro and NodeJS for server-side rendering. diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..046eb60 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,18 @@ +version: "3.4" +services: + scale: + image: "node:latest" + container_name: scale + user: "node" + working_dir: /home/node/app + environment: + - NODE_ENV=production + volumes: + - ./:/home/node/app + ports: + - "3000:3000" + entrypoint: ["/bin/sh","-c"] + command: + - | + npm run build + node server.mjs diff --git a/package-lock.json b/package-lock.json index b58cbe8..37dd482 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,12 +10,10 @@ "dependencies": { "@astrojs/node": "^1.0.0", "express": "^4.18.1", - "js-sha256": "^0.9.0", "uuid": "^8.3.2" }, "devDependencies": { - "astro": "^1.0.8", - "svelte": "^3.49.0" + "astro": "^1.0.8" } }, "node_modules/@ampproject/remapping": { @@ -2978,11 +2976,6 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, - "node_modules/js-sha256": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", - "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==" - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -5520,15 +5513,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/svelte": { - "version": "3.49.0", - "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.49.0.tgz", - "integrity": "sha512-+lmjic1pApJWDfPCpUUTc1m8azDqYCG1JN9YEngrx/hUyIcFJo6VZhj0A1Ai0wqoHcEIuQy+e9tk+4uDgdtsFA==", - "dev": true, - "engines": { - "node": ">= 8" - } - }, "node_modules/to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", @@ -8395,11 +8379,6 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, - "js-sha256": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", - "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==" - }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -10120,12 +10099,6 @@ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true }, - "svelte": { - "version": "3.49.0", - "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.49.0.tgz", - "integrity": "sha512-+lmjic1pApJWDfPCpUUTc1m8azDqYCG1JN9YEngrx/hUyIcFJo6VZhj0A1Ai0wqoHcEIuQy+e9tk+4uDgdtsFA==", - "dev": true - }, "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", diff --git a/package.json b/package.json index facbacf..890f63d 100644 --- a/package.json +++ b/package.json @@ -10,13 +10,11 @@ "astro": "astro" }, "devDependencies": { - "astro": "^1.0.8", - "svelte": "^3.49.0" + "astro": "^1.0.8" }, "dependencies": { "@astrojs/node": "^1.0.0", "express": "^4.18.1", - "js-sha256": "^0.9.0", "uuid": "^8.3.2" } } diff --git a/run.sh b/run.sh deleted file mode 100755 index 4a285e9..0000000 --- a/run.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -cd ${0%/*} # go to project root -set -xe - -# development -NODE_TLS_REJECT_UNAUTHORIZED=0 npm run dev -- --host - -# deploy -# npm run build -# NODE_TLS_REJECT_UNAUTHORIZED=0 node server.mjs diff --git a/src/components/Form.astro b/src/components/Form.astro index 540a4d4..93192a0 100644 --- a/src/components/Form.astro +++ b/src/components/Form.astro @@ -1,20 +1,17 @@ --- -import { sha256 } from 'js-sha256'; - export interface Props { board: string; tid?: string } const { board, tid } = Astro.props; -const iphash = sha256(Astro.clientAddress); ---
-