当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Tyr.config方法代码示例

本文整理汇总了TypeScript中tyranid.Tyr.config方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Tyr.config方法的具体用法?TypeScript Tyr.config怎么用?TypeScript Tyr.config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tyranid.Tyr的用法示例。


在下文中一共展示了Tyr.config方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

test.before(async () => {
  await Tyr.config({
    validate: [
      { dir: root + `${path.sep}test${path.sep}models`, fileMatch: '.*.js' }
    ]
  });
});
开发者ID:tyranid-org,项目名称:tyranid,代码行数:7,代码来源:index.ts

示例2: generateStream

(async () => {
  if (!fileGlob) return program.help();
  const root = process.cwd();
  const outFile = program['outFile'];

  const globToUse =
    path.resolve(fileGlob) === fileGlob ? fileGlob : path.join(CWD, fileGlob);

  const log = console.log;
  if (!outFile) (console as any).log = () => {};
  await Tyr.config({ validate: [{ glob: globToUse }] });
  if (!outFile) console.log = log;

  const stream = generateStream(Tyr.collections, {
    type: program.type || 'isomorphic'
  });

  if (outFile) {
    const filename = path.join(root, outFile);
    stream.pipe(
      fs.createWriteStream(filename).on('finish', () => {
        process.exit(0);
      })
    );
  } else {
    stream.pipe(process.stdout);
    stream.on('end', () => {
      process.exit(0);
    });
  }
})().catch(err => {
开发者ID:tyranid-org,项目名称:tyranid,代码行数:31,代码来源:cli.ts

示例3: generate

async function generate() {
  await Tyr.config({
    validate: [
      {
        dir: path.resolve(__dirname, `./models/`),
        fileMatch: '.*.ts'
      }
    ]
  });

  await Promise.all([
    generateFile(
      Tyr.collections,
      path.resolve(__dirname, './output/isomorphic.d.ts')
    ),
    generateFile(
      Tyr.collections,
      path.resolve(__dirname, './output/server.d.ts'),
      { type: 'server' }
    ),
    generateFile(
      Tyr.collections,
      path.resolve(__dirname, './output/client.d.ts'),
      { type: 'client' }
    )
  ]);

  process.exit(0);
}
开发者ID:tyranid-org,项目名称:tyranid,代码行数:29,代码来源:generate.ts

示例4: createTestData

(async () => {
  const mongoClient = await mongodb.MongoClient.connect(
    'mongodb://127.0.0.1:27017/tyranid_gracl_test',
    { useNewUrlParser: true }
  );

  Tyr.config({
    mongoClient,
    db: mongoClient.db(),
    validate: [
      {
        dir: __dirname,
        fileMatch: 'models.js'
      }
    ]
  });

  await createTestData();

  const GRAPHQL_PORT = 8080;

  const graphQLServer = express();

  graphQLServer.use(
    '/graphql',
    bodyParser.json(),
    graphqlExpress({
      schema: createGraphQLSchema(Tyr)
    })
  );

  graphQLServer.use(
    '/graphiql',
    graphiqlExpress({
      endpointURL: '/graphql'
    })
  );

  /* tslint:disable no-console */
  graphQLServer.listen(GRAPHQL_PORT, () =>
    console.log(
      `GraphQL Server is now running on http://localhost:${GRAPHQL_PORT}/graphiql`
    )
  );
})().catch(err => console.log(err.stack)); /* tslint:enable no-console */
开发者ID:tyranid-org,项目名称:tyranid,代码行数:45,代码来源:server.ts

示例5: createTestData

test.before(async () => {
  const mongoClient = await mongodb.MongoClient.connect(
    `mongodb://127.0.0.1:27017/${dbName}`,
    { useNewUrlParser: true }
  );

  Tyr.config({
    mongoClient,
    db: mongoClient.db(),
    validate: [
      {
        dir: __dirname,
        fileMatch: 'models.js'
      }
    ]
  });

  await createTestData();
});
开发者ID:tyranid-org,项目名称:tyranid,代码行数:19,代码来源:index.ts

示例6: createTestData

test.before(async () => {
  const mongoClient = await mongodb.MongoClient.connect(
    'mongodb://127.0.0.1:27017/_tyranid_graphql_test',
    { useNewUrlParser: true }
  );

  Tyr.config({
    mongoClient,
    db: mongoClient.db(),
    validate: [
      {
        dir: __dirname,
        fileMatch: 'models.js'
      }
    ]
  });

  await createTestData();
  graphqlize(Tyr);
});
开发者ID:tyranid-org,项目名称:tyranid,代码行数:20,代码来源:index.ts

示例7: join

test.before(async t => {
  await Tyr.config({
    validate: [{ glob: join(__dirname, './models/*.js') }]
  });
  t.truthy(Tyr.collections.length);
});
开发者ID:tyranid-org,项目名称:tyranid,代码行数:6,代码来源:index.ts


注:本文中的tyranid.Tyr.config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。