-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Fastify is not implemented yet #9
Comments
I'll try to add support for Fastify in the upcoming days, first I need to learn how Fastify serves a static file |
nice |
Any updates regading the implementation of Fastify? |
@JoeyyT you dont need this. see example:
import { join } from 'path';
import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import {
FastifyAdapter,
NestFastifyApplication,
} from '@nestjs/platform-fastify';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
new FastifyAdapter(),
);
app.useGlobalPipes(
new ValidationPipe({
transform: true,
}),
);
app.setGlobalPrefix('v1');
app.useStaticAssets({
root: join(__dirname, '..', 'public'),
prefix: '/public/',
});
app.setViewEngine({
engine: {
handlebars: require('handlebars'),
},
templates: join(__dirname, '..', 'views'),
});
const config = new DocumentBuilder()
.setTitle('Title')
.setDescription('API description')
.setVersion('1.0')
.build();
const document = SwaggerModule.createDocument(app, config);
document.info['x-logo'] = {
url: '/public/logo-light.svg',
backgroundColor: '#F0F0F0',
altText: 'Logo',
};
document.info['x-tagGroups'] = [
{
name: 'Catalog resources',
tags: ['catalog'],
},
];
SwaggerModule.setup('api', app, document);
await app.listen(3000, '0.0.0.0');
}
bootstrap();
import { Controller, Get, Header, Headers, Render } from '@nestjs/common';
import { ApiExcludeEndpoint, ApiTags } from '@nestjs/swagger';
import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
@ApiExcludeEndpoint()
getHello(): string {
return this.appService.getHello();
}
@Get('/docs')
@Render('redoc.handlebars')
@Header(
'Content-Security-Policy',
"default-src * 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; child-src * 'unsafe-inline' 'unsafe-eval' blob:; worker-src * 'unsafe-inline' 'unsafe-eval' blob:; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * 'unsafe-inline';",
)
@ApiExcludeEndpoint()
getDocs() {
return {
data: {
docUrl: 'http://localhost:3000/api/json',
favicon: '/public/icon.svg',
options: JSON.stringify({
theme: {
logo: {
gutter: '15px',
},
},
sortPropsAlphabetically: true,
hideDownloadButton: false,
hideHostname: false,
noAutoAuth: true,
pathInMiddlePanel: true,
}),
},
};
}
}
<!DOCTYPE html>
<html>
<head>
<title>{{ data.title }}</title>
<!-- needed for adaptive design -->
<meta charset="utf-8" />
{{#if data.favicon}}
<link rel="shortcut icon" type="image/x-icon" href="{{ data.favicon }}" />
{{/if}}
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
<!--
ReDoc doesn't change outer page styles
-->
<style>
body {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<!-- we provide is specification here -->
<div id="redoc_container"></div>
<script src="https://cdn.jsdelivr.net/npm/redoc/bundles/redoc.standalone.js"> </script>
<script>
Redoc.init(
'{{ data.docUrl }}',
JSON.parse('{{{ data.options }}}'),
document.getElementById("redoc_container")
);
</script>
</body>
</html> Just access |
Is there any progress on this? |
any progress on this? 2 years have passed... please |
@ojoanalogo is there any current progress or future road-map to support Fastify in nestjs-redoc ? |
Hi, I just created a library that supports Redoc using NestJS 10 and fastify: nestjs-redox |
No description provided.
The text was updated successfully, but these errors were encountered: