本文整理匯總了TypeScript中@nestjs/core.NestFactory.create方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript NestFactory.create方法的具體用法?TypeScript NestFactory.create怎麽用?TypeScript NestFactory.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@nestjs/core.NestFactory
的用法示例。
在下文中一共展示了NestFactory.create方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: bootstrap
async function bootstrap() {
//創建express 實例
const instance = express();
//middleware
instance.use(bodyParser.json());
instance.use(bodyParser.urlencoded({ extended: false }));
//NestFactory.create()接受一個模組引數,和一個可選的express實例引數,並返回Promise。
const app = await NestFactory.create(ApplicationModule, instance);
//swagger options
const options = new DocumentBuilder()
.setTitle('Users Restful API')
.setDescription('The users Restful API description')
.setVersion('1.0')
.addTag('users')
.build();
//restful API 文檔
const document = SwaggerModule.createDocument(app, options);
//打開http://localhost/api 就會連結到swagger服務。
SwaggerModule.setup('/api', app, document);
await app.listen(3000)
}
示例2: bootstrap
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.use(
session({
secret:'No sera de tomar un traguito',
resave: false,
saveUninitialized: true,
cookie: {secure: false},
name: 'server-session-id',
store: new FileStore()
})
);
app.use(cookieParser(
'me gustan los tacos', // secreto
{ // opciones
}
));
app.set('view engine', 'ejs');
app.use(
express.static('publico')
);
await app.listen(3000);
}
示例3: bootstrap
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.use(
express.static('publico')
);
await app.listen(3000);
}
示例4: bootstrap
async function bootstrap() {
const app = await NestFactory.create(AppModule, {
logger: console,
cors: true,
});
await app.useWebSocketAdapter(new WsAdapter(app)).listen(port);
}
示例5: bootstrap
async function bootstrap(): Promise<any> {
const app = await NestFactory.create(ApplicationModule, instance);
/* App filters. */
app.useGlobalFilters(new DispatchErrorFilter());
/* End of app filters. */
await app.listen(3000);
}
示例6: bootstrap
async function bootstrap(): Promise<void> {
const app = await NestFactory.create(M1cr0blogModule, { cors: true })
// Set up static content rendering
app.useStaticAssets(__dirname + '/static')
app.setBaseViewsDir(__dirname + '/views')
app.setViewEngine('hbs')
hbs.registerPartials(__dirname + '/views/partials')
hbs.registerHelper('unlessEquals', function(arg1, arg2, options) {
//@ts-ignore
return (arg1 != arg2) ? options.fn(this) : options.inverse(this);
})
hbs.registerHelper('replace', function(needle: string, newstr: string, options) {
//@ts-ignore
return options.fn(this).replace(needle, newstr)
})
// Set up Swagger
const options = new DocumentBuilder()
.setTitle('M1cr0blog API')
.setDescription('Backend REST API for m1cr0man\'s blog')
.setVersion('1.0')
.addTag('Users', 'User management system')
.addBearerAuth()
.build()
const document = SwaggerModule.createDocument(app, options)
SwaggerModule.setup('api/swagger', app, document)
await app.listen(3000)
}
示例7: bootstrap
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.use(cors());
app.useStaticAssets(join(__dirname, '..', 'public'));
await app.listen(app.get(ConfigService).port);
}
示例8: bootstrap
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.use(cookieParser('Max super perro',//secreto
{
//opciones
}));
await app.listen(3000);
}
示例9: bootstrap
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.use(cookieParser('me gusta los tacos',
{
}
));
await app.listen(3000);
}
示例10: bootstrap
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
app.useStaticAssets(join(__dirname, '..', 'public'));
app.setBaseViewsDir(join(__dirname, '..', 'views'));
app.setViewEngine('hbs');
await app.listen(3000);
}