diff --git a/backend/.env.dist b/backend/.env.dist index 054ba101a..210ef3fa7 100644 --- a/backend/.env.dist +++ b/backend/.env.dist @@ -66,4 +66,4 @@ EVENT_PROTOCOL_DISABLED=false # on an hash created from this topic # FEDERATION_DHT_TOPIC=GRADIDO_HUB # FEDERATION_DHT_SEED=64ebcb0e3ad547848fef4197c6e2332f -# FEDERATION_COMMUNITY_URL=http://localhost:4000/graphql +# FEDERATION_COMMUNITY_URL=http://localhost:4000/api diff --git a/backend/src/federation/index.ts b/backend/src/federation/index.ts index a8863e582..6b6d4e5ba 100644 --- a/backend/src/federation/index.ts +++ b/backend/src/federation/index.ts @@ -18,9 +18,9 @@ const ANNOUNCETIME = 30000 const nodeURL = CONFIG.FEDERATION_COMMUNITY_URL || 'not configured' enum ApiVersionType { - V1 = 'v1', + V1_0 = 'v1_0', V1_1 = 'v1_1', - V2 = 'v2', + V2_0 = 'v2_0', } type CommunityApi = { @@ -32,14 +32,19 @@ type CommunityApiList = { } const prepareCommunityApiList = (): CommunityApiList => { - const apiEnumList = Object.values(ApiVersionType) + /* + const communityApiArray = Object.values(ApiVersionType) const communityApiArray = new Array() apiEnumList.forEach((apiEnum) => { const communityApi = { api: apiEnum, url: nodeURL } communityApiArray.push(communityApi) }) - const communityApiList = { apiVersions: communityApiArray } - return communityApiList + */ + return { + apiVersions: Object.values(ApiVersionType).map(function (apiEnum) { + return { api: apiEnum, url: nodeURL } + }), + } } export const startDHT = async ( diff --git a/database/entity/0055-add_communities_table/Community.ts b/database/entity/0055-add_communities_table/Community.ts index b1563a1fa..26f1d56d1 100644 --- a/database/entity/0055-add_communities_table/Community.ts +++ b/database/entity/0055-add_communities_table/Community.ts @@ -11,7 +11,7 @@ export class Community extends BaseEntity { @Column({ name: 'api_version', length: 10, nullable: false }) apiVersion: string - @Column({ name: 'endpoint', length: 255, nullable: false }) + @Column({ name: 'end_point', length: 255, nullable: false }) endPoint: string @Column({ name: 'last_announced_at', type: 'datetime', nullable: false }) diff --git a/database/migrations/0055-add_communities_table.ts b/database/migrations/0055-add_communities_table.ts index bfb053a74..1e5bb5084 100644 --- a/database/migrations/0055-add_communities_table.ts +++ b/database/migrations/0055-add_communities_table.ts @@ -8,11 +8,11 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { await queryFn(` - CREATE TABLE IF NOT EXISTS communities ( + CREATE TABLE communities ( id int unsigned NOT NULL AUTO_INCREMENT, public_key binary(64), api_version varchar(10) NOT NULL, - endpoint varchar(255) NOT NULL, + end_point varchar(255) NOT NULL, last_announced_at datetime(3) NOT NULL, created_at datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), updated_at datetime(3), @@ -24,5 +24,5 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { // write downgrade logic as parameter of queryFn - await queryFn(`DROP TABLE IF EXISTS communities;`) + await queryFn(`DROP TABLE communities;`) }