Comments (20)
I fixed it in start.js file by changing that below line (|| instead of &&), however a bit busy to submit PR
- if (opts.options && file.options) {
+ if (opts.options || file.options) {
options = deepmerge(options, file.options)
}
from fastify-cli.
You should assign the options
to app.options
instead of exporting in the end.
from fastify-cli.
There is two people checked the library is working correctly. Only you are the person that say it is not working.
Please provide a reproducible repository like what dancastillo did.
@mcollina I would say there is no bug
here, may be misconfiguration on author side. However, I don't have permission to this repository. Could you helps to remove both bug
and first good issue
unless a proper reproducible repository
is provided. Thanks.
from fastify-cli.
I don't know why you added in dev
in first place.
My git diff is showing it should be added in dev:start
and start
.
Anyway, it works on your side now.
from fastify-cli.
Thanks for reporting! Fixing this should be easy, it’s likely we are missing some ways to move this option through.
from fastify-cli.
Would you like to send a PR?
from fastify-cli.
@frodoe7 if you update your script in pacakge.json
to include --options
should work
"start": "fastify start -l info app.js --options",
"dev": "fastify start -w -l info -P app.js --options"
from fastify-cli.
@dancastillo and where to add caseSensitive prop?
because I tested also with --options and did not work
the start.js file not pass the options
from fastify-cli.
You should provide the whole index.ts
/ app.js
to show how you export the value.
from fastify-cli.
@climba03003
here's the whole app.ts file
import { join } from 'path';
import AutoLoad, {AutoloadPluginOptions} from '@fastify/autoload';
import { FastifyPluginAsync } from 'fastify';
export type AppOptions = {
// Place your custom options for app below here.
caseSensitive: boolean
} & Partial<AutoloadPluginOptions>;
// Pass --options via CLI arguments in command to enable these options.
const options: AppOptions = {
caseSensitive: false,
}
const app: FastifyPluginAsync<AppOptions> = async (
fastify,
opts
): Promise<void> => {
// Place here your custom code!
// Do not touch the following lines
// This loads all plugins defined in plugins
// those should be support plugins that are reused
// through your application
void fastify.register(AutoLoad, {
dir: join(__dirname, 'plugins'),
options: opts
});
// This loads all plugins defined in routes
// define your routes in one of these
void fastify.register(AutoLoad, {
dir: join(__dirname, 'routes'),
options: opts
});
};
export default app;
export { app, options }
from fastify-cli.
options is not a member of app,
here we talk about the generated template from CLI, not when you use Fastify from scratch
from fastify-cli.
@mcollina
Can you look into that PR, should fix that issue?
from fastify-cli.
options is not a member of app,
It is where this library expect the options
to be but not FastifyPluginAsync
types expect it.
Use @ts-ignore
to see what is the outcome.
fastify-cli
may not really fit all the expected types on fastify
.
here we talk about the generated template from CLI, not when you use Fastify from scratch
No one is talking about using fastify from scratch.
from fastify-cli.
Tested with ts-ignore
It's not a fix for the issue
from fastify-cli.
Have you also use the --options
flag when starting the application?
Just a git diff to show how it should works.
diff --git a/package.json b/package.json
index ef7aaa1..3cc02c4 100644
--- a/package.json
+++ b/package.json
@@ -8,11 +8,11 @@
},
"scripts": {
"test": "npm run build:ts && tsc -p test/tsconfig.json && c8 node --test -r ts-node/register test/**/*.ts",
- "start": "npm run build:ts && fastify start -l info dist/app.js",
+ "start": "npm run build:ts && fastify start -l info dist/app.js --options",
"build:ts": "tsc",
"watch:ts": "tsc -w",
"dev": "npm run build:ts && concurrently -k -p \"[{name}]\" -n \"TypeScript,App\" -c \"yellow.bold,cyan.bold\" \"npm:watch:ts\" \"npm:dev:start\"",
- "dev:start": "fastify start --ignore-watch=.ts$ -w -l info -P dist/app.js"
+ "dev:start": "fastify start --ignore-watch=.ts$ -w -l info -P dist/app.js --options"
},
"keywords": [],
"author": "",
@@ -32,4 +32,4 @@
"fastify-tsconfig": "^2.0.0",
"typescript": "^5.2.2"
}
-}
\ No newline at end of file
+}
diff --git a/src/app.ts b/src/app.ts
index 58aabb6..6ab3b75 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -1,12 +1,13 @@
-import { join } from 'path';
-import AutoLoad, {AutoloadPluginOptions} from '@fastify/autoload';
+import AutoLoad, { AutoloadPluginOptions } from '@fastify/autoload';
import { FastifyPluginAsync, FastifyServerOptions } from 'fastify';
+import { join } from 'path';
export interface AppOptions extends FastifyServerOptions, Partial<AutoloadPluginOptions> {
}
// Pass --options via CLI arguments in command to enable these options.
const options: AppOptions = {
+ caseSensitive: false
}
const app: FastifyPluginAsync<AppOptions> = async (
@@ -35,4 +36,5 @@ const app: FastifyPluginAsync<AppOptions> = async (
};
export default app;
-export { app, options }
+export { app, options };
from fastify-cli.
@climba03003 Still not works and not a solution, did you test that solution by yourself?
from fastify-cli.
@frodoe7 here is demo repo with working example. Specific changes were in this commit
from fastify-cli.
@climba03003 really? Okay
It's still not working with your suggestion, it worked only when I implemented that change #687 (comment)
anyway, I used patch-package to apply that change, in case no intention to fix it
from fastify-cli.
It's still not working with your suggestion
Just saying it is not working do not helps to move thing forward.
Providing a reproducible repository
is what we would like to see and investigate.
from fastify-cli.
It worked when I added --options
in dev:start instead of dev
in package.json
from fastify-cli.
Related Issues (20)
- Allow add plugin to main process scope ( not app.js scope ), without eject the project. HOT 1
- Allow `build` from `'fastify-cli/helper.js'` to accept an existing module object
- Add support for generate-swagger to generate in YAML format HOT 3
- TypeScript Option Produces Inoperable Code - Bundled TypeScript Version? HOT 1
- Cannot use --require option is ESM project HOT 3
- Logger not loading after conversion to ES module HOT 3
- Generated project doesn't work out of the box with --esm --lang=ts HOT 2
- Need better `eject`
- Can't add schema to route HOT 1
- Generate plugin nitpicks to work out of the box
- Core plugin installation utility HOT 4
- package.json file already exists in target directory HOT 2
- c8 dependency is not added with fastify generate project_name --lang=ts HOT 1
- How to configure project to run as https in development mode HOT 2
- How to run a fastify server in production HOT 2
- Watcher is not working on builders
- Does Platformatic Replace fastify-cli ? HOT 1
- Dependency update for v5
- with 'nom run start' error: Missing the required file parameter shows up
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 fastify-cli.