rework PR comments

This commit is contained in:
Claus-Peter Hübner 2022-11-30 00:35:50 +01:00
parent 0ef185e70f
commit 8db3c0f9d6
4 changed files with 15 additions and 10 deletions

View File

@ -66,4 +66,4 @@ EVENT_PROTOCOL_DISABLED=false
# on an hash created from this topic # on an hash created from this topic
# FEDERATION_DHT_TOPIC=GRADIDO_HUB # FEDERATION_DHT_TOPIC=GRADIDO_HUB
# FEDERATION_DHT_SEED=64ebcb0e3ad547848fef4197c6e2332f # FEDERATION_DHT_SEED=64ebcb0e3ad547848fef4197c6e2332f
# FEDERATION_COMMUNITY_URL=http://localhost:4000/graphql # FEDERATION_COMMUNITY_URL=http://localhost:4000/api

View File

@ -18,9 +18,9 @@ const ANNOUNCETIME = 30000
const nodeURL = CONFIG.FEDERATION_COMMUNITY_URL || 'not configured' const nodeURL = CONFIG.FEDERATION_COMMUNITY_URL || 'not configured'
enum ApiVersionType { enum ApiVersionType {
V1 = 'v1', V1_0 = 'v1_0',
V1_1 = 'v1_1', V1_1 = 'v1_1',
V2 = 'v2', V2_0 = 'v2_0',
} }
type CommunityApi = { type CommunityApi = {
@ -32,14 +32,19 @@ type CommunityApiList = {
} }
const prepareCommunityApiList = (): CommunityApiList => { const prepareCommunityApiList = (): CommunityApiList => {
const apiEnumList = Object.values(ApiVersionType) /*
const communityApiArray = Object.values(ApiVersionType)
const communityApiArray = new Array<CommunityApi>() const communityApiArray = new Array<CommunityApi>()
apiEnumList.forEach((apiEnum) => { apiEnumList.forEach((apiEnum) => {
const communityApi = { api: apiEnum, url: nodeURL } const communityApi = { api: apiEnum, url: nodeURL }
communityApiArray.push(communityApi) 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 ( export const startDHT = async (

View File

@ -11,7 +11,7 @@ export class Community extends BaseEntity {
@Column({ name: 'api_version', length: 10, nullable: false }) @Column({ name: 'api_version', length: 10, nullable: false })
apiVersion: string apiVersion: string
@Column({ name: 'endpoint', length: 255, nullable: false }) @Column({ name: 'end_point', length: 255, nullable: false })
endPoint: string endPoint: string
@Column({ name: 'last_announced_at', type: 'datetime', nullable: false }) @Column({ name: 'last_announced_at', type: 'datetime', nullable: false })

View File

@ -8,11 +8,11 @@
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) { export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn(` await queryFn(`
CREATE TABLE IF NOT EXISTS communities ( CREATE TABLE communities (
id int unsigned NOT NULL AUTO_INCREMENT, id int unsigned NOT NULL AUTO_INCREMENT,
public_key binary(64), public_key binary(64),
api_version varchar(10) NOT NULL, api_version varchar(10) NOT NULL,
endpoint varchar(255) NOT NULL, end_point varchar(255) NOT NULL,
last_announced_at datetime(3) NOT NULL, last_announced_at datetime(3) NOT NULL,
created_at datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), created_at datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
updated_at datetime(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<Array<any>>) { export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// write downgrade logic as parameter of queryFn // write downgrade logic as parameter of queryFn
await queryFn(`DROP TABLE IF EXISTS communities;`) await queryFn(`DROP TABLE communities;`)
} }