Skip to content

Instantly share code, notes, and snippets.

@peterkellydev
Last active April 9, 2018 17:23
Show Gist options
  • Save peterkellydev/e56be6f2f6f5b892d436c76c07fead34 to your computer and use it in GitHub Desktop.
Save peterkellydev/e56be6f2f6f5b892d436c76c07fead34 to your computer and use it in GitHub Desktop.
simpleapi
var express = require("express");
var bodyParser = require("body-parser");
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.get("/", function(req, res) {
res.status(200).send("Welcome to our restful API");
});
var server = app.listen(3000, function() {
console.log("app running on port.", server.address().port);
});
function sum(x, y) {
return x + y;
}
module.exports = sum;
var test = require("tape");
var sum_test = require("../app.js");
test("sum test", function(t) {
var s = sum_test(3, 4);
t.equal(s, 7);
t.end();
});
test("sum negative test", function(t) {
var s = sum_test(-3, -4);
t.equal(s, -7);
t.end();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment