Skip to content
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

Serve static files without using express #29

Closed
daquinoaldo opened this issue Oct 1, 2019 · 10 comments
Closed

Serve static files without using express #29

daquinoaldo opened this issue Oct 1, 2019 · 10 comments
Labels
feature New feature or request good first issue Good for newcomers hacktoberfest
Milestone

Comments

@daquinoaldo
Copy link
Owner

Rewrite the app.serve function at row 61 in index.js so that will serve static files without using express.js.

You'll be mentioned as a contributor.
Happy Hacktoberfest!

@daquinoaldo daquinoaldo added feature New feature or request good first issue Good for newcomers hacktoberfest labels Oct 1, 2019
@prkhrv
Copy link

prkhrv commented Oct 1, 2019

Can use node-static?

@HeyIts-RJ
Copy link

HeyIts-RJ commented Oct 1, 2019

Hello, I try to resolve your issue by using the native file system module not express. Please check it and merge it if it is right.

Here is my methodology to implementation
`
var fs = require('fs'),
http = require('http');

http.createServer(function (req, res) {
 fs.readFile(__dirname + req.url, function (err,data) {
if (err) {
  res.writeHead(404);
  res.end(JSON.stringify(err));
  return;
}
res.writeHead(200);
res.end(data);
 });
}).listen(8080);

`

@daquinoaldo
Copy link
Owner Author

daquinoaldo commented Oct 1, 2019

@prkhrv I would like to remove as many dependencies as possible from my package. node-static is pretty lightweight, but I prefer a native solution if it is possible.

Actually, I prefer @HeyIts-RJ's solution (#30). I have to review the code with more attention, probably this evening (CET timezone).
Could you please fix the linter errors, so that I can better test it? Give a look to the GitHub Actions CI or just run npm t on your fork.
Also, even if its a developer tool, JSON.stringify(err) could probably be rewritten in a more user-friendly way.

@HeyIts-RJ
Copy link

Alright @daquinoaldo I will fix the linter error and actually I'm thinking to remove JSON.stringify(err)

@HeyIts-RJ
Copy link

@daquinoaldo I fixed the linter errors and warning in my last commit.

@daquinoaldo daquinoaldo added this to the v5.0.0 milestone Oct 1, 2019
@daquinoaldo
Copy link
Owner Author

@HeyIts-RJ take a look at my comment on #30. Can you implement it?
If you think it is too complex we can use node-static as suggested by @prkhrv.

@HeyIts-RJ
Copy link

Give me some time for it @daquinoaldo I think I'm moving in right direction.

@daquinoaldo
Copy link
Owner Author

Sure, no problem

@daquinoaldo
Copy link
Owner Author

Someone wants to help @HeyIts-RJ with #30 or whish to propose its own solution?

@HeyIts-RJ
Copy link

Someone wants to help @HeyIts-RJ with #30 or whish to propose its own solution?

Alright. It's open for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request good first issue Good for newcomers hacktoberfest
Projects
None yet
Development

No branches or pull requests

3 participants