本文整理汇总了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' }
]
});
});
示例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 => {
示例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);
}
示例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 */
示例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();
});
示例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);
});
示例7: join
test.before(async t => {
await Tyr.config({
validate: [{ glob: join(__dirname, './models/*.js') }]
});
t.truthy(Tyr.collections.length);
});