Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
gobengo committed May 24, 2022
1 parent ece1533 commit 385ad17
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 40 deletions.
20 changes: 8 additions & 12 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,11 @@ jobs:
if: ${{ steps.release.outputs.release_created }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

docs:
runs-on: ubuntu-latest
needs:
- release
steps:
- run: npm run doc
- name: Deploy 🚀
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: docs
- run: npm run doc
if: ${{ steps.release.outputs.release_created }}
- if: ${{ steps.release.outputs.release_created }}
name: Deploy Docs 🚀
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: docs
17 changes: 12 additions & 5 deletions src/activitypub/activitypub-ucanto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ export type OutboxPostUcanto = {
};

export class OutboxUcanto {
constructor(public get: OutboxGetUcantoHandler, public post: OutboxPostUcantoHandler) {}
constructor(
public get: OutboxGetUcantoHandler,
public post: OutboxPostUcantoHandler
) {}
}

/**
Expand All @@ -77,12 +80,16 @@ class _ActivityPubUcanto {
}
public get outbox(): OutboxUcanto {
const get: OutboxGetUcantoHandler = async (_invocation) => {
const value: OutboxGetResponse = await (new OutboxGetHandler(this.getOutboxRepository())).handle({})
const value: OutboxGetResponse = await new OutboxGetHandler(
this.getOutboxRepository()
).handle({});
return { ok: true, value };
};
const post: OutboxPostUcantoHandler = async (_invocation) => {
const { activity } = _invocation.capability;
const value: OutboxPostResponse = await (new OutboxPostHandler(this.getOutboxRepository())).handle(activity)
const value: OutboxPostResponse = await new OutboxPostHandler(
this.getOutboxRepository()
).handle(activity);
return { ok: true, value };
};
return { get, post };
Expand Down Expand Up @@ -113,8 +120,8 @@ type KnownActivitypubActivity = AnnounceActivityPubCom;
*/
export interface ActivityPubUcantoAbstraction {
did(): DID;
inbox: InboxUcanto
outbox: OutboxUcanto
inbox: InboxUcanto;
outbox: OutboxUcanto;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/activitypub/activitypub.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * as outbox from "./outbox"
export * as outbox from "./outbox";
export * as inbox from "./inbox";
44 changes: 22 additions & 22 deletions src/activitypub/outbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,40 @@ import { ArrayRepository } from "./repository-array";
export type OutboxRepository = ArrayRepository<OutboxItem>;
export type OutboxPostableActivity = AnnounceActivityPubCom;
// eslint-disable-next-line @typescript-eslint/ban-types
export type OutboxGetRequest = {}
export type OutboxGetRequest = {};
export type OutboxGetResponse = {
totalItems: number;
};
export type OutboxPostRequest = OutboxPostableActivity
export type OutboxPostRequest = OutboxPostableActivity;
export type OutboxPostResponse = {
posted: true;
};

export type OutboxItem = InboxItem;

export interface Handler<Request, Response> {
handle(request: Request): Promise<Response>
handle(request: Request): Promise<Response>;
}

export class OutboxGetHandler implements Handler<OutboxGetRequest, OutboxGetResponse> {
constructor(
private outboxRepo: OutboxRepository
) {}
async handle(_request: OutboxGetRequest) {
return {
totalItems: await this.outboxRepo.count()
};
}
export class OutboxGetHandler
implements Handler<OutboxGetRequest, OutboxGetResponse>
{
constructor(private outboxRepo: OutboxRepository) {}
async handle(_request: OutboxGetRequest) {
return {
totalItems: await this.outboxRepo.count(),
};
}
}

export class OutboxPostHandler implements Handler<OutboxPostableActivity, OutboxPostResponse> {
constructor(
private outboxRepo: OutboxRepository
) {}
async handle(_request: OutboxPostRequest) {
await this.outboxRepo.push(_request)
return {
posted: true as const,
};
}
export class OutboxPostHandler
implements Handler<OutboxPostableActivity, OutboxPostResponse>
{
constructor(private outboxRepo: OutboxRepository) {}
async handle(_request: OutboxPostRequest) {
await this.outboxRepo.push(_request);
return {
posted: true as const,
};
}
}

0 comments on commit 385ad17

Please sign in to comment.