Express framework is so huge, are there any cases where I should prefer http.createServer() over Express .get and .post?
express seems rather tiny to me, compared with other packages.
One use case where even this package seems not justified is if I have to start up an http server only for one interaction, such as authenticating a desktop app with OAuth 2.0 with localhost as the loopback URI.
The following code snippet illustrates this, and also shows that code = req.query.code (which would be possible with express) must be replaced with something lengthier:
var oAuth2Client = new google.auth.OAuth2(...);
var loopback = http.createServer(function(req, res) {
var code = new URL("http://" + req.url).searchParams.get("code");
if (code) {
oAuth2Client.getToken(code, (err, token) => {
oAuth2Client.setCredentials(token);
res.end();
});
loopback.close();
}
}).listen(...);