Skip to content

Commit

Permalink
feat: ✨ Port code from Lysand Server and improve it
Browse files Browse the repository at this point in the history
  • Loading branch information
CPlusPatch committed May 14, 2024
1 parent ef76ee4 commit bf8898a
Show file tree
Hide file tree
Showing 18 changed files with 733 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"conventionalCommits.scopes": ["docs"]
"conventionalCommits.scopes": ["docs"]
}
20 changes: 20 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
"organizeImports": {
"enabled": true,
"ignore": ["node_modules", "dist"]
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"ignore": ["node_modules", "dist"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 4,
"ignore": ["node_modules", "dist"]
}
}
17 changes: 17 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import dts from "bun-plugin-dts";
import ora from "ora";

const spinner = ora("Building...").start();

await Bun.build({
entrypoints: ["federation/index.ts"],
outdir: "federation/dist",
format: "esm",
minify: true,
sourcemap: "external",
splitting: true,
target: "browser",
plugins: [dts()],
});

spinner.succeed("Built federation module");
Binary file modified bun.lockb
Binary file not shown.
20 changes: 0 additions & 20 deletions federation/biome.json

This file was deleted.

53 changes: 53 additions & 0 deletions federation/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* @file index.ts
* @fileoverview Main entrypoint and export for the module
* @module federation
* @see module:federation/schemas/base
*/

import type { z } from "zod";
import {
Action,
ActorPublicKeyData,
ContentFormat,
Dislike,
Entity,
Extension,
Follow,
FollowAccept,
FollowReject,
Like,
Note,
Patch,
Publication,
Report,
ServerMetadata,
Undo,
User,
VanityExtension,
Visibility,
} from "~/federation/schemas/base";

export type InferType<T extends z.AnyZodObject> = z.infer<T>;

export {
Entity,
ContentFormat,
Visibility,
Publication,
Note,
Patch,
ActorPublicKeyData,
VanityExtension,
User,
Action,
Like,
Undo,
Dislike,
Follow,
FollowAccept,
FollowReject,
Extension,
Report,
ServerMetadata,
};
126 changes: 65 additions & 61 deletions federation/package.json
Original file line number Diff line number Diff line change
@@ -1,63 +1,67 @@
{
"name": "@lysand-org/federation",
"displayName": "Lysand Federation",
"version": "3.0.0",
"author": {
"email": "jesse.wierzbinski@lysand.org",
"name": "Jesse Wierzbinski (CPlusPatch)",
"url": "https://cpluspatch.com"
},
"readme": "README.md",
"repository": {
"type": "git",
"url": "https://github.com/lysand-org/api.git",
"directory": "federation"
},
"bugs": {
"url": "https://github.com/lysand-org/api/issues"
},
"license": "MIT",
"contributors": [
{
"name": "Jesse Wierzbinski",
"email": "jesse.wierzbinski@lysand.org",
"url": "https://cpluspatch.com"
}
],
"maintainers": [
{
"name": "Jesse Wierzbinski",
"email": "jesse.wierzbinski@lysand.org",
"url": "https://cpluspatch.com"
}
],
"description": "Type definitions for Lysand Federation, with validators.",
"categories": ["Other"],
"type": "module",
"engines": {
"bun": ">=1.1.8"
},
"exports": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/lysand"
},
"homepage": "https://lysand.org",
"keywords": [
"lysand",
"federation",
"api",
"typescript",
"zod",
"validation"
],
"packageManager": "bun@1.1.8",
"devDependencies": {
"@biomejs/biome": "^1.7.3"
},
"trustedDependencies": ["@biomejs/biome"]
"name": "@lysand-org/federation",
"displayName": "Lysand Federation",
"version": "3.0.0",
"author": {
"email": "jesse.wierzbinski@lysand.org",
"name": "Jesse Wierzbinski (CPlusPatch)",
"url": "https://cpluspatch.com"
},
"readme": "README.md",
"repository": {
"type": "git",
"url": "https://github.com/lysand-org/api.git",
"directory": "federation"
},
"bugs": {
"url": "https://github.com/lysand-org/api/issues"
},
"license": "MIT",
"contributors": [
{
"name": "Jesse Wierzbinski",
"email": "jesse.wierzbinski@lysand.org",
"url": "https://cpluspatch.com"
}
],
"maintainers": [
{
"name": "Jesse Wierzbinski",
"email": "jesse.wierzbinski@lysand.org",
"url": "https://cpluspatch.com"
}
],
"description": "Type definitions for Lysand Federation, with validators.",
"categories": ["Other"],
"type": "module",
"engines": {
"bun": ">=1.1.8"
},
"exports": {
".": {
"import": "./dist/index.js",
"default": "./dist/index.js"
}
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/lysand"
},
"homepage": "https://lysand.org",
"keywords": [
"lysand",
"federation",
"api",
"typescript",
"zod",
"validation"
],
"packageManager": "bun@1.1.8",
"dependencies": {
"@types/mime-types": "^2.1.4",
"magic-regexp": "^0.8.0",
"mime-types": "^2.1.35",
"zod": "^3.23.8",
"zod-validation-error": "^3.3.0"
}
}
Loading

0 comments on commit bf8898a

Please sign in to comment.