Update eject example to something more robust
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Documentación
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- node.js, typescript
- Área
- cli, documentation
Línea de trabajo
El issue no indica el archivo de plantilla de eject ni una prueba; empieza por localizar el ejemplo de eject en fastify-cli e inspeccionar cómo la aplicación generada registra plugins e inicia el servidor. Actualiza el ejemplo para validar el registro antes de empezar a escuchar y mostrar .ready(); estará terminado cuando el ejemplo generado refleje este flujo y las comprobaciones pertinentes pasen.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the feature has not already been requested
🚀 Feature Proposal
Change the eject file example to validate everything before running the server and make use of the .ready() function.
Motivation
What made me think of this approach are:
- Fastify encapsulation concept, the server should not run if something goes wrong with
pluginsand are not loaded inside correctly inside Fastify. - The struggle I've been in the past few days trying to use Fastify in a complex real-world project and I didn't find clear examples.
- easier to handle errors, if something goes wrong Fastify will throw the valid error not some error buried deep inside the router or hooks
- the unclear error "cannot read properties of undefined (reading 'length')" which was happening for several reasons and I cannot detect them until i throw error on startup
Example
// Read the .env file.
import * as dotenv from "dotenv";
dotenv.config();
// Require the framework
import Fastify from "fastify";
// Require library to exit fastify process, gracefully (if possible)
import closeWithGrace from "close-with-grace";
// Instantiate Fastify with some config
const app = Fastify({
logger: true,
});
// make use of the `.ready()` to prevent going on race condition
fastify.register(app).ready((err) => {
// throw error if something happened on registering `plugins` or `routes`
if (err) throw err;
// delay is the number of milliseconds for the graceful close to finish
const closeListeners = closeWithGrace(
{
delay:
parseInt(process.env.FASTIFY_CLOSE_GRACE_DELAY as string) ||
500,
},
async function ({ signal, err, manual }) {
if (err) {
fastify.log.error(err);
}
await fastify.close();
} as closeWithGrace.CloseWithGraceAsyncCallback
);
fastify.addHook("onClose", async (instance, done) => {
closeListeners.uninstall();
done();
});
//server listen
const port = process.env.PORT || 8000;
// Start listening.
fastify.listen({ port: parseInt(port as string) }, (err: any) => {
if (err) {
fastify.log.error(err);
process.exit(1);
}
});
});
- Lenguaje dominante
- JavaScript
- Estrellas
- 733
- Forks
- 179
- Merge medio
- 8 d 12 h
- PR fusionados (30 d)
- 2
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de fastify/fastify-cli
-
Allow to use custom templatesAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
fastify/fastify-cli#846 · 2 comentarios ·
-
Options propagationAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
fastify/fastify-cli#841 ·
-
Generated Fastify ESM/TS app has broken `npm test` command (FASTIFY_AUTOLOAD_TYPESCRIPT)Posiblemente ocupada @GhaythBenAbid la tomó hace 28 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
fastify/fastify-cli#835 · 2 comentarios ·
-
Adding Path Alias Support in fastify-cliQuizá libre de nuevo @ali139713 la tomó hace 51 días y no hay ningún pull request abierto. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
fastify/fastify-cli#806 · 1 comentario · 7 reacciones ·
-
Only watch specified directory (--watch CLI param)Posiblemente ocupada @josephreilly22 la tomó hace 240 días. Abiertogood first issue
Dificultad 3/5 1-2 días Aptitud para principiantes 38/100
fastify/fastify-cli#787 · 5 comentarios · 2 reacciones ·
Todos los issues de fastify/fastify-cli
Issues similares
-
t0ggles
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
nolimits4web/swiper#8240 · 1 comentario ·
-
netbox status: backlog topic: testing type: housekeeping
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
netbox-community/netbox#23395 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
[scanner] check:spelling skips blog/ — posts and author metadata are never spell-checkedPosiblemente ocupada @hivecommons-hive la tomó hoy. Abiertoagent/scanner bug hive/covered-by-pr hive/hosted-available-lke648397-260827-5n31
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
cncf/endusers#1452 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Edit: HTVKey.vnAbiertochannels:edit check:passed
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
Los mantenedores suelen responder en 6 días