-
-
Notifications
You must be signed in to change notification settings - Fork 173
Throw an error if serverPlugin is not defined #633
Copy link
Copy link
Closed
Labels
feature requestNew feature to be addedNew feature to be addedgood first issueGood for newcomersGood for newcomers
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the feature has not already been requested
🚀 Feature Proposal
Throw a well described exception if serverPlugin is not defined (node_modules/fastify-cli/util.js, requireServerPluginFromPath)
Motivation
Hi team,
I had followed Getting Started docs page, copied the code from 'You First Server' section and then used command to run a server from 'Run Your Server From CLI' section. The execution failed with the following exception:
TypeError: Cannot read properties of undefined (reading 'length')
at isInvalidAsyncPlugin (/Users/mbelsky/gh/xox-mm/node_modules/fastify-cli/util.js:45:17)
at requireServerPluginFromPath (/Users/mbelsky/gh/xox-mm/node_modules/fastify-cli/util.js:84:7)
at async runFastify (/Users/mbelsky/gh/xox-mm/node_modules/fastify-cli/start.js:90:12)
Then it took me some time to realize the start file must have an exported plugin. "fastify-cli" package version: 5.7.1
I believe adding a well described exception throw can help other users to spot the issue faster. If you find the proposal useful I'd like to implement it.
Example
if (!serverPlugin) {
throw new Error(`${resolvedModulePath} does not export a plugin function`)
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feature requestNew feature to be addedNew feature to be addedgood first issueGood for newcomersGood for newcomers