Skip to content

Commit 0cebf0a

Browse files
author
Max Beatty
committed
hello world
0 parents  commit 0cebf0a

13 files changed

+195
-0
lines changed

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"env": {
3+
"node": true
4+
}
5+
}

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
coverage.html
3+
lcov.info

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
iojs-v1.2.0

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: node_js
2+
node_js:
3+
- iojs

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
test:
2+
@node node_modules/lab/bin/lab -L
3+
test-cov:
4+
@node node_modules/lab/bin/lab -c -L -r lcov -o lcov.info
5+
test-cov-html:
6+
@node node_modules/lab/bin/lab -r html -o coverage.html
7+
8+
.PHONY: test test-cov test-cov-html

README.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# jsperf.com
2+
3+
[![Build Status](https://travis-ci.org/jsperf/jsperf.com.svg?branch=master)](https://travis-ci.org/jsperf/jsperf.com)
4+
5+
## How to run a local copy of jsPerf for testing/debugging
6+
7+
### Prerequisites
8+
9+
You'll need [io.js](https://iojs.org/en/index.html) and [mysql](https://www.mysql.com/downloads/) installed.
10+
11+
1. Clone the repository (`git clone https://github.com/jsperf/jsperf.com.git`)
12+
2. Install dependencies (`npm install`)
13+
14+
### Environment Variables
15+
16+
You'll need to provide the following environment variables:
17+
18+
- `PORT`
19+
20+
### Run
21+
22+
```
23+
npm start
24+
```
25+
26+
## Testing
27+
28+
We use [lab](https://github.com/hapijs/lab) as our test utility and [code](https://github.com/hapijs/code) as our assertion library. Lab enforces linting with [eslint](http://eslint.org/). To run the test suite:
29+
30+
```
31+
make test
32+
```
33+
34+
### Coverage
35+
36+
When [travis-ci](https://travis-ci.org) runs the tests, it enforces 100% code coverage. You can run this locally with either `make test-cov` or `npm test`
37+
38+
#### HTML Report
39+
40+
To generate an HTML report with code coverage, run `make test-cov-html`

index.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"use strict";
2+
3+
var Hapi = require("hapi");
4+
5+
var server = new Hapi.Server();
6+
server.connection({ port: process.env.PORT });
7+
8+
server.route({
9+
method: "GET",
10+
path: "/",
11+
handler: function (request, reply) {
12+
reply("Hello, world!");
13+
}
14+
});
15+
16+
module.exports = server;

package.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "jsperf.com",
3+
"version": "0.0.0",
4+
"description": "jsPerf aims to provide an easy way to create and share test cases, comparing the performance of different JavaScript snippets by running benchmarks",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "make test-cov"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "[email protected]:jsperf/jsperf.com.git"
12+
},
13+
"keywords": [
14+
"jsperf"
15+
],
16+
"contributors": [
17+
"Max Beatty"
18+
],
19+
"bugs": {
20+
"url": "https://github.com/jsperf/jsperf.com/issues"
21+
},
22+
"homepage": "https://github.com/jsperf/jsperf.com",
23+
"dependencies": {
24+
"good": "^5.1.2",
25+
"good-console": "^4.1.0",
26+
"hapi": "^8.2.0"
27+
},
28+
"devDependencies": {
29+
"code": "^1.3.0",
30+
"lab": "^5.2.1"
31+
}
32+
}

server.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"use strict";
2+
3+
var Good = require("good");
4+
var server = require("./index.js");
5+
6+
server.register({
7+
register: Good,
8+
options: {
9+
reporters: [{
10+
reporter: require("good-console"),
11+
args: [{
12+
log: "*",
13+
response: "*"
14+
}]
15+
}]
16+
}
17+
}, function(err) {
18+
if (err) {
19+
throw err;
20+
}
21+
22+
server.start(function() {
23+
server.log("info", "Server running at: " + server.info.uri);
24+
});
25+
});

test/index.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"use strict";
2+
3+
var Code = require("code");
4+
var Lab = require("lab");
5+
var server = require("../index");
6+
7+
var lab = exports.lab = Lab.script();
8+
9+
lab.experiment("Index", function () {
10+
11+
lab.before(function (done) {
12+
done();
13+
});
14+
15+
lab.beforeEach(function (done) {
16+
done();
17+
});
18+
19+
lab.test("main endpoint returns hello world", function (done) {
20+
server.inject({
21+
method: "GET",
22+
url: "/"
23+
}, function(response) {
24+
var result = response.result;
25+
26+
Code.expect(response.statusCode).to.equal(200);
27+
Code.expect(result).to.equal("Hello, world!");
28+
29+
done();
30+
});
31+
});
32+
});

test/server.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"use strict";
2+
3+
var Lab = require("lab");
4+
5+
var lab = exports.lab = Lab.script();
6+
7+
lab.experiment("Server", function () {
8+
9+
lab.before(function (done) {
10+
done();
11+
});
12+
13+
lab.beforeEach(function (done) {
14+
done();
15+
});
16+
17+
lab.test("register good plugin", function (done) {
18+
done();
19+
});
20+
});

0 commit comments

Comments
 (0)