Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dep: 🌊 Fetch upstream #26

Merged
merged 22 commits into from
Mar 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
83f9f88
♻️ refactor: Move Docker to its own branch
mellowmarshe Mar 18, 2022
84cb213
🐛 fix: Remove my testing nginx config
mellowmarshe Mar 18, 2022
557e4f1
sorry testing :(
mellowmarshe Mar 18, 2022
bd844c6
Update README.md
ThatOneCalculator Mar 19, 2022
783dabb
Close 🐢 Split TS files #21
ThatOneCalculator Mar 19, 2022
58a15da
Merge branch 'main' of https://github.com/Domterion/zer0bin
ThatOneCalculator Mar 19, 2022
456a92e
style: :art: Formatting
ThatOneCalculator Mar 19, 2022
8f8b234
docs: 📝 Remove "Docker coming soon" 😔🐋
ThatOneCalculator Mar 19, 2022
bd238e3
docs: 📝 Configuration and benchmarks now details
ThatOneCalculator Mar 19, 2022
3e13591
refactor: :art: Formatting, remove global.content
ThatOneCalculator Mar 19, 2022
18fb461
Merge branch 'main' of https://github.com/Domterion/zer0bin
ThatOneCalculator Mar 19, 2022
a20a2df
docs: 📝 Add SVG
ThatOneCalculator Mar 19, 2022
57253f0
docs: 📝 Move Prettier
ThatOneCalculator Mar 19, 2022
345d461
docs: 📝 Add comment to psql line
ThatOneCalculator Mar 19, 2022
8822872
feat: :zap: Yarn
ThatOneCalculator Mar 19, 2022
a625235
docs: 📝 Omit cargo from deps
ThatOneCalculator Mar 19, 2022
2274efa
docs: 📝 Change Brotli emoji 🌾
ThatOneCalculator Mar 19, 2022
ed94164
egg: 🥚 Change node egg to yarn egg
ThatOneCalculator Mar 19, 2022
a5236a1
Merge pull request #25 from zer0bin-dev/yarn
ThatOneCalculator Mar 19, 2022
5a649e2
docs: 📝 😈 for FreeBSD
ThatOneCalculator Mar 19, 2022
de9ac51
docs: :memo: Add back comment
ThatOneCalculator Mar 19, 2022
a5d55af
docs: 📝 `username` -> `postgres`
ThatOneCalculator Mar 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
**/dist/
**/.parcel-cache/
**/config.json
**/package-lock.json
44 changes: 17 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Submit your public instance [here](https://github.com/Domterion/zer0bin/issues/n

### Frontend:

<a href="https://www.typescriptlang.org/"><img src="https://github.com/tandpfun/skill-icons/raw/main/icons/TypeScript.svg" height=40/></a> <a href="https://sass-lang.com/"><img src="https://github.com/tandpfun/skill-icons/raw/main/icons/Sass.svg" height=40/></a> <a href="https://pugjs.org/"><img src="https://github.com/tandpfun/skill-icons/raw/main/icons/Pug-Dark.svg" height=40/></a> <a href="https://rosepinetheme.com/"><img src="https://cdn.discordapp.com/attachments/810799100940255260/953176309444542464/RosePine.svg" height=40/></a> <a href="https://highlightjs.org/"><img src="https://cdn.discordapp.com/attachments/810799100940255260/953177926688464936/HLJS.svg" height=40/></a> <a href="https://github.com/ant-design/ant-design-icons"><img src="https://cdn.discordapp.com/attachments/810799100940255260/953181625259266059/AntIcons-Dark.svg" height=40/></a> <a href="https://github.com/idiotWu/smooth-scrollbar"><img src="https://cdn.discordapp.com/attachments/810799100940255260/953564432628322364/SmoothScrollJS.svg" height=40/></a> <a href="https://github.com/loonywizard/js-confetti"><img src="https://cdn.discordapp.com/attachments/810799100940255260/953564432896782416/JSConfetti.svg" height=40/></a> <a href="https://definitelytyped.org/"><img src="https://cdn.discordapp.com/attachments/810799100940255260/953567495321710602/DefinitelyTyped.svg" height=40/></a> <a href="https://parceljs.org/"><img src="https://user-images.githubusercontent.com/44733677/158683062-17ac3b62-cacd-4add-babb-1f74f36020d8.svg" height=40/></a> <a href="https://npmjs.org"><img src="https://cdn.discordapp.com/attachments/810799100940255260/953176309259972638/NPM.svg" height=40/></a> <a href="https://transfonter.org"><img src="https://user-images.githubusercontent.com/44733677/159066877-234f68ba-e95c-439d-b5fe-74def49dc762.svg" height=40></a>
<a href="https://www.typescriptlang.org/"><img src="https://github.com/tandpfun/skill-icons/raw/main/icons/TypeScript.svg" height=40/></a> <a href="https://sass-lang.com/"><img src="https://github.com/tandpfun/skill-icons/raw/main/icons/Sass.svg" height=40/></a> <a href="https://pugjs.org/"><img src="https://github.com/tandpfun/skill-icons/raw/main/icons/Pug-Dark.svg" height=40/></a> <a href="https://rosepinetheme.com/"><img src="https://cdn.discordapp.com/attachments/810799100940255260/953176309444542464/RosePine.svg" height=40/></a> <a href="https://highlightjs.org/"><img src="https://cdn.discordapp.com/attachments/810799100940255260/953177926688464936/HLJS.svg" height=40/></a> <a href="https://github.com/ant-design/ant-design-icons"><img src="https://cdn.discordapp.com/attachments/810799100940255260/953181625259266059/AntIcons-Dark.svg" height=40/></a> <a href="https://github.com/idiotWu/smooth-scrollbar"><img src="https://cdn.discordapp.com/attachments/810799100940255260/953564432628322364/SmoothScrollJS.svg" height=40/></a> <a href="https://github.com/loonywizard/js-confetti"><img src="https://cdn.discordapp.com/attachments/810799100940255260/953564432896782416/JSConfetti.svg" height=40/></a> <a href="https://definitelytyped.org/"><img src="https://cdn.discordapp.com/attachments/810799100940255260/953567495321710602/DefinitelyTyped.svg" height=40/></a> <a href="https://parceljs.org/"><img src="https://user-images.githubusercontent.com/44733677/158683062-17ac3b62-cacd-4add-babb-1f74f36020d8.svg" height=40/></a> <a href="https://yarnpkg.org"><img src="https://cdn.discordapp.com/attachments/810799100940255260/954823377493852170/Yarn.svg" height=40/></a> <a href="https://transfonter.org"><img src="https://user-images.githubusercontent.com/44733677/159066877-234f68ba-e95c-439d-b5fe-74def49dc762.svg" height=40></a>

### Backend:

Expand All @@ -56,34 +56,16 @@ Submit your public instance [here](https://github.com/Domterion/zer0bin/issues/n

### Requirements

- 🦀 Rust ≥ 1.58.0
- 🚢 Cargo ≥ 1.58.0
- 🐢 NodeJS ≥ 16.0
- 🚀 NPM ≥ 8.0.0
- 🐘 PostgreSQL ≥ 9.6
- 🦝 Nginx ≥ 1.18.0
- 🥖 [Brotli](https://github.com/google/ngx_brotli) plugin reccomended
- 📍 Domain linked to your server
- 🌄 Must have [SSL certs](https://letsencrypt.org/)
- 🐧 \*nix OS (Linux, \*BSD, etc)
- 🦀 [Rust](https://www.rust-lang.org/) ≥ 1.58.0
- 🐈 [Yarn](https://yarnpkg.com/) ≥ 1.0.0
- 🐘 [PostgreSQL](https://www.postgresql.org/) ≥ 9.6
- 🦝 [Nginx](https://www.nginx.com/) ≥ 1.18.0
- 🌾 [Brotli plugin](https://github.com/google/ngx_brotli) recommended
- 🐧 [Linux](https://kernel.org/) or 😈 [FreeBSD](https://freebsd.org/)
- 🌄 Domain with [SSL](https://letsencrypt.org/)

### Steps

<!--
1. `git clone https://github.com/zer0bin-dev/zer0bin && cd zer0bin`
2. Edit `example.nginx` as appropriate, then `mv example.nginx yourdomain.tld && for i in /etc/nginx/sites-available/ /etc/nginx/sites-enabled/; do cp ./yourdomain.tld $i; done && systemctl nginx restart`
3. `psql -f schema.sql -U postgres zer0bin`
4. `cd frontend`
5. `cp config.example.json config.json` and edit as appropriate
6. `npm i && npm run build`
7. `cd ../backend`
8. `cp config.example.json config.json` and edit as appropriate
9. `cargo build --release`
10. `./target/release/backend` (preferably in a tmux session or as a service)
-->

🐋 Docker is coming soon:tm:

Please run each command one at a time!

```bash
Expand All @@ -97,7 +79,7 @@ systemctl nginx restart # Or whichever process manager you use
cd frontend
cp config.example.json config.json
$EDITOR config.json # Edit as appropriate
npm i && npm run build
yarn && yarn build
cd ../backend
psql -f schema.sql -U postgres zer0bin
cp config.example.json config.json
Expand All @@ -108,6 +90,8 @@ cargo build --release

### Configuration

<details>

| Key | Values | Description |
| ------------------------------------------ | ------------------------ | ------------------------------------------------------------------------------ |
| server.backend_host | 127.0.0.1 or 0.0.0.0 | The host to run the backend on |
Expand All @@ -121,10 +105,14 @@ cargo build --release
| logging.on_post_paste | true or false | Log on new paste is made |
| logging.on_get_paste | true or false | Log on paste get |

</details>

# Benchmarks

###### Measured with Lighthouse and Firefox Network Performance Analysis

<details>

### Homepage

![image](https://user-images.githubusercontent.com/44733677/158523056-2d1b4a38-76f8-413f-b4df-5fd3d920dc66.png)
Expand All @@ -135,6 +123,8 @@ cargo build --release
![image](https://user-images.githubusercontent.com/44733677/158522958-a226612f-3848-43be-876e-8822a4cc9907.png)
![image](https://user-images.githubusercontent.com/44733677/158523846-d79a94a5-64a5-475a-b481-e72141b47cf6.png)

</details>

# Contributing

See [CONTRIBUTING.md](./CONTRIBUTING.md)
21 changes: 0 additions & 21 deletions backend/Dockerfile

This file was deleted.

4 changes: 3 additions & 1 deletion backend/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ CREATE TABLE IF NOT EXISTS pastes (
"expires_at" TIMESTAMP WITHOUT TIME ZONE,
"created_at" TIMESTAMP WITHOUT TIME ZONE DEFAULT(NOW() AT TIME ZONE 'utc')
);

CREATE OR REPLACE FUNCTION deleteExpiredPastes() RETURNS trigger AS $pastes_expire$ BEGIN
DELETE FROM pastes
WHERE "expires_at" IS NOT NULL
AND "expires_at" < now() AT TIME ZONE 'utc';
RETURN NEW;
END;
$pastes_expire$ LANGUAGE plpgsql;

CREATE TRIGGER checkPastes BEFORE
INSERT
OR
UPDATE ON pastes FOR STATEMENT EXECUTE PROCEDURE deleteExpiredPastes();
UPDATE ON pastes FOR STATEMENT EXECUTE PROCEDURE deleteExpiredPastes();
47 changes: 0 additions & 47 deletions default.nginx

This file was deleted.

58 changes: 0 additions & 58 deletions docker-compose.yml

This file was deleted.

9 changes: 0 additions & 9 deletions frontend/Dockerfile

This file was deleted.

1 change: 1 addition & 0 deletions frontend/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ head
meta(property='twitter:description' content='🖊 Just a place to paste')
meta(property='twitter:image' content='https://raw.githubusercontent.com/zer0bin-dev/.github/main/zer0bin.png')
script(defer='' type='module' src='src/index.ts')
script(defer='' type='module' src='src/icons.ts')

ul.noselect#messages
.button-wrapper.noselect(style='position: fixed')
Expand Down
31 changes: 31 additions & 0 deletions frontend/src/icons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {
SaveOutlined,
FileAddOutlined,
GithubOutlined,
CopyOutlined,
} from "@ant-design/icons-svg"
import { renderIconDefinitionToSVGElement } from "@ant-design/icons-svg/es/helpers"

const saveButton = <HTMLButtonElement>document.getElementById("save-button")
const newButton = <HTMLButtonElement>document.getElementById("new-button")
const copyButton = <HTMLButtonElement>document.getElementById("copy-button")
const githubButton = <HTMLButtonElement>document.getElementById("github-button")

const extraSVGAttrs = {
width: "1em",
height: "1em",
fill: "currentColor",
}

saveButton.innerHTML += renderIconDefinitionToSVGElement(SaveOutlined, {
extraSVGAttrs: extraSVGAttrs,
})
newButton.innerHTML += renderIconDefinitionToSVGElement(FileAddOutlined, {
extraSVGAttrs: extraSVGAttrs,
})
copyButton.innerHTML += renderIconDefinitionToSVGElement(CopyOutlined, {
extraSVGAttrs: extraSVGAttrs,
})
githubButton.innerHTML += renderIconDefinitionToSVGElement(GithubOutlined, {
extraSVGAttrs: extraSVGAttrs,
})
Loading