本文整理汇总了TypeScript中prisma-yml.PrismaDefinitionClass.getToken方法的典型用法代码示例。如果您正苦于以下问题:TypeScript PrismaDefinitionClass.getToken方法的具体用法?TypeScript PrismaDefinitionClass.getToken怎么用?TypeScript PrismaDefinitionClass.getToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prisma-yml.PrismaDefinitionClass
的用法示例。
在下文中一共展示了PrismaDefinitionClass.getToken方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: connect
async connect() {
await this.cluster
.request(
`mutation($input: AddProjectInput!) {
addProject(input: $input) {
clientMutationId
}
}`,
{
input: {
name: SERVICE_NAME,
stage: SERVICE_STAGE,
secrets: [SERVICE_SECRET],
},
},
)
.then(res => res.json())
const endpoint = this.cluster.getApiEndpoint(SERVICE_NAME, SERVICE_STAGE)
const secretsBackup = this.definition.secrets
this.definition.secrets = [SERVICE_SECRET]
const token = this.definition.getToken(SERVICE_NAME, SERVICE_STAGE)
this.definition.secrets = secretsBackup
this.client = new GraphQLClient(endpoint, {
headers: token
? {
Authorization: `Bearer ${token}`,
}
: {},
})
}
示例2: seed
async seed(
serviceName: string,
stageName: string,
reset: boolean = false,
workspaceSlug?: string,
) {
const seed = this.definition.definition!.seed
if (!seed) {
throw new Error(
`In order to seed, you need to provide a "seed" property in your prisma.yml`,
)
}
if (seed.import && seed.run) {
throw new Error(
`Please provider either seed.import or seed.run but not both at the same time`,
)
}
if (seed.import) {
const source = path.join(this.config.definitionDir, seed.import)
debug(source)
if (!source.endsWith('.zip') && !source.endsWith('.graphql')) {
throw new Error(`Source must end with .zip or .graphql`)
}
if (!fs.pathExistsSync(source)) {
throw new Error(`Path ${source} does not exist`)
}
const token = this.definition.getToken(serviceName, stageName)
if (reset) {
await this.reset(serviceName, stageName)
}
if (source.endsWith('.zip')) {
await this.import(source, serviceName, stageName, token, workspaceSlug)
} else if (source.endsWith('.graphql')) {
await this.executeQuery(
source,
serviceName,
stageName,
token,
workspaceSlug,
)
}
}
if (seed.run) {
if (reset) {
await this.reset(serviceName, stageName)
}
await this.run(seed.run)
}
}
示例3: reset
async reset(serviceName, stageName) {
const before = Date.now()
this.out.action.start(
`Resetting ${chalk.bold(`${serviceName}@${stageName}`)}`,
)
await this.client.reset(
serviceName,
stageName,
this.definition.getToken(serviceName, stageName),
)
this.out.action.stop(chalk.cyan(`${Date.now() - before}ms`))
}