framework icon indicating copy to clipboard operation
framework copied to clipboard

Using serve-index middleware

Open sant123 opened this issue 9 years ago • 3 comments

Hi, I'm planning to switch an express application to total.js :). After I read the support of middlewares I thought I could use some packages for express in total.js (if total.js is based on connect for middlewares). However I don't find a way to make work this module.

I have the following code:

middleware.js

const serveIndex = require("serve-index");

F.middleware("serve-index", serveIndex("public/files", { "icons": true }));

uploadController.js

exports.install = function () {
    F.route("/files", ["#serve-index"])
}

Thank you, I'd appreciate your help!

sant123 avatar Sep 15 '17 07:09 sant123

Hi, great. Yes, you could but I don't recommend it.

  • Total.js supports handling of static files automatically (so /app/public/ are really public directory)
  • for Express you had to find some modules always, but Total.js contains all what you need
  • so don't find modules in NPM and always look to Total.js docs or write me on messenger.totaljs.com

petersirka avatar Sep 15 '17 07:09 petersirka

@sant123 Hi, there's a module for Total.js that does almost the same as serve-index. Check it out https://github.com/totaljs/modules/tree/master/Miscellaneous/directorylisting

molda avatar Sep 15 '17 07:09 molda

Everything working!!!!!. Thank you both for your help. :smile:

sant123 avatar Sep 15 '17 08:09 sant123