Skip to content

Commit

Permalink
Preparing 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Fredrik Liljegren committed Oct 19, 2015
1 parent 0921a31 commit 70c1623
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 21 deletions.
15 changes: 15 additions & 0 deletions README.md
Expand Up @@ -224,6 +224,21 @@ require('nodemailer-sendmail-transport')(options)`.
Changelog
---------

### 0.4.0

**Upgrade from 0.3**:

1. Update config (`database` format changed to [Knex]())
2. `node migrate0.3.0-0.4.0.js`

* #19: Edit/delete own comments.
* Changing ORM again (using objection.js, but thinking about ditching that and only using knex).
* Using Bluebird for promises.
* Dropping node < 4 - This is a microservice, does not need to be compatible with old interpreters!

Use with caution; I haven't tested the Dynamic OpenID Connect authentication in this version.


### 0.3.0

**Upgrade from 0.2**: `grunt migrate:up`
Expand Down
6 changes: 4 additions & 2 deletions TODO.md
@@ -1,8 +1,7 @@
Todo
====

* MIGRATE 0.3.0 → 0.4.0.
* Remove Q (in favour of bluebird and asyncawait).
* Move authentication.js to routes.
* Use express router consistently.
* Reasonable logging.
* Error handling.
Expand All @@ -15,3 +14,6 @@ Todo
* Validate config for easier setup/upgrade.
* Switch from supertest to request-promise.
* Consistent ES6 usage: const, let, arrow-lambdas…
* Remove Q from test/routes.
* Remove Q from frontend.
* Use `request-promise` in test, rather than `supertest`.
4 changes: 2 additions & 2 deletions authentication.js
Expand Up @@ -20,7 +20,7 @@
var async = require('asyncawait/async')
var await = require('asyncawait/await')

var Q = require('q')
var Promise = require('bluebird')
var passport = require('passport')
var FacebookStrategy = require('passport-facebook').Strategy
var GithubStrategy = require('passport-github').Strategy
Expand All @@ -36,7 +36,7 @@ function setupAnonymous(model, app, anonConfig) {

// Create an anonymous user.
var user = await(model.User.createAnonymous(req.ip))
await(Q.ninvoke(req, 'login', user))
await(Promise.promisify(req.login, req)(user))
res.redirect('/account')
})
)
Expand Down
5 changes: 4 additions & 1 deletion config.js.example
Expand Up @@ -26,7 +26,10 @@ var config = {
}
],
},
database: 'sqlite://' + path.join(__dirname, 'comments.db'),
database: {
client: 'sqlite3',
connection: {filename: path.join(__dirname, 'comments.db')}
}
}

module.exports = config
3 changes: 0 additions & 3 deletions package.json
Expand Up @@ -28,12 +28,9 @@
"jsonwebtoken": "^5.0.1",
"knex": "^0.8.6",
"markdown": "^0.5.0",
"migrate-orm2": "^1.2.14",
"morgan": "^1.5.2",
"nodemailer": "^1.3.4",
"objection": "^0.2.7",
"orm": "^2.1.26",
"orm-timestamps": "^0.5.2",
"passport": "^0.2.1",
"passport-facebook": "^2.0.0",
"passport-github": "^0.1.5",
Expand Down
2 changes: 1 addition & 1 deletion public/client.js
Expand Up @@ -243,7 +243,7 @@
iframe.src = server + 'login'
iframe.className = 'login'

var deferred = Q.defer()
var deferred = window.Q.defer()

window.addEventListener('message', function(event) {
var origUrl = parseUrl(event.origin)
Expand Down
16 changes: 5 additions & 11 deletions routes/comments.js
Expand Up @@ -22,9 +22,9 @@
var async = require('asyncawait/async')
var await = require('asyncawait/await')

//// TODO remove Q
var Q = require('q')
var Promise = require('bluebird')
var Handlebars = require('handlebars')
var readFile = Promise.promisify(require("fs").readFile)
var FS = require('fs')
var path = require('path')
var markdown = require('markdown').markdown
Expand Down Expand Up @@ -123,14 +123,8 @@ module.exports = function (app, model, mailTransport, config) {
var site = await(page.getSite())

var hbsRaw = await({
txt: Q.nfcall(
FS.readFile, path.join(__dirname, '..', 'views', 'email', 'notification.txt.hbs'),
'utf-8'
),
html: Q.nfcall(
FS.readFile, path.join(__dirname, '..', 'views', 'email', 'notification.html.hbs'),
'utf-8'
)
txt: readFile(path.join(__dirname, '..', 'views', 'email', 'notification.txt.hbs'), 'utf-8'),
html: readFile(path.join(__dirname, '..', 'views', 'email', 'notification.html.hbs'), 'utf-8')
})
var templates = {
txt: Handlebars.compile(hbsRaw.txt),
Expand Down Expand Up @@ -160,7 +154,7 @@ module.exports = function (app, model, mailTransport, config) {
unsubscribeUrl: unsubscribeUrl
})

return Q.ninvoke(mailTransport, 'sendMail', {
return Promise.promisify(mailTransport.sendMail, mailTransport)({
from: config.email.address,
to: user.email,
subject: 'New comment on: ' + page.url,
Expand Down
2 changes: 1 addition & 1 deletion test/routes.js
Expand Up @@ -47,7 +47,7 @@ describe('Routing Integration', function() {

before(async(function() {
this.timeout(5000)
await(Q.Promise(function(resolve, reject, notify) {
await(new Promise(function(resolve, reject) {
// Start the server
var subEnv = process.env
subEnv.COVERAGE = true
Expand Down

0 comments on commit 70c1623

Please sign in to comment.