Ind.ie is now Small Technology Foundation.
Commit 6fdbe016 authored by Aral Balkan's avatar Aral Balkan

Clean up test output and use Winston for logs

parent ac23508e
{
"host": "localhost",
"port": 3030,
"public": "../public/",
"paginate": {
"default": 10,
"max": 50
}
}
......@@ -1922,6 +1922,30 @@
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
},
"jade": {
"version": "0.26.3",
"resolved": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz",
"integrity": "sha1-jxDXl32NefL2/4YqgbBRPMslaGw=",
"dev": true,
"requires": {
"commander": "0.6.1",
"mkdirp": "0.3.0"
},
"dependencies": {
"commander": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-0.6.1.tgz",
"integrity": "sha1-+mihT2qUXVTbvlDYzbMyDp47GgY=",
"dev": true
},
"mkdirp": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz",
"integrity": "sha1-G79asbqCevI1dRQ0kEJkVfSB/h4=",
"dev": true
}
}
},
"js-tokens": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz",
......@@ -2091,6 +2115,106 @@
"resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz",
"integrity": "sha1-8atrg5KZrUj3hKu/R2WW8DuRTTs="
},
"log-suppress": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/log-suppress/-/log-suppress-1.0.3.tgz",
"integrity": "sha1-p4093l3QD4rzO1LpK3DFTDk6Gzs=",
"dev": true,
"requires": {
"mocha": "2.5.3"
},
"dependencies": {
"commander": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.3.0.tgz",
"integrity": "sha1-/UMOiJgy7DU7ms0d4hfBHLPu+HM=",
"dev": true
},
"debug": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz",
"integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=",
"dev": true,
"requires": {
"ms": "0.7.1"
}
},
"diff": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz",
"integrity": "sha1-fyjS657nsVqX79ic5j3P2qPMur8=",
"dev": true
},
"escape-string-regexp": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz",
"integrity": "sha1-Tbwv5nTnGUnK8/smlc5/LcHZqNE=",
"dev": true
},
"glob": {
"version": "3.2.11",
"resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz",
"integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=",
"dev": true,
"requires": {
"inherits": "2.0.3",
"minimatch": "0.3.0"
}
},
"growl": {
"version": "1.9.2",
"resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz",
"integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=",
"dev": true
},
"lru-cache": {
"version": "2.7.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz",
"integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=",
"dev": true
},
"minimatch": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz",
"integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=",
"dev": true,
"requires": {
"lru-cache": "2.7.3",
"sigmund": "1.0.1"
}
},
"mocha": {
"version": "2.5.3",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-2.5.3.tgz",
"integrity": "sha1-FhvlvetJZ3HrmzV0UFC2IrWu/Fg=",
"dev": true,
"requires": {
"commander": "2.3.0",
"debug": "2.2.0",
"diff": "1.4.0",
"escape-string-regexp": "1.0.2",
"glob": "3.2.11",
"growl": "1.9.2",
"jade": "0.26.3",
"mkdirp": "0.5.1",
"supports-color": "1.2.0",
"to-iso-string": "0.0.2"
}
},
"ms": {
"version": "0.7.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz",
"integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=",
"dev": true
},
"supports-color": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.2.0.tgz",
"integrity": "sha1-/x7R5hFp0Gs88tWI4YixjYhH4X4=",
"dev": true
}
}
},
"lru-cache": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz",
......@@ -2857,6 +2981,12 @@
"rechoir": "0.6.2"
}
},
"sigmund": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz",
"integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=",
"dev": true
},
"signal-exit": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
......@@ -3316,6 +3446,12 @@
"os-tmpdir": "1.0.2"
}
},
"to-iso-string": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/to-iso-string/-/to-iso-string-0.0.2.tgz",
"integrity": "sha1-TcGeZk38y+Jb2NtQiwDG2hWCVdE=",
"dev": true
},
"tough-cookie": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz",
......
......@@ -22,7 +22,7 @@
"npm": ">= 3.0.0"
},
"scripts": {
"test": "npm run mocha",
"test": "npm run -s mocha",
"eslint": "eslint src/. test/. --config .eslintrc.json",
"start": "nodemon src/",
"mocha": "mocha test/ --recursive --exit"
......@@ -42,6 +42,7 @@
},
"devDependencies": {
"eslint": "^4.16.0",
"log-suppress": "^1.0.3",
"mocha": "^4.0.1",
"request": "^2.83.0",
"request-promise": "^4.2.2",
......
const path = require('path');
const favicon = require('serve-favicon');
const compress = require('compression');
const cors = require('cors');
const helmet = require('helmet');
const logger = require('winston');
const path = require('path')
const favicon = require('serve-favicon')
const compress = require('compression')
const cors = require('cors')
const helmet = require('helmet')
let logger = require('winston')
const feathers = require('@feathersjs/feathers');
const configuration = require('@feathersjs/configuration');
const express = require('@feathersjs/express');
const feathers = require('@feathersjs/feathers')
const configuration = require('@feathersjs/configuration')
const express = require('@feathersjs/express')
const primus = require('@feathersjs/primus');
const primus = require('@feathersjs/primus')
const middleware = require('./middleware');
const services = require('./services');
const appHooks = require('./app.hooks');
const channels = require('./channels');
const middleware = require('./middleware')
const services = require('./services')
const appHooks = require('./app.hooks')
const channels = require('./channels')
const app = express(feathers());
const app = express(feathers())
// Load app configuration
app.configure(configuration());
app.configure(configuration())
// Enable CORS, security, compression, favicon and body parsing
app.use(cors());
app.use(helmet());
app.use(compress());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(favicon(path.join(app.get('public'), 'favicon.ico')));
app.use(cors())
app.use(helmet())
app.use(compress())
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
app.use(favicon(path.join(app.get('public'), 'favicon.ico')))
// Host the public folder
app.use('/', express.static(app.get('public')));
app.use('/', express.static(app.get('public')))
// Set up Plugins and providers
app.configure(express.rest());
app.configure(express.rest())
app.configure(primus({ transformer: 'websockets' }));
app.configure(primus({ transformer: 'websockets' }))
// Configure other middleware (see `middleware/index.js`)
app.configure(middleware);
app.configure(middleware)
// Set up our services (see `services/index.js`)
app.configure(services);
app.configure(services)
// Set up event channels (see channels.js)
app.configure(channels);
app.configure(channels)
// Configure a middleware for 404s and the error handler
app.use(express.notFound());
app.use(express.errorHandler({ logger }));
app.use(express.notFound())
app.hooks(appHooks);
// When running tests, do not log errors (as we don’t want them
// corrupting the output – especially when they’re being expected.)
if (process.env.NODE_ENV === 'test') {
logger = null
}
module.exports = app;
app.use(express.errorHandler({ logger }))
app.hooks(appHooks)
module.exports = app
// @ts-check
const activity = require('../lib/activity.js')
// Setup logger.
// (At least for now, we log to console unless tests are being run.)
const winston = require('winston')
if (process.env.NODE_ENV !== 'test') {
winston.add(new winston.transports.Console())
}
module.exports = function (app) { // eslint-disable-line no-unused-vars
// Custom Express middleware. The order matters
......@@ -29,7 +36,7 @@ module.exports = function (app) { // eslint-disable-line no-unused-vars
// ActivityPub response (return Actor object for the site owner).
const activityPub = () => {
console.log('🎭 Actor request for site owner.')
winston.log('🎭 Actor request for site owner.')
// Retrieve and return the Actor object for the site owner.
const ownerActorJSON = activity.owner.json()
......
npm run -s mocha
// @ts-check
/* global describe, before, after, it */
process.env.NODE_ENV = 'test'
const assert = require('assert')
const rp = require('request-promise')
const url = require('url')
......@@ -38,7 +41,7 @@ describe('Feathers application tests', () => {
headers: {
'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
}
}).then( (body) => {
}).then((body) => {
const owner = JSON.parse(body)
assert.equal(owner['@context'], 'https://www.w3.org/ns/activitystreams')
assert.equal(owner.type, 'Person')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment