Browse Source

Test driven development. (#41)

master
Eric Lang 3 years ago
committed by GitHub
parent
commit
0fe1c44287
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 13 deletions
  1. +14
    -8
      server/package.json
  2. +2
    -0
      server/routes/api/index.js
  3. +1
    -1
      server/routes/api/v2.js
  4. +11
    -0
      server/routes/test/v2.js
  5. +0
    -0
      server/run.sh
  6. +8
    -4
      server/server.js

+ 14
- 8
server/package.json View File

@ -1,28 +1,34 @@
{ {
"name": "github-graphs", "name": "github-graphs",
"version": "0.0.1",
"version": "0.0.2",
"description": "Generates graphs of github things.", "description": "Generates graphs of github things.",
"main": "server.js", "main": "server.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
"test": "mocha routes/test --exit --reporter spec",
"start": "node server.js" "start": "node server.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/jrtechs/github-graphs.git" "url": "git+https://github.com/jrtechs/github-graphs.git"
}, },
"author": "Jeffery Russell",
"author": "Jeffery Russell, Eric Lang",
"license": "ISC", "license": "ISC",
"bugs": { "bugs": {
"url": "https://github.com/jrtechs/github-graphs/issues" "url": "https://github.com/jrtechs/github-graphs/issues"
}, },
"homepage": "https://github.com/jrtechs/github-graphs#readme", "homepage": "https://github.com/jrtechs/github-graphs#readme",
"dependencies": { "dependencies": {
"dotenv": "^8.2.0",
"express": "^4.16.4",
"express-session": "^1.15.6",
"dotenv": "~8.2.0",
"express": "~4.16.4",
"express-session": "~1.15.6",
"fs": "0.0.1-security", "fs": "0.0.1-security",
"got": "^9.6.0",
"memory-cache": "^0.2.0"
"got": "~9.6.0",
"memory-cache": "~0.2.0"
},
"devDependencies": {
"coveralls": "*",
"mocha": "*",
"nyc": "*"
} }
} }

+ 2
- 0
server/routes/api/index.js View File

@ -0,0 +1,2 @@
exports.V1 = require('./v1');
exports.V2 = require('./v2');

+ 1
- 1
server/routes/api/v2.js View File

@ -307,4 +307,4 @@ routes.get('/*', (request, result) =>
} }
}); });
module.exports = routes;
module.exports = routes;

+ 11
- 0
server/routes/test/v2.js View File

@ -0,0 +1,11 @@
const assert = require('assert');
const V2 = require('../api/v2');
describe('github api v2', function() {
it('successfully queries friends', async function() {
var queryFriends = V2.queryFriends;
// it was this point that Eric realized he doesn't understand
// module.exports very well.
assert.strictEqual(typeof(queryFriends), typeof(queryFriends));
});
});

+ 0
- 0
server/run.sh View File


+ 8
- 4
server/server.js View File

@ -1,10 +1,14 @@
const crypto = require('crypto');
const app = express();
const dotenv = require("dotenv").config();
const express = require("express"); const express = require("express");
const session = require('express-session'); const session = require('express-session');
const dotenv = require("dotenv").config();
const app = express();
const sessionProperties = { const sessionProperties = {
secret: process.env.SESSION_SECRET,
secret: process.env.SESSION_SECRET || crypto.randomBytes(64),
cookie: { maxAge: 6000000 }, cookie: { maxAge: 6000000 },
resave: false, resave: false,
saveUninitialized: false saveUninitialized: false
@ -18,4 +22,4 @@ const routes = require('./routes');
app.use('/', routes); app.use('/', routes);
app.listen(process.env.PORT, () => console.log(`App listening on port ${process.env.PORT}!`));
app.listen(process.env.PORT || 8100, () => console.log(`App listening on port ${process.env.PORT || 8100}!`));

Loading…
Cancel
Save