Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

# Make sure to define this!
DATABASE_PASSWORD=
DATABASE_URL=postgresql://USER:${DATABASE_PASSWORD}@HOST:PORT/DATABASE
# Example postgresql://postgres:[DATABASE_PASSWORD]@localhost:5432/ppsl
DATABASE_URL=postgresql://[USER]:${DATABASE_PASSWORD}@[HOST]:[PORT]/[DATABASE]
CHECKPOINT_DISABLE=

HOST=0.0.0.0
HOST=127.0.0.1
PORT=3000
NODE_ENV=

Expand Down
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach",
"port": 9229,
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
}
]
}
8 changes: 5 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"npm.packageManager": "yarn",
"standard.enable": true,
"standard.autoFixOnSave": true,
"standard.validate": ["javascript"],
"standard.validate": [
"javascript",
],
"javascript.validate.enable": false,
"eslint.enable": false
}
"javascript.format.enable": false
}
873 changes: 0 additions & 873 deletions .yarn/releases/yarn-3.5.0.cjs

This file was deleted.

934 changes: 934 additions & 0 deletions .yarn/releases/yarn-4.6.0.cjs

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
yarnPath: .yarn/releases/yarn-3.5.0.cjs
compressionLevel: mixed

enableGlobalCache: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.6.0.cjs
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ Based\* on [@TomDoesTech](https://github.com/TomDoesTech)'s video titled [Build

* Node.js LTS recommended (Node.js 18.16.0 when this was written).
* Yarn (Node.js >=16.10 (corepack) & Node.js >=18.6 (yarn@stable) installation steps).
* `yarn` && `yarn run prisma:db-push` && `yarn start`
* `git submodule init` && `git submodule update`
* Copy `.env.example` file content into a `.env` file that is in the same directory.
Fill out the .env details. **Most notably `DATABASE_PASSWORD` to continue installation.**
* Use docker compose to `docker compose up` the `compose.yaml` file. **(REQUIRES `DATABASE_PASSWORD` TO BE SET).**
* Run `yarn` to install project dependencies.
* At this point, you should probably setup the rest of the .env stuff. Like `DATABASE_URL`. Google & GitHub require OAuth apps to be set. GitHub is easiest to setup. Just create a new organisation and create an OAuth App for it. **Set CALLBACK URL TO `http://localhost:5173/api/auth/callback/github` FOR GitHub.**
* Initialise & seed the database: `yarn run prisma:db-push && yarn run prisma:seed`
* `git submodule init && git submodule update`
* `yarn start` to start server.

## License

Expand Down
12 changes: 11 additions & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
"compilerOptions": {
"typeRoots": ["src/**/*.d.ts"]
"typeRoots": [
"src/**/*.d.ts"
],
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
},
"include": [
// Add all paths you want intellisense to work
Expand Down
66 changes: 37 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,55 @@
"name": "ppsl-cd-api",
"version": "0.1.0",
"license": "AGPL-3.0-only",
"packageManager": "yarn@3.5.0",
"packageManager": "yarn@4.6.0",
"type": "module",
"main": "src/server.js",
"scripts": {
"start": "node ./src/server.js",
"prisma:generate": "yarn rimraf ./.prisma && yarn pnpify prisma generate",
"prisma:db-push": "yarn pnpify prisma db push",
"prisma:migrate-reset": "yarn pnpify prisma migrate reset",
"prisma:migrate-dev": "yarn pnpify prisma migrate dev",
"prisma:seed": "yarn node ./prisma/seed/types.js",
"start": "node --inspect ./src/server.js",
"prisma:generate": "npx yarn rimraf ./.prisma && npx yarn pnpify prisma generate",
"prisma:db-push": "npx yarn pnpify prisma db push",
"prisma:migrate-reset": "npx yarn pnpify prisma migrate reset",
"prisma:migrate-dev": "npx yarn pnpify prisma migrate dev",
"prisma:seed": "npx yarn node ./prisma/seed/types.js",
"lint": "standard",
"lintfix": "standard --fix"
},
"dependencies": {
"@auth/core": "^0.8.2",
"@auth/core": "^0.37.4",
"@auth/prisma-adapter": "^2.7.4",
"@fastify/middie": "^8.3.0",
"@fastify/swagger": "^8.5.1",
"@fastify/swagger-ui": "^1.9.0",
"@lexical/headless": "^0.11.1",
"@lexical/html": "^0.11.1",
"@msgpack/msgpack": "^3.0.0-beta2",
"@next-auth/prisma-adapter": "^1.0.7",
"@prisma/client": "^4.15.0",
"authey": "^0.6.0",
"dotenv": "^16.3.1",
"@fastify/swagger": "^8.14.0",
"@fastify/swagger-ui": "^2.1.0",
"@lexical/headless": "0.22.0",
"@lexical/html": "0.22.0",
"@lexical/utils": "0.22.0",
"@lexical/yjs": "0.22.0",
"@prisma/client": "^5.9.1",
"authey": "^0.8.3",
"dotenv": "^16.4.1",
"dotenv-expand": "^10.0.0",
"fastify": "^4.18.0",
"fastify-plugin": "^4.5.0",
"fastify-zod": "^1.3.2",
"helmet": "^7.0.0",
"lexical": "^0.11.1",
"linkedom": "^0.14.26",
"fastify": "^4.26.0",
"fastify-plugin": "^4.5.1",
"fastify-zod": "^1.4.0",
"helmet": "^7.1.0",
"lexical": "0.22.0",
"linkedom": "^0.16.8",
"linkedom-global": "^1.0.0",
"zod": "^3.21.4"
"uint8array-extras": "^1.1.0",
"yjs": "13.6.21",
"zod": "^3.22.4"
},
"devDependencies": {
"@yarnpkg/pnpify": "4.0.0-rc.45",
"pino-pretty": "^10.0.0",
"prisma": "^4.15.0",
"rimraf": "^5.0.1",
"@yarnpkg/pnpify": "4.0.1",
"pino-pretty": "^10.3.1",
"prisma": "^5.9.1",
"rimraf": "^5.0.5",
"standard": "^17.1.0",
"typescript": "^5.1.3"
"typescript": "^5.3.3"
},
"overrides": {
"lexical": "0.22.0",
"yjs": "13.6.21",
"@lexical/yjs": "0.22.0"
}
}
67 changes: 67 additions & 0 deletions prisma/migrations/20240211103200_add_yjs/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
-- CreateTable
CREATE TABLE "YFolder" (
"id" TEXT NOT NULL,

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

-- CreateTable
CREATE TABLE "YPost" (
"id" TEXT NOT NULL,
"language" TEXT NOT NULL DEFAULT 'en',
"yFolderId" TEXT NOT NULL,
"lastUpdated" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"createdTimestamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateTable
CREATE TABLE "YPostRelation" (
"isSystem" BOOLEAN NOT NULL,
"fromPostId" TEXT NOT NULL,
"toPostId" TEXT NOT NULL,

CONSTRAINT "YPostRelation_pkey" PRIMARY KEY ("fromPostId","toPostId")
);

-- CreateTable
CREATE TABLE "YPostUpdate" (
"id" TEXT NOT NULL,
"title" TEXT NOT NULL,
"content" TEXT NOT NULL,
"postId" TEXT NOT NULL,
"metadataId" TEXT NOT NULL,
"createdTimestamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateTable
CREATE TABLE "YPostUpdateMetadata" (
"id" TEXT NOT NULL,
"userId" TEXT NOT NULL,

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

-- CreateIndex
CREATE UNIQUE INDEX "YPostUpdate_metadataId_key" ON "YPostUpdate"("metadataId");

-- AddForeignKey
ALTER TABLE "YPost" ADD CONSTRAINT "YPost_yFolderId_fkey" FOREIGN KEY ("yFolderId") REFERENCES "YFolder"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "YPostRelation" ADD CONSTRAINT "YPostRelation_fromPostId_fkey" FOREIGN KEY ("fromPostId") REFERENCES "YPost"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "YPostRelation" ADD CONSTRAINT "YPostRelation_toPostId_fkey" FOREIGN KEY ("toPostId") REFERENCES "YPost"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "YPostUpdate" ADD CONSTRAINT "YPostUpdate_postId_fkey" FOREIGN KEY ("postId") REFERENCES "YPost"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "YPostUpdate" ADD CONSTRAINT "YPostUpdate_metadataId_fkey" FOREIGN KEY ("metadataId") REFERENCES "YPostUpdateMetadata"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "YPostUpdateMetadata" ADD CONSTRAINT "YPostUpdateMetadata_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
28 changes: 28 additions & 0 deletions prisma/migrations/20240501223459_add_y_post_review/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- DropForeignKey
ALTER TABLE "PostMetadata" DROP CONSTRAINT "PostMetadata_userId_fkey";

-- DropForeignKey
ALTER TABLE "PostReview" DROP CONSTRAINT "PostReview_userId_fkey";

-- CreateTable
CREATE TABLE "YPostReview" (
"id" TEXT NOT NULL,
"type" "PostReviewTypes" NOT NULL,
"userId" TEXT NOT NULL,
"fromPostId" TEXT,
"toPostId" TEXT NOT NULL,

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

-- CreateIndex
CREATE UNIQUE INDEX "YPostReview_fromPostId_key" ON "YPostReview"("fromPostId");

-- AddForeignKey
ALTER TABLE "YPostReview" ADD CONSTRAINT "YPostReview_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "YPostReview" ADD CONSTRAINT "YPostReview_fromPostId_fkey" FOREIGN KEY ("fromPostId") REFERENCES "YPost"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "YPostReview" ADD CONSTRAINT "YPostReview_toPostId_fkey" FOREIGN KEY ("toPostId") REFERENCES "YPost"("id") ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Warnings:

- You are about to drop the column `expires_in` on the `Account` table. All the data in the column will be lost.
- The primary key for the `Session` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `id` on the `Session` table. All the data in the column will be lost.

*/
-- DropIndex
DROP INDEX "VerificationToken_identifier_token_key";

-- DropIndex
DROP INDEX "VerificationToken_token_key";

-- AlterTable
ALTER TABLE "Account" DROP COLUMN "expires_in",
ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;

-- AlterTable
ALTER TABLE "Session" DROP CONSTRAINT "Session_pkey",
DROP COLUMN "id",
ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;

-- AlterTable
ALTER TABLE "VerificationToken" ADD CONSTRAINT "VerificationToken_pkey" PRIMARY KEY ("identifier", "token");
20 changes: 20 additions & 0 deletions prisma/migrations/20250104151022_add_bytelength/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- AlterTable
ALTER TABLE "YPost" ADD COLUMN "totalByteLength" BIGINT;

-- AlterTable
ALTER TABLE "YPostUpdateMetadata" ADD COLUMN "byteLength" BIGINT;

-- CreateTable
CREATE TABLE "Html" (
"id" TEXT NOT NULL,
"postId" TEXT NOT NULL,
"content" TEXT NOT NULL,

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

-- CreateIndex
CREATE UNIQUE INDEX "Html_postId_key" ON "Html"("postId");

-- AddForeignKey
ALTER TABLE "Html" ADD CONSTRAINT "Html_postId_fkey" FOREIGN KEY ("postId") REFERENCES "YPost"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "Html" ADD COLUMN "createdTimestamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "lastUpdated" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
Loading