當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。