Git Product home page Git Product logo

Comments (5)

mcavage avatar mcavage commented on May 1, 2024

Hi,

No this should definitely work (I do it). Here's a gist with a crude "serve up API docs from ./docs" set of routes from one of my projects. Not the most elegant (or error-resistant), but it should get you going: https://gist.github.com/1056404

Anyway, I'll leave this ticket open to fix the docs since you're the second or third person that's asked about this. Also, do you have a stack trace ? (if it's throwing TypeError because you're sending a buffer into res.send() et al, that's what it should do - if it's something else I'll clean it up).

m

from node-restify.

mcavage avatar mcavage commented on May 1, 2024

Closing this out.

from node-restify.

mullr avatar mullr commented on May 1, 2024

I case anyone else comes here for the same reason, I had at least initial success with the following (using restify 1.1.1):

var static = require('node-static');

file = new static.Server('./public');
server.get(/^\/.*/, function(req, res, next) {
  file.serve(req, res, next);
});

from node-restify.

tlevine avatar tlevine commented on May 1, 2024

@mullr's is great; the included static server almost as good, but it doesn't serve the index as I would expect.

from node-restify.

jedahan avatar jedahan commented on May 1, 2024

@tlevine To server up index, I used the built in static server

server.get /\/*/, restify.serveStatic directory: './static'

and then added early on

server.pre (req, res, next) ->
  req.url = '/index.html' if req.url is '/'
  next()

from node-restify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.