Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serverBefore/serverAfter/serverExtend event question #308

Closed
davidsteinberger opened this issue Sep 23, 2012 · 2 comments
Closed

serverBefore/serverAfter/serverExtend event question #308

davidsteinberger opened this issue Sep 23, 2012 · 2 comments

Comments

@davidsteinberger
Copy link

While playing around with the express-namespace module I realized a small issue with the events of docpad:

The module requires a require('express-namespace') call and then provides an app.namespace() method.

However calling require('express-namespace') in either of the events doesn't do the trick.

Workaround:
Manually setting a server instance fixes that.

docpadConfig = {
  server: express.createServer()
  ...

  serverBefore: (opts, next) ->
    console.log 'serverBefore'
    require('express-namespace')
    next()

  ...
}

Why is that?

@balupton
Copy link
Member

From our quick chat on IRC it seems that express-namespace only works with express v3. As DocPad uses express v2, grabbing express inside your docpad configuration file will load in your own express (assuming v3) instead of docpad's express (v2) solving the issue.

Would you say that could be the case?

balupton added a commit that referenced this issue Oct 2, 2012
- v6.7.0 October 2, 2012
	- Server changes:
		- Updated [Express.js](http://expressjs.com/) from v2.5 to v3.0
			- If you're doing custom routing, you'll want to check the
[Express.js Upgrade
Guide](https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to
-3.x)
			- There are now two server objects: `serverExpress` and `serverHttp`
- get them using `docpadInstance.getServer(true)`, set them using
`docpad.setServer({serverExpress,serverHttp})` - `server` in events,
and `docpadInstance.getServer()` return the `serverExpress` object for
backwards compatibility (however things like socket.io require the
`serverHttp` object)
			- Closes [#311](#311),
[#308](#308),
[#272](#272),
[#274](#274)
			- Help by [dave8401](https://github.com/dave8401) and [Ben
Harris](https://github.com/bharrisau)
		- Abstracted out the different middlewares to
`serverMiddlewareHeader`, `serverMiddlewareRouter`,
`serverMiddleware404`, and `serverMiddleware500`
		- Added the following options to the `server` actions:
			- `serverExpress` for a custom express.js server
			- `serverHttp` for a custom http server
			- `middlewareStandard` set it to `false` for us to not use any of
the standard middleware (body parse, method override, express router)
			- `middlewareBodyParser` set it to `false` for us to not add the
`bodyParser` middleware
			- `middlewareMethodOverride` set it to `false` for us to not add the
`methodOverride` middleware
			- `middlewareExpressRouter` set it to `false` for us to not add the
Express.js `router` middleware
			- `middleware404` set it to `false` for us to not add our `404`
middleware
			- `middleware500` set it to `false` for us to not add our `500`
middleware
		- Example API usage can be found
[here](https://github.com/bevry/docpad/wiki/API)
	- Added `standalone` attribute to files (defaults to `false`)
		- If you set to `true`, changes to the file will only cause
re-rendering of that file alone
	- Added a progress indicator during generation
		- Closes [#247](#247)
		- Help by [Bruno Héridet](https://github.com/Delapouite)
@balupton
Copy link
Member

balupton commented Oct 2, 2012

Express.js v3 has landed in DocPad v6.7.0

@balupton balupton closed this as completed Oct 2, 2012
balupton added a commit that referenced this issue Oct 23, 2013
- v6.7.0 October 2, 2012
	- Server changes:
		- Updated [Express.js](http://expressjs.com/) from v2.5 to v3.0
			- If you're doing custom routing, you'll want to check the
[Express.js Upgrade
Guide](https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to
-3.x)
			- There are now two server objects: `serverExpress` and `serverHttp`
- get them using `docpadInstance.getServer(true)`, set them using
`docpad.setServer({serverExpress,serverHttp})` - `server` in events,
and `docpadInstance.getServer()` return the `serverExpress` object for
backwards compatibility (however things like socket.io require the
`serverHttp` object)
			- Closes [#311](#311),
[#308](#308),
[#272](#272),
[#274](#274)
			- Help by [dave8401](https://github.com/dave8401) and [Ben
Harris](https://github.com/bharrisau)
		- Abstracted out the different middlewares to
`serverMiddlewareHeader`, `serverMiddlewareRouter`,
`serverMiddleware404`, and `serverMiddleware500`
		- Added the following options to the `server` actions:
			- `serverExpress` for a custom express.js server
			- `serverHttp` for a custom http server
			- `middlewareStandard` set it to `false` for us to not use any of
the standard middleware (body parse, method override, express router)
			- `middlewareBodyParser` set it to `false` for us to not add the
`bodyParser` middleware
			- `middlewareMethodOverride` set it to `false` for us to not add the
`methodOverride` middleware
			- `middlewareExpressRouter` set it to `false` for us to not add the
Express.js `router` middleware
			- `middleware404` set it to `false` for us to not add our `404`
middleware
			- `middleware500` set it to `false` for us to not add our `500`
middleware
		- Example API usage can be found
[here](https://github.com/bevry/docpad/wiki/API)
	- Added `standalone` attribute to files (defaults to `false`)
		- If you set to `true`, changes to the file will only cause
re-rendering of that file alone
	- Added a progress indicator during generation
		- Closes [#247](#247)
		- Help by [Bruno Héridet](https://github.com/Delapouite)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants