Commit 5982dd77 authored by Grant's avatar Grant
Browse files

initial

parent 661fe3a7
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
FROM node:20-alpine AS base
FROM node:23-alpine AS base
RUN apk add --no-cache openssl

FROM base as dev_dep
FROM base AS dev_dep
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
WORKDIR /home/node/app

@@ -12,7 +13,7 @@ COPY --chown=node:node frontend/package*.json ./frontend/
USER node
RUN npm install --include=dev

FROM base as dep
FROM base AS dep
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
WORKDIR /home/node/app

@@ -28,7 +29,7 @@ RUN npm install --omit=dev
# === BUILDER ===
#

FROM base as build
FROM base AS build
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
WORKDIR /home/node/app

@@ -49,7 +50,7 @@ RUN npm -w backend run build
# === RUNNER ===
#

FROM base as run
FROM base AS run
WORKDIR /home/node/app
COPY --from=dep /home/node/app/ ./
COPY package*.json docker-start.sh ./
@@ -72,9 +73,9 @@ RUN npx -w backend prisma generate

# set runtime env variables

ENV PORT 3000
ENV NODE_ENV production
ENV SERVE_FRONTEND /home/node/app/frontend
ENV PORT=3000
ENV NODE_ENV=production
ENV SERVE_FRONTEND=/home/node/app/frontend

EXPOSE 3000
ENTRYPOINT [ "/bin/sh" ]
+6 −0
Original line number Diff line number Diff line
@@ -6,6 +6,11 @@
  "private": true,
  "type": "module",
  "dependencies": {
    "@fedify/express": "^0.2.0",
    "@fedify/fedify": "^1.5.1",
    "@fedify/redis": "^0.4.0",
    "@js-temporal/polyfill": "^0.5.1",
    "@logtape/logtape": "^0.9.1",
    "@prisma/client": "^5.13.0",
    "@tsconfig/recommended": "^1.0.6",
    "body-parser": "^1.20.2",
@@ -13,6 +18,7 @@
    "cors": "^2.8.5",
    "express": "^4.19.2",
    "express-session": "^1.18.0",
    "ioredis": "^5.6.1",
    "oidc-provider": "^8.4.6",
    "openid-client": "^5.6.5"
  },
+25 −0
Original line number Diff line number Diff line
/*
  Warnings:

  - You are about to drop the column `mode` on the `AuthSession` table. All the data in the column will be lost.
  - A unique constraint covering the columns `[objectId]` on the table `AuthSession` will be added. If there are existing duplicate values, this will fail.
  - The required column `objectId` was added to the `AuthSession` table with a prisma-level default value. This is not possible if the table is not empty. Please add this column as optional, then populate it before making it required.

*/
-- AlterTable
ALTER TABLE "AuthSession" DROP COLUMN "mode",
ADD COLUMN     "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN     "expiresAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN     "objectId" TEXT NOT NULL;

-- CreateTable
CREATE TABLE "FediverseKeyPair" (
    "id" TEXT NOT NULL,
    "keyType" TEXT NOT NULL,
    "value" TEXT NOT NULL,

    CONSTRAINT "FediverseKeyPair_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "AuthSession_objectId_key" ON "AuthSession"("objectId");
+10 −1
Original line number Diff line number Diff line
@@ -28,7 +28,16 @@ model OidcModel {

model AuthSession {
  id            String @id @default(uuid())
  objectId      String @unique @default(uuid()) // fediverse object id
  one_time_code String
  mode          String // RECV_CODE | SEND_CODE -- is the service receiving or sending
  user_sub      String

  createdAt DateTime @default(now())
  expiresAt DateTime @default(now())
}

model FediverseKeyPair {
  id      String @id @default(uuid())
  keyType String
  value   String
}
+21 −18
Original line number Diff line number Diff line
import { setupAllProviders } from "./lib/delivery/index.js";
import { configure, getConsoleSink } from "@logtape/logtape";
import { app as Express } from "./lib/express.js";
import { oidc } from "./lib/oidc.js";
import { FederationWorker } from "./lib/apub/worker.js";

if (typeof process.env.SESSION_SECRET !== "string") {
  throw new Error("SESSION_SECRET is not defined");
@@ -40,22 +41,24 @@ if (process.env.NODE_ENV === "production") {
  }
}

setupAllProviders().then((providers) => {
  let errors: string[] = [];

  for (const prov of providers) {
    if (prov.status === "rejected") {
      errors.push(prov.reason || "unknown");
    }
  }

  if (errors.length === 0) {
    console.log("setup all deliver providers");
  } else {
    console.error("provider setup failed", errors);
  }
await configure({
  sinks: { console: getConsoleSink() },
  loggers: [
    {
      category: "fedify",
      sinks: ["console"],
      lowestLevel: "debug",
    },
  ],
  filters: {},
});

if (process.env.NODE_TYPE === "worker") {
  FederationWorker.create().then(() => {
    console.log("FederationWorker started");
  });
} else {
  Express.listen(process.env.PORT, () => {
    console.log("Listening on :" + process.env.PORT);
  });
}
Loading