Skip to content

Instantly share code, notes, and snippets.

@tanner0101
Created June 13, 2016 02:50
Show Gist options
  • Save tanner0101/8880b7a030fb0e9590c4f0167c02d069 to your computer and use it in GitHub Desktop.
Save tanner0101/8880b7a030fb0e9590c4f0167c02d069 to your computer and use it in GitHub Desktop.
Express Benchmark
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