typicode / json-server

Get a full fake REST API with zero coding in less than 30 seconds (seriously)
Other
71.85k stars 6.92k forks source link

Http2 support #633

Open meriturva opened 6 years ago

meriturva commented 6 years ago

Any way to support http2 protocol?

Thanks. Diego

amard33p commented 4 years ago

Not possible until these issues are fixed in node: https://stackoverflow.com/questions/50819872/using-nodejs-10-http2-and-express-crashes https://github.com/expressjs/express/issues/3388 https://github.com/nodejs/node/issues/14672

andriy101 commented 3 years ago

I have it working with this code:

const jsonServer = require('json-server');`
const server = jsonServer.create();
const spdy = require('spdy');

const port = 8080;
spdy.createServer({
  key: fs.readFileSync(__dirname + '/localhost.key'),
  cert: fs.readFileSync(__dirname + '/localhost.crt')
}, server).listen(port, (error) => {
  if (error) {
    console.error(error);
  } else {
    console.log(`JSON Server is running on port ${port}`);
  }
});

Versions: "json-server": "^0.16.1" "spdy": "^4.0.2"