Skip to content

Commit

Permalink
Merge dev to stable (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
inetol authored Feb 15, 2024
2 parents 339e4ba + c23d583 commit 95c2e33
Show file tree
Hide file tree
Showing 47 changed files with 1,307 additions and 764 deletions.
18 changes: 12 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
# Enable HTTPS for document "url" parameter? [false]:boolean
#TLS=false

# Domain for document "url" parameter [localhost]:string
#DOMAIN=localhost

# Port for the server [4000]:number
# (Don't expose the server to the internet, use a reverse proxy)
PORT=4000
#PORT=4000

### Documentation:
# Enable documentation? [true]:boolean
# (Disabling this will also disable the playground)
DOCS_ENABLED=true
#DOCS_ENABLED=true

# Path to documentation [/docs]:string
DOCS_PATH=/docs
#DOCS_PATH=/docs

### Documentation playground:
# Enable HTTPS for domain? [true]:boolean
DOCS_PLAYGROUND_HTTPS=true
#DOCS_PLAYGROUND_TLS=true

# Domain for documentation playground [jspaste.eu]:string
DOCS_PLAYGROUND_DOMAIN=jspaste.eu
#DOCS_PLAYGROUND_DOMAIN=jspaste.eu

# Port for documentation playground [443]:number
DOCS_PLAYGROUND_PORT=443
#DOCS_PLAYGROUND_PORT=443
27 changes: 0 additions & 27 deletions .github/workflows/security-dependencies.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ permissions: read-all

jobs:
codeql:
name: 'CodeQL analysis'
name: 'CodeQL'
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
category: '/language:${{ matrix.language }}'

scoreboard:
name: 'Scorecard analysis'
name: 'Scorecard'
runs-on: ubuntu-latest
permissions:
security-events: write
Expand Down
80 changes: 80 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# TODO: Experimental feature
name: 'CI -> Test'
on:
workflow_dispatch:
push:
branches:
- dev
paths-ignore:
- '*.md'
- '.*ignore'

pull_request:
branches:
- dev
paths-ignore:
- '*.md'
- '.*ignore'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
lint:
name: 'Lint'
runs-on: ubuntu-latest
permissions:
id-token: write

steps:
- name: 'Harden Runner'
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit

- name: 'Checkout'
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: 'Setup Bun'
uses: oven-sh/setup-bun@9b21598af8d4dfc302e5a30250007de0fda92acc # v1.1.1

- name: 'Setup dependencies'
run: bun install --production --frozen-lockfile --ignore-scripts

# FIXME: Lint failing
- name: 'Run lint'
continue-on-error: true
run: bun run lint

build:
name: 'Build'
runs-on: ubuntu-latest
permissions:
id-token: write

steps:
- name: 'Harden Runner'
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit

- name: 'Checkout'
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: 'Setup Node.js'
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: current

- name: 'Setup Bun'
uses: oven-sh/setup-bun@9b21598af8d4dfc302e5a30250007de0fda92acc # v1.1.1

- name: 'Setup dependencies'
run: bun install --production --frozen-lockfile --ignore-scripts

- name: 'Run build'
run: bun run build:standalone
4 changes: 2 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**/documents/
**/node_modules/
**/src/structures/
documents/
src/structures/
.prettierrc.json
LICENSE
tsconfig.json
10 changes: 5 additions & 5 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Builder
FROM docker.io/oven/bun:1.0-slim AS builder
FROM docker.io/imbios/bun-node:1.0-21-alpine AS builder
WORKDIR /build/

COPY . ./

RUN bun install --production --frozen-lockfile --ignore-scripts
RUN bun run production:build

# Runner
FROM docker.io/oven/bun:1.0-distroless AS runner
WORKDIR /home/nonroot/
FROM gcr.io/distroless/base-nossl-debian12:nonroot AS runner

COPY --from=builder /build/. ./
COPY --from=builder /build/dist/jspaste ./

ENV DOCS_ENABLED=false

Expand All @@ -24,4 +24,4 @@ LABEL org.opencontainers.image.licenses="EUPL-1.2"
VOLUME /home/nonroot/documents
EXPOSE 4000/tcp

CMD ["./src/index.ts"]
CMD ["./jspaste"]
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Backend

The backend for [JSPaste](https://jspaste.eu), built with [Bun](https://bun.sh) and [ElysiaJS](https://elysiajs.com)
This repository contains the backend code for [JSPaste](https://jspaste.eu). It is built using [Bun](https://bun.sh) and [ElysiaJS](https://elysiajs.com)

## License

This project is licensed under the EUPL License. See the [`LICENSE`](LICENSE) file for more details.
Binary file modified bun.lockb
Binary file not shown.
6 changes: 0 additions & 6 deletions compileStructures.cmd

This file was deleted.

6 changes: 0 additions & 6 deletions compileStructures.sh

This file was deleted.

31 changes: 18 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,35 @@
"license": "EUPL-1.2",
"type": "module",
"scripts": {
"dev": "bun run start:watch",
"fix": "bun run prettier",
"build": "bun run build:structures && bun run build:structures:dts && bun run build:bundle",
"build:bundle": "bun build --target bun --format esm --minify --outdir ./dist/ ./src/index.ts",
"build:standalone": "bun build --compile --target bun --format esm --minify --outfile ./dist/jspaste ./src/index.ts",
"build:structures": "bunx pbjs -t static-module -w es6 --no-create --no-typeurl --no-service -o ./src/structures/Structures.js ./src/structures/**/*.proto",
"build:structures:dts": "bunx pbts -o ./src/structures/Structures.d.ts ./src/structures/Structures.js",
"fix": "bun run fix:prettier",
"fix:prettier": "bunx prettier . --write",
"lint": "bun run lint:tsc",
"lint:tsc": "bunx tsc --noEmit",
"prepare": "husky",
"prettier": "bunx prettier . --write",
"start": "bun ./src/index.ts",
"start:watch": "bun ./src/index.ts --watch"
"production:build": "bun run build:structures && bun run build:structures:dts && bun run build:standalone",
"start": "bun run build && bun ./dist/index.js",
"start:dev": "bun ./src/index.ts --watch"
},
"dependencies": {
"@elysiajs/cors": "^0.8.0",
"@elysiajs/swagger": "^0.8.5",
"@protobuf-ts/plugin": "^2.9.3",
"@protobuf-ts/runtime": "^2.9.3",
"elysia": "^0.8.15",
"env-var": "^7.4.1"
"@types/bun": "^1.0.5",
"elysia": "^0.8.17",
"env-var": "^7.4.1",
"protobufjs": "~7.2.6",
"protobufjs-cli": "^1.1.2",
"typescript": "~5.3.3"
},
"devDependencies": {
"@types/bun": "^1.0.4",
"husky": "^9.0.10",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"prettier-plugin-jsdoc": "^1.3.0",
"prettier-plugin-packagejson": "^2.4.10",
"typescript": "~5.3.3"
"prettier-plugin-packagejson": "^2.4.10"
}
}
11 changes: 11 additions & 0 deletions src/classes/AbstractPlugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Elysia } from 'elysia';

export abstract class AbstractPlugin {
protected readonly server: Elysia;

protected constructor(server: Elysia) {
this.server = server;
}

protected abstract load(): Elysia;
}
11 changes: 11 additions & 0 deletions src/classes/AbstractRoute.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Elysia } from 'elysia';

export abstract class AbstractRoute {
protected readonly server: Elysia;

protected constructor(server: Elysia) {
this.server = server;
}

protected abstract register(path: string): void;
}
Loading

0 comments on commit 95c2e33

Please sign in to comment.