Skip to content

Commit e570df0

Browse files
author
Ilya Radchenko
committed
Add a basic server
1 parent e5bb54a commit e570df0

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
var server = require('./server');
4+
var port = process.env.PORT || 3000;
5+
6+
server.listen(port, function () {
7+
console.log('Server running on port %d', port);
8+
});

package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "testing-express-api",
3+
"version": "1.0.0",
4+
"description": "Testing Express APIs with Supertest",
5+
"main": "index.js",
6+
"scripts": {
7+
"start": "node index",
8+
"test": "node test"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/knownasilya/testing-express-api.git"
13+
},
14+
"keywords": [
15+
"testing",
16+
"express",
17+
"api",
18+
"supertest"
19+
],
20+
"author": "Ilya Radchenko <ilya@burstcreations.com>",
21+
"license": "ISC",
22+
"bugs": {
23+
"url": "https://github.com/knownasilya/testing-express-api/issues"
24+
},
25+
"homepage": "https://github.com/knownasilya/testing-express-api",
26+
"dependencies": {
27+
"express": "^4.11.2"
28+
},
29+
"devDependencies": {
30+
"supertest": "^0.15.0",
31+
"tape": "^3.5.0"
32+
}
33+
}

server/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
var express = require('express');
4+
var app = express();
5+
var users = ['John', 'Betty', 'Hal'];
6+
7+
app.get('/api/users', function (req, res) {
8+
res.json(users);
9+
});
10+
11+
module.exports = app;

0 commit comments

Comments
 (0)