UNPKG

@practica/create-node-app

Version:

Create Node.js app that is packed with best practices AND strive for simplicity

21 lines (18 loc) 802 B
import { logger } from '@practica/logger'; import { AppError, errorHandler } from '@practica/error-handling'; import { startWebServer } from './entry-points-fastify/api/server'; async function start() { // 🦉 Array of entry point is being used to support more entry-points kinds like message queue, scheduled job, return Promise.all([startWebServer()]); } start() .then((startResponses) => { logger.info(`The app has started successfully ${startResponses}}`); }) .catch((error) => { // ️️️✅ Best Practice: A failure during startup is catastrophic and should lead to process exit (you may retry before) // Consequently, we flag the error as catastrophic errorHandler.handleError( new AppError('startup-failure', error.message, 500, false, error) ); });