-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow conigure local custom storage drivers #530
Comments
I'm having the same problem but bigger because I wrote my driver in typescript and can't even use the workaround because it only gets bundled into the server and is not importable |
I had a look in the code and it is definitely more complicated than just adding the pure driver factory to the type definition because they use the string to generate the variable name and use dynamic imports |
I am facing the same problem trying to use a Custom Driver. Any updates on that issue? |
I have the same problem. Does nitro support Custom Driver? |
You should use an absolute path for your custom driver location : import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
export default defineNitroConfig({
storage: {
"custom-db": {
driver: resolve(
dirname(fileURLToPath(import.meta.url)),
"unstorage/custom-driver.ts"
),
},
},
}); |
It worked for me. But I think we should support using I would like to help if we have a plan to support this. |
It supports typescript files. You can replace |
Environment
nitropack@0.4.24
$ node --version
v16.17.0
Reproduction
Follow the example of unstorage https://github.com/unjs/unstorage#making-custom-drivers
I used the original memory driver as "custom driver"
Describe the bug
The current interface for storage options is:
but unstorage allows the use of custom drivers and we are not using them.
Additional context
I found https://github.com/unjs/nitro/blob/main/src/rollup/plugins/storage.ts
on line 47
${driverImports.map(i => genImport(i, genSafeVariableName(i))).join('\n')}
I am not quite sure if that means we should do the following
This kind of complex and error prone
We should allow the user to pass in the driver directly and just
driver:new Driver({})
Logs
No response
The text was updated successfully, but these errors were encountered: