Merge remote-tracking branch 'origin/backend_setup' into apollo_gdt

This commit is contained in:
einhornimmond 2021-08-03 15:12:00 +02:00
commit 3834871071
23 changed files with 243 additions and 381 deletions

View File

@ -33,7 +33,7 @@ export const apiGet = async (url: string): Promise<any> => {
})
.catch((error) => {
// eslint-disable-next-line no-console
console.log('IN apiGet.ERROR: ' + JSON.stringify({ success: false, result: error }))
console.log('IN apiGet.ERROR: ', { success: false, result: error })
return { success: false, data: error.message }
})
}

View File

@ -1,184 +0,0 @@
import axios from 'axios'
import { graphql } from 'graphql'
import CONFIG from '../config'
import { User } from '../graphql/models/User'
import { LoginUserInput } from '../graphql/inputs/LoginUserInput'
// eslint-disable-next-line no-unused-vars
// import regeneratorRuntime from 'regenerator-runtime'
// control email-text sended with email verification code
const EMAIL_TYPE = {
DEFAULT: 2, // if user has registered directly
ADMIN: 5, // if user was registered by an admin
}
const apiGet = async (url: string) => {
try {
const result = await axios.get(url)
if (result.status !== 200) {
throw new Error('HTTP Status Error ' + result.status)
}
if (!['success', 'warning'].includes(result.data.state)) {
throw new Error(result.data.msg)
}
return { success: true, result }
} catch (error) {
return { success: false, result: error }
}
}
const apiPost = async (url: string, payload: any): Promise<any> => {
try {
const result = await axios.post(url, payload)
if (result.status !== 200) {
throw new Error('HTTP Status Error ' + result.status)
}
if (result.data.state === 'warning') {
return { success: true, result: result.data.errors }
}
if (result.data.state !== 'success') {
throw new Error(result.data.msg)
}
return { success: true, result }
} catch (error) {
return { success: false, result: error }
}
}
interface NetworkInfosResult {
state: string
msg?: string
errors: string[]
data: {
groups?: string[]
}
}
interface LoginResult {
state: string
msg?: string
details?: number
info?: string
user?: User
// eslint-disable-next-line camelcase
session_id?: number
}
const loginAPI = {
login: async (login: LoginUserInput): Promise<LoginResult> => {
return (await apiPost(CONFIG.LOGIN_API_URL + 'unsecureLogin', login)).result.data
},
logout: async (sessionId: number): Promise<any> => {
const payload: any = { session_id: sessionId }
return apiPost(CONFIG.LOGIN_API_URL + 'logout', payload)
},
create: async (
email: string,
firstName: string,
lastName: string,
password: string,
): Promise<any> => {
const payload: any = {
email,
first_name: firstName,
last_name: lastName,
password,
emailType: EMAIL_TYPE.DEFAULT,
login_after_register: true,
}
return apiPost(CONFIG.LOGIN_API_URL + 'createUser', payload)
},
sendEmail: async (
email: string,
email_text = 7,
email_verification_code_type = 'resetPassword',
): Promise<any> => {
const payload: any = {
email,
email_text,
email_verification_code_type,
}
return apiPost(CONFIG.LOGIN_API_URL + 'sendEmail', payload)
},
loginViaEmailVerificationCode: async (optin: number): Promise<any> => {
return apiGet(
CONFIG.LOGIN_API_URL + 'loginViaEmailVerificationCode?emailVerificationCode=' + optin,
)
},
getUserInfos: async (sessionId: number, email: string): Promise<any> => {
const payload: any = {
session_id: sessionId,
email: email,
ask: ['user.first_name', 'user.last_name'],
}
return apiPost(CONFIG.LOGIN_API_URL + 'getUserInfos', payload)
},
updateUserInfos: async (sessionId: number, email: string, data: any): Promise<any> => {
const payload: any = {
session_id: sessionId,
email,
update: {
'User.first_name': data.firstName,
'User.last_name': data.lastName,
'User.description': data.description,
},
}
return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload)
},
changePassword: async (sessionId: number, email: string, password: string): Promise<any> => {
const payload: any = {
session_id: sessionId,
email,
password,
}
return apiPost(CONFIG.LOGIN_API_URL + 'resetPassword', payload)
},
changePasswordProfile: async (
sessionId: number,
email: string,
password: string,
passwordNew: string,
): Promise<any> => {
const payload: any = {
session_id: sessionId,
email,
update: {
'User.password_old': password,
'User.password': passwordNew,
},
}
return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload)
},
changeUsernameProfile: async (
sessionId: number,
email: string,
username: string,
): Promise<any> => {
const payload: any = {
session_id: sessionId,
email,
update: {
'User.username': username,
},
}
return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload)
},
updateLanguage: async (sessionId: number, email: string, language: string): Promise<any> => {
const payload: any = {
session_id: sessionId,
email,
update: {
'User.language': language,
},
}
return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload)
},
checkUsername: async (username: string, groupId = 1): Promise<any> => {
return apiGet(CONFIG.LOGIN_API_URL + `checkUsername?username=${username}&group_id=${groupId}`)
},
getNetworkInfos: async (ask: string[]): Promise<NetworkInfosResult> => {
return (await apiPost(CONFIG.LOGIN_API_URL + `networkInfos`, { ask: ask })).result.data
},
}
export { loginAPI, NetworkInfosResult, LoginResult }

View File

@ -1,7 +1,7 @@
import { ArgsType, Field } from 'type-graphql'
@ArgsType()
export class TransactionInput {
export class TransactionListInput {
@Field(() => Number)
sessionId: number

View File

@ -1,27 +1,21 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Entity, BaseEntity, Column } from 'typeorm'
import { ObjectType, Field } from 'type-graphql'
@Entity()
@ObjectType()
export class Balance extends BaseEntity {
export class Balance {
constructor(json: any) {
super()
this.balance = json.balance
this.decay = json.decay
this.balance = Number(json.balance)
this.decay = Number(json.decay)
this.decayDate = json.decay_date
}
@Field(() => Number)
@Column()
balance: number
@Field(() => Number)
@Column()
decay: number
@Field(() => String)
@Column()
decayDate: string
}

View File

@ -1,9 +0,0 @@
import { Entity, BaseEntity } from 'typeorm'
import { ObjectType, Field } from 'type-graphql'
@Entity()
@ObjectType()
export class BaseResponse extends BaseEntity {
@Field(() => Boolean)
success: boolean
}

View File

@ -1,9 +0,0 @@
import { Entity, BaseEntity } from 'typeorm'
import { ObjectType, Field } from 'type-graphql'
@Entity()
@ObjectType()
export class ChangePasswordResponse extends BaseEntity {
@Field(() => String)
state: string
}

View File

@ -1,9 +1,15 @@
import { Entity, BaseEntity } from 'typeorm'
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { ObjectType, Field } from 'type-graphql'
@Entity()
@ObjectType()
export class CheckUsernameResponse extends BaseEntity {
export class CheckUsernameResponse {
constructor(json: any) {
this.state = json.state
this.msg = json.msg
this.groupId = json.group_id
}
@Field(() => String)
state: string

View File

@ -1,14 +0,0 @@
import { Entity, BaseEntity } from 'typeorm'
import { ObjectType, Field } from 'type-graphql'
@Entity()
@ObjectType()
export class CreateResponse extends BaseEntity {
constructor(json: any) {
super()
this.state = json.state
}
@Field(() => String)
state: string
}

View File

@ -0,0 +1,25 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { ObjectType, Field } from 'type-graphql'
@ObjectType()
export class Decay {
constructor(json: any) {
this.balance = Number(json.balance)
this.decayStart = json.decay_start
this.decayEnd = json.decay_end
this.decayDuration = json.decay_duration
}
@Field(() => Number)
balance: number
@Field({ nullable: true })
decayStart?: number
@Field({ nullable: true })
decayEnd?: number
@Field(() => String)
decayDuration: string
}

View File

@ -1,25 +1,20 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Entity, BaseEntity, Column } from 'typeorm'
import { ObjectType, Field } from 'type-graphql'
import { User } from './User'
// temporaray solution until we have JWT implemented
@Entity()
@ObjectType()
export class LoginResponse extends BaseEntity {
export class LoginResponse {
constructor(json: any) {
super()
this.sessionId = json.session_id
this.user = new User(json.user)
}
@Field(() => Number)
@Column()
sessionId: number
@Field(() => User)
@Column()
user: User
}

View File

@ -1,22 +1,17 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Entity, BaseEntity, Column } from 'typeorm'
import { ObjectType, Field } from 'type-graphql'
@Entity()
@ObjectType()
export class LoginViaVerificationCode extends BaseEntity {
export class LoginViaVerificationCode {
constructor(json: any) {
super()
this.sessionId = json.session_id
this.email = json.user.email
}
@Field(() => Number)
@Column()
sessionId: number
@Field(() => String)
@Column()
email: string
}

View File

@ -1,11 +1,10 @@
import { Entity, BaseEntity } from 'typeorm'
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { ObjectType, Field } from 'type-graphql'
@Entity()
@ObjectType()
export class SendEmailResponse extends BaseEntity {
export class SendPasswordResetEmailResponse {
constructor(json: any) {
super()
this.state = json.state
this.msg = json.msg
}

View File

@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Entity, BaseEntity } from 'typeorm'
import { ObjectType, Field } from 'type-graphql'

View File

@ -1,10 +1,89 @@
import { Entity, BaseEntity, Column } from 'typeorm'
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { ObjectType, Field } from 'type-graphql'
import { Decay } from './Decay'
// we need a better solution for the decay block:
// the first transaction on the first page shows the decay since the last transaction
// the format is actually a Decay and not a Transaction.
// Therefore we have a lot of nullable fields, which should be always present
@Entity()
@ObjectType()
export class Transaction extends BaseEntity {
export class Transaction {
constructor(json: any) {
this.type = json.type
this.balance = Number(json.balance)
this.decayStart = json.decay_start
this.decayEnd = json.decay_end
this.decayDuration = json.decay_duration
this.memo = json.memo
this.transactionId = json.transaction_id
this.name = json.name
this.email = json.email
this.date = json.date
this.decay = json.decay
}
@Field(() => String)
@Column({ length: 191 })
email: string
type: string
@Field(() => Number)
balance: number
@Field({ nullable: true })
decayStart?: number
@Field({ nullable: true })
decayEnd?: number
@Field({ nullable: true })
decayDuration?: string
@Field(() => String)
memo: string
@Field(() => Number)
transactionId: number
@Field({ nullable: true })
name?: string
@Field({ nullable: true })
email?: string
@Field({ nullable: true })
date?: string
@Field({ nullable: true })
decay?: Decay
}
@ObjectType()
export class TransactionList {
constructor(json: any) {
this.gdtSum = Number(json.gdtSum)
this.count = json.count
this.balance = Number(json.balance)
this.decay = Number(json.decay)
this.decayDate = json.decay_date
this.transactions = json.transactions
}
@Field(() => Number)
gdtSum: number
@Field(() => Number)
count: number
@Field(() => Number)
balance: number
@Field(() => Number)
decay: number
@Field(() => String)
decayDate: string
@Field(() => [Transaction])
transactions: Transaction[]
}

View File

@ -1,15 +1,13 @@
import { Entity, BaseEntity } from 'typeorm'
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { ObjectType, Field } from 'type-graphql'
@Entity()
@ObjectType()
export class UpdateUserInfosResponse extends BaseEntity {
@Field(() => String)
state: string
export class UpdateUserInfosResponse {
constructor(json: any) {
this.validValues = json.valid_values
}
@Field(() => Number)
validValues: number
@Field(() => [String])
errors: [string]
}

View File

@ -1,18 +1,15 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Entity, BaseEntity, Column } from 'typeorm'
import { ObjectType, Field } from 'type-graphql'
@Entity()
@ObjectType()
export class User extends BaseEntity {
export class User {
/*
@Field(() => ID)
@PrimaryGeneratedColumn()
id: number
*/
constructor(json: any) {
super()
this.email = json.email
this.firstName = json.first_name
this.lastName = json.last_name
@ -22,62 +19,49 @@ export class User extends BaseEntity {
}
@Field(() => String)
@Column({ length: 191 })
email: string
@Field(() => String)
@Column({ length: 150 })
firstName: string
@Field(() => String)
@Column()
lastName: string
@Field(() => String)
@Column()
username: string
@Field(() => String)
@Column('text')
description: string
/*
@Field(() => String)
@Column({ length: 64 })
pubkey: string
// not sure about the type here. Maybe better to have a string
@Field(() => number)
@Column({ type: 'datetime' })
created: number
@Field(() => Boolean)
@Column({ default: false })
emailChecked: boolean
@Field(() => Boolean)
@Column({ default: false })
passphraseShown: boolean
*/
@Field(() => String)
@Column({ default: 'de' })
language: string
/*
@Field(() => Boolean)
@Column({ default: false })
disabled: boolean
*/
/* I suggest to have a group as type here
@Field(() => ID)
@Column()
groupId: number
// what is puvlisherId?
@Field(() => ID)
@Column({ default: 0 })
publisherId: number
*/
}

View File

@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Entity, BaseEntity } from 'typeorm'
import { ObjectType, Field } from 'type-graphql'
import { Server } from './Server'

View File

@ -0,0 +1,14 @@
import { Resolver, Query, /* Mutation, */ Arg } from 'type-graphql'
import CONFIG from '../../config'
import { Balance } from '../models/Balance'
import { apiGet } from '../../apis/loginAPI'
@Resolver()
export class BalanceResolver {
@Query(() => Balance)
async balance(@Arg('sessionId') sessionId: number): Promise<Balance> {
const result = await apiGet(CONFIG.COMMUNITY_API_URL + 'getBalance/' + sessionId)
if (!result.success) throw new Error(result.data)
return new Balance(result.data)
}
}

View File

@ -1,57 +0,0 @@
import { Resolver, Query, /* Mutation, */ Args, Arg } from 'type-graphql'
import CONFIG from '../../config'
import {} from '../models/Transaction'
import { Balance } from '../models/Balance'
import {
TransactionCreateArgs,
TransactionInput,
TransactionSendArgs,
} from '../inputs/TransactionInput'
import { apiPost, apiGet } from '../../apis/loginAPI'
@Resolver()
export class CommunityTransactionResolver {
@Query(() => Balance)
async balance(@Arg('sessionId') sessionId: number): Promise<Balance> {
// eslint-disable-next-line no-console
console.log('IN BALANCE: URL: ' + CONFIG.COMMUNITY_API_URL + 'getBalance/' + sessionId)
const result = await apiGet(CONFIG.COMMUNITY_API_URL + 'getBalance/' + sessionId)
return new Balance(result.result.data)
}
@Query(() => String)
async transactions(
@Args() { sessionId, firstPage = 1, items = 5, order = 'DESC' }: TransactionInput,
): Promise<any> {
return apiGet(
`${CONFIG.COMMUNITY_API_URL}listTransactions/${firstPage}/${items}/${order}/${sessionId}`,
)
}
@Query(() => String)
async send(@Args() { sessionId, email, amount, memo }: TransactionSendArgs): Promise<any> {
const payload = {
session_id: sessionId,
auto_sign: true,
email: email,
amount: amount,
memo: memo,
}
return apiPost(CONFIG.COMMUNITY_API_URL + 'sendCoins/', payload)
}
@Query(() => String)
async createCoins(
@Args() { sessionId, email, amount, memo, targetDate = new Date() }: TransactionCreateArgs,
): Promise<any> {
const payload = {
sessionId,
email,
amount,
targetDate,
memo,
auto_sign: true,
}
return apiPost(CONFIG.COMMUNITY_API_URL + 'createCoins/', payload)
}
}

View File

@ -0,0 +1,37 @@
import { Resolver, Query, /* Mutation, */ Args } from 'type-graphql'
import CONFIG from '../../config'
import { TransactionList } from '../models/Transaction'
import { TransactionListInput, TransactionSendArgs } from '../inputs/TransactionInput'
import { apiGet, apiPost } from '../../apis/loginAPI'
@Resolver()
export class TransactionResolver {
@Query(() => TransactionList)
async transactionList(
@Args() { sessionId, firstPage = 1, items = 25, order = 'DESC' }: TransactionListInput,
): Promise<TransactionList> {
const result = await apiGet(
`${CONFIG.COMMUNITY_API_URL}listTransactions/${firstPage}/${items}/${order}/${sessionId}`,
)
if (!result.success) throw new Error(result.data)
return new TransactionList(result.data)
}
@Query(() => String)
async sendCoins(
@Args() { sessionId, email, amount, memo }: TransactionSendArgs,
): Promise<string> {
const payload = {
session_id: sessionId,
email,
amount,
memo,
auto_sign: true,
}
const result = await apiPost(CONFIG.COMMUNITY_API_URL + 'sendCoins', payload)
if (!result.success) {
throw new Error(result.data)
}
return 'success'
}
}

View File

@ -1,13 +1,11 @@
// import jwt from 'jsonwebtoken'
import { Resolver, Query, /* Mutation, */ Args, Arg } from 'type-graphql'
import { Resolver, Query, Args, Arg } from 'type-graphql'
import CONFIG from '../../config'
import { ChangePasswordResponse } from '../models/ChangePasswordResponse'
import { CheckUsernameResponse } from '../models/CheckUsernameResponse'
import { CreateResponse } from '../models/CreateResponse'
import { GetUserInfoResponse } from '../models/UserInfoData'
import { LoginResponse } from '../models/LoginResponse'
import { LoginViaVerificationCode } from '../models/LoginViaVerificationCode'
import { SendEmailResponse } from '../models/SendEmailResponse'
import { SendPasswordResetEmailResponse } from '../models/SendPasswordResetEmailResponse'
import { UpdateUserInfosResponse } from '../models/UpdateUserInfosResponse'
import {
ChangePasswordArgs,
@ -23,7 +21,6 @@ import { apiPost, apiGet } from '../../apis/loginAPI'
@Resolver()
export class UserResolver {
@Query(() => LoginResponse)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async login(@Args() { email, password }: UnsecureLoginArgs): Promise<LoginResponse> {
email = email.trim().toLowerCase()
const result = await apiPost(CONFIG.LOGIN_API_URL + 'unsecureLogin', { email, password })
@ -51,7 +48,6 @@ export class UserResolver {
}
@Query(() => LoginViaVerificationCode)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async loginViaEmailVerificationCode(
@Arg('optin') optin: string,
): Promise<LoginViaVerificationCode> {
@ -66,21 +62,18 @@ export class UserResolver {
return new LoginViaVerificationCode(result.data)
}
/* @Query(() => LogoutResponse)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async logout(@Arg('sessionId') sessionId: number): Promise<LogoutResponse> {
@Query(() => String)
async logout(@Arg('sessionId') sessionId: number): Promise<string> {
const payload = { session_id: sessionId }
const result = apiPost(CONFIG.LOGIN_API_URL + 'logout', payload)
const result = await apiPost(CONFIG.LOGIN_API_URL + 'logout', payload)
if (!result.success) {
throw new Error(result.data)
}
return result.data
return 'success'
}
*/
@Query(() => CreateResponse)
async create(
@Args() { email, firstName, lastName, password }: CreateUserArgs,
): Promise<CreateResponse> {
@Query(() => String)
async create(@Args() { email, firstName, lastName, password }: CreateUserArgs): Promise<string> {
const payload = {
email,
first_name: firstName,
@ -93,23 +86,27 @@ export class UserResolver {
if (!result.success) {
throw new Error(result.data)
}
return new CreateResponse(result.data)
return 'success'
}
@Query(() => SendEmailResponse)
async sendEmail(
// TODO
@Query(() => SendPasswordResetEmailResponse)
async sendResetPasswordEmail(
@Args()
{ email, emailText = 7, emailVerificationCodeType = 'resetPassword' }: SendEmailArgs,
): Promise<any> {
): Promise<SendPasswordResetEmailResponse> {
const payload = {
email,
email_text: emailText,
email_verification_code_type: emailVerificationCodeType,
}
return apiPost(CONFIG.LOGIN_API_URL + 'sendEmail', payload)
const response = await apiPost(CONFIG.LOGIN_API_URL + 'sendEmail', payload)
if (!response.success) throw new Error(response.data)
return new SendPasswordResetEmailResponse(response.data)
}
@Query(() => GetUserInfoResponse)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async getUserInfos(@Args() { sessionId, email }: GetUserInfoArgs): Promise<any> {
const payload = {
session_id: sessionId,
@ -119,16 +116,19 @@ export class UserResolver {
return apiPost(CONFIG.LOGIN_API_URL + 'getUserInfos', payload)
}
@Query(() => ChangePasswordResponse)
async changePassword(@Args() { sessionId, email, password }: ChangePasswordArgs): Promise<any> {
@Query(() => String)
async resetPassword(
@Args()
{ sessionId, email, password }: ChangePasswordArgs,
): Promise<string> {
const payload = {
session_id: sessionId,
email,
password,
}
const result = await apiPost(CONFIG.LOGIN_API_URL + 'resetPassword', payload)
if (result.success) return result.result.data.state
return result.result
if (!result.success) throw new Error(result.data)
return 'sucess'
}
@Query(() => UpdateUserInfosResponse)
@ -137,32 +137,39 @@ export class UserResolver {
{
sessionId,
email,
firstName,
lastName,
username,
language,
password,
passwordNew,
firstName = '',
lastName = '',
username = '',
language = '',
password = '',
passwordNew = '',
}: UpdateUserInfosArgs,
): Promise<any> {
): Promise<UpdateUserInfosResponse> {
const payload = {
session_id: sessionId,
email,
update: {
'User.first_name': firstName,
'User.last_name': lastName,
// 'User.description': data.description,
'User.username': username,
'User.language': language,
'User.password_old': password,
'User.password': passwordNew,
'User.first_name': firstName !== '' ? firstName : undefined,
'User.last_name': lastName !== '' ? lastName : undefined,
'User.username': username !== '' ? username : undefined,
'User.language': language !== '' ? language : undefined,
'User.password': passwordNew !== '' ? passwordNew : undefined,
'User.password_old': password !== '' ? password : undefined,
},
}
return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload)
const result = await apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload)
if (!result.success) throw new Error(result.data)
return new UpdateUserInfosResponse(result.data)
}
@Query(() => CheckUsernameResponse)
async checkUsername(@Args() { username, groupId = 1 }: CheckUsernameArgs): Promise<any> {
return apiGet(CONFIG.LOGIN_API_URL + `checkUsername?username=${username}&group_id=${groupId}`)
async checkUsername(
@Args() { username, groupId = 1 }: CheckUsernameArgs,
): Promise<CheckUsernameResponse> {
const response = await apiGet(
CONFIG.LOGIN_API_URL + `checkUsername?username=${username}&group_id=${groupId}`,
)
if (!response.success) throw new Error(response.data)
return new CheckUsernameResponse(response.data)
}
}

View File

@ -9,19 +9,17 @@ import CONFIG from './config'
// import { BookResolver } from './graphql/resolvers/BookResolver'
import { UserResolver } from './graphql/resolvers/UserResolver'
import { CommunityTransactionResolver } from './graphql/resolvers/CommunityTransactionResolver'
import { BalanceResolver } from './graphql/resolvers/BalanceResolver'
import { GdtResolver } from './graphql/resolvers/GdtResolver'
// import { GroupResolver } from './graphql/resolvers/GroupResolver'
import { TransactionResolver } from './graphql/resolvers/TransactionResolver'
// TODO implement
// import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity";
async function main() {
// const connection = await createConnection()
const schema = await buildSchema({
resolvers: [
/* BookResolver , GroupResolver, */ UserResolver,
CommunityTransactionResolver,
GdtResolver,
],
resolvers: [UserResolver, BalanceResolver, TransactionResolver, GdtResolver],
})
// Graphiql interface