-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Add support for browser File systems #3
Comments
So currently Wayne doesn't allow this? I was looking for a simple way to do this, thought the git terminal webapp already did it |
Yes, the git web terminal does this, I only need to extract the logic and put it into this library. And also allow using both FS libraries. |
But if you want this feature you can easily do this yourself by hand, but it will take longer to write. I want to make this easier. |
I see :( thanks for the answer. I think I will just extract the code from one of the projects that to that (if I start from your git terminal I'll credit you ofc), I just need that very specific functionality and it would take more time to analyze Wayne and find out how to integrate it with it (esp. considering that I don't think I would use anything else from Wayne in my project) |
Wayne is a very small library ~200LOC. It only adds a wrapper over service worker so if you would like to have a file system from indexedDB you will need to use a big part of the library. I though that to create FS support you would just add a single get request: app.get('/__fs__/{path}', function(req, res) {
// read path if it's directory return list of links
// if it's a file return a file with proper MIME type
}); But unfortunately |
By "only matches a single directory" you mean it does not work with subdirectories? |
Yes the parameter when using I need to check how express.js is doing this and do the same. And if it does the same, I need to come up with a syntax that will allow matching the whole path, when needed. |
Interesting. And why can't you do it like you did with the git web terminal? |
I can, this is what this issue is for. |
Oh I see, you were trying to find a simpler solution with the example you posted before 👍 |
Yes, the task is to simplify what the git web terminal is doing, so users can do this with a single line if possible. |
It seems that express.js work the same: const express = require("express");
const app = express();
app.get('/__fs__/:path', function(req, res) {
res.send(req.params.path);
});
app.listen(8080, () => {
console.log("listening on 8080...");
}); This return 404 for |
But you can use: app.get('/__fs__/*', function(req, res) {
res.send(req.params[0]);
}); So I need to add an asterisk as a glob. |
glob path was added in version 0.4.0 |
Filesystem is ready, the code looks like this: import { Wayne, FileSystem } from 'https://cdn.jsdelivr.net/npm/@jcubic/wayne';
import FS from "https://cdn.skypack.dev/@isomorphic-git/lightning-fs";
import mime from "https://cdn.skypack.dev/mime";
import path from "https://cdn.skypack.dev/path-browserify";
const { promises: fs } = new FS("__wayne__");
const app = new Wayne();
app.use(FileSystem({ path, fs, mime, prefix: '__fs__' })); when using ES Modules and only promisified FS is supported. |
It should work with:
BrowserFSIt should work similar to express, maybe something like:
It will require adding middleware maybe I will steal the API and architecture from express.js.
ref: https://www.npmjs.com/package/mime
The text was updated successfully, but these errors were encountered: