Comments (9)
Is there any progress on this?
from nestjs-redoc.
I'll try to add support for Fastify in the upcoming days, first I need to learn how Fastify serves a static file
from nestjs-redoc.
@JoeyyT you dont need this.
see example:
main.ts
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();
app.controller.ts
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,
}),
},
};
}
}
views/redoc.handlebars
Just access /v1/docs
and be happy
from nestjs-redoc.
any progress on this? 2 years have passed... please
from nestjs-redoc.
https://github.com/fastify/fastify-static
from nestjs-redoc.
nice
from nestjs-redoc.
Any updates regading the implementation of Fastify?
from nestjs-redoc.
@ojoanalogo is there any current progress or future road-map to support Fastify in nestjs-redoc ?
from nestjs-redoc.
Hi, I just created a library that supports Redoc using NestJS 10 and fastify: nestjs-redox
from nestjs-redoc.
Related Issues (20)
- Incompatibility with Nest MVC techniques HOT 3
- "Patch" version bump should have been major HOT 4
- Cannot run the 'app' in RedocModule.setup(); HOT 7
- How to secure docs route? HOT 5
- NestJS v7 issue HOT 5
- TypeError: Cannot read property 'enabled' of undefined HOT 1
- multiple security HOT 2
- Cant load swagger file in Nest app running with url prefix
- Update to NestJS 8 HOT 5
- Custom fonts or specify html template
- TagGroups `namespaces` HOT 1
- example does not work in ApiHeader HOT 1
- Question: How to add custom tags with custom description? HOT 3
- Some features on the page are very slow
- Sync redoc options
- Maintained HOT 4
- Update to NestJS 9 HOT 14
- Fastify support HOT 2
- swagger.json not secured HOT 1
- New library supporting NestJS 10, ExpressJS & Fastify, multi-user basic auth and more
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nestjs-redoc.