Add method to fetch DNS data for latest deployment
This commit is contained in:
parent
b5762432e6
commit
56eccb48b3
@ -24,6 +24,7 @@ import { Domain } from './entity/Domain';
|
|||||||
import { getEntities, loadAndSaveData } from './utils';
|
import { getEntities, loadAndSaveData } from './utils';
|
||||||
import { UserOrganization } from './entity/UserOrganization';
|
import { UserOrganization } from './entity/UserOrganization';
|
||||||
import { Deployer } from './entity/Deployer';
|
import { Deployer } from './entity/Deployer';
|
||||||
|
import { DNSRecordAttributes } from './types';
|
||||||
|
|
||||||
const ORGANIZATION_DATA_PATH = '../test/fixtures/organizations.json';
|
const ORGANIZATION_DATA_PATH = '../test/fixtures/organizations.json';
|
||||||
|
|
||||||
@ -602,6 +603,28 @@ export class Database {
|
|||||||
return domains;
|
return domains;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getLatestDNSDataByProjectId(
|
||||||
|
projectId: string,
|
||||||
|
): Promise<DNSRecordAttributes | null> {
|
||||||
|
const deploymentRepository = this.dataSource.getRepository(Deployment);
|
||||||
|
|
||||||
|
const deployment = await deploymentRepository.findOne({
|
||||||
|
where: {
|
||||||
|
project: {
|
||||||
|
id: projectId
|
||||||
|
},
|
||||||
|
}, order: {
|
||||||
|
createdAt: "DESC",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (deployment === null) {
|
||||||
|
throw new Error(`Error finding DNS data for project with id ${projectId}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return deployment.dnsRecordData;
|
||||||
|
}
|
||||||
|
|
||||||
async addDeployer(data: DeepPartial<Deployer>): Promise<Deployer> {
|
async addDeployer(data: DeepPartial<Deployer>): Promise<Deployer> {
|
||||||
const deployerRepository = this.dataSource.getRepository(Deployer);
|
const deployerRepository = this.dataSource.getRepository(Deployer);
|
||||||
const newDomain = await deployerRepository.save(data);
|
const newDomain = await deployerRepository.save(data);
|
||||||
|
@ -95,6 +95,13 @@ export const createResolvers = async (service: Service): Promise<any> => {
|
|||||||
) => {
|
) => {
|
||||||
return service.verifyTx(txHash, amount, senderAddress);
|
return service.verifyTx(txHash, amount, senderAddress);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getLatestDNSDataByProjectId: async (
|
||||||
|
_: any,
|
||||||
|
{ projectId }: { projectId: string },
|
||||||
|
) => {
|
||||||
|
return service.getLatestDNSDataByProjectId(projectId);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: Return error in GQL response
|
// TODO: Return error in GQL response
|
||||||
|
@ -249,6 +249,14 @@ type Auction {
|
|||||||
bids: [Bid!]!
|
bids: [Bid!]!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DNSRecordAttributes {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
request: string;
|
||||||
|
resourceType: string;
|
||||||
|
version: string;
|
||||||
|
}
|
||||||
|
|
||||||
input AuctionParams {
|
input AuctionParams {
|
||||||
maxPrice: String,
|
maxPrice: String,
|
||||||
numProviders: Int,
|
numProviders: Int,
|
||||||
@ -265,6 +273,7 @@ type Query {
|
|||||||
projectMembers(projectId: String!): [ProjectMember!]
|
projectMembers(projectId: String!): [ProjectMember!]
|
||||||
searchProjects(searchText: String!): [Project!]
|
searchProjects(searchText: String!): [Project!]
|
||||||
getAuctionData(auctionId: String!): Auction!
|
getAuctionData(auctionId: String!): Auction!
|
||||||
|
getLatestDNSDataByProjectId(projectId: String!): DNSRecordAttributes
|
||||||
domains(projectId: String!, filter: FilterDomainsInput): [Domain]
|
domains(projectId: String!, filter: FilterDomainsInput): [Domain]
|
||||||
deployers: [Deployer]
|
deployers: [Deployer]
|
||||||
address: String!
|
address: String!
|
||||||
|
@ -447,6 +447,11 @@ export class Service {
|
|||||||
return dbDeployments;
|
return dbDeployments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getLatestDNSDataByProjectId(projectId: string): Promise<DNSRecordAttributes | null> {
|
||||||
|
const dbDeployments = await this.db.getLatestDNSDataByProjectId(projectId);
|
||||||
|
return dbDeployments;
|
||||||
|
}
|
||||||
|
|
||||||
async getEnvironmentVariablesByProjectId(
|
async getEnvironmentVariablesByProjectId(
|
||||||
projectId: string,
|
projectId: string,
|
||||||
): Promise<EnvironmentVariable[]> {
|
): Promise<EnvironmentVariable[]> {
|
||||||
|
@ -453,4 +453,15 @@ export class GQLClient {
|
|||||||
|
|
||||||
return data.verifyTx;
|
return data.verifyTx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getLatestDNSDataByProjectId(projectId: string): Promise<types.DNSRecordAttributes> {
|
||||||
|
const { data } = await this.client.query({
|
||||||
|
query: queries.getLatestDNSDataByProjectId,
|
||||||
|
variables: {
|
||||||
|
projectId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return data.dnsRecordData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,3 +343,15 @@ query ($txHash: String!, $amount: String!, $senderAddress: String!) {
|
|||||||
verifyTx(txHash: $txHash, amount: $amount, senderAddress: $senderAddress)
|
verifyTx(txHash: $txHash, amount: $amount, senderAddress: $senderAddress)
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const getLatestDNSDataByProjectId = gql`
|
||||||
|
query($projectId: String!) {
|
||||||
|
dnsRecordData(projectId: $projectId) {
|
||||||
|
name
|
||||||
|
value
|
||||||
|
request
|
||||||
|
resourceType
|
||||||
|
version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
@ -376,3 +376,11 @@ export type AuctionParams = {
|
|||||||
maxPrice: string;
|
maxPrice: string;
|
||||||
numProviders: number;
|
numProviders: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type DNSRecordAttributes = {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
request: string;
|
||||||
|
resourceType: string;
|
||||||
|
version: string;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user