Created
June 7, 2022 05:46
-
-
Save flashvnn/f155d595c30f586f605f2687b404c8f6 to your computer and use it in GitHub Desktop.
Totaljs http2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const spdy = require('spdy'); | |
const fs = require('fs'); | |
require('total4'); | |
// Registers a route | |
ROUTE('GET /', function() { | |
// this === Controller | |
this.json({ message: 'Hello world' }); | |
}); | |
var handlerRequest = function(req, res) { | |
F.serverless(req, res) | |
} | |
const options = { | |
key: fs.readFileSync('./server.key'), | |
cert: fs.readFileSync('./server.crt') | |
}; | |
spdy | |
.createServer(options, handlerRequest) | |
.listen(3000, (err) => { | |
if (err) { | |
throw new Error(err); | |
} | |
console.log('Listening on port: ' + 3000 + '.'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment