Created
June 13, 2016 02:50
-
-
Save tanner0101/8880b7a030fb0e9590c4f0167c02d069 to your computer and use it in GitHub Desktop.
Express Benchmark
This file contains hidden or 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 express = require('express'); | |
const app = express(); | |
const sqlite3 = require('sqlite3'); | |
const db = new sqlite3.Database('../database/test.sqlite'); | |
app.get('/plaintext', function(req, res) { | |
res.setHeader('Content-Type', 'text/plain'); | |
res.send('Hello, World!'); | |
}); | |
app.get('/json', function(req, res) { | |
res.send({ | |
array: [1, 2, 3], | |
dict: { | |
one: 1, | |
two: 2, | |
'three': 3 | |
}, | |
int: 42, | |
string: 'test', | |
double: 3.14, | |
'null': null | |
}); | |
}); | |
app.get('/sqlite-fetch', function(req, res) { | |
db.get('select * from users where id = ?', Math.floor(Math.random() * 3) + 1, function(err, row) { | |
if(err) { | |
res.send(err.message); | |
} else { | |
res.send(row); | |
} | |
}); | |
}); | |
module.exports = { | |
app: app, | |
port: 8400 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment