Minimalistic, high-performance web framework that supports both classic, generator and async middleware.
- Robust routing
- Focus on high performance
- HTTP helpers (redirection, caching, etc.)
- Content negotiation
- Centralised error handling
- Support for generator and async middleware
- Use of contexts
const Ellipse = require('ellipse'),
app = new Ellipse
app.use(function(req, res, next) {
req.sessionId = this.cookies.get('session')
next()
})
app.use(async (req, res, next) => {
req.user = await findUserBySessionId(req.sessionId)
next()
})
app.get('/', (req, res) => {
res.send('Hello Ellipse!')
})
app.get('/me', (req, res) => {
res.json(req.user)
})
app.get('/greet/:name', function *(next) {
this.html = `<h1>Hello ${this.params.name}!</h1>`
yield doSomething()
this.send()
})
app.on('notFound', ctx => {
ctx.status = 404
ctx.send('Page not found.')
})
app.listen(3333)
For more information, take a look at the examples folder.
Note: this
refers to a context object - except in arrow functions. Context is similar but not quite identical to Koa's.
You're reading about the upcoming v0.21
release-line of Ellipse which is alpha
software.
If you want to try out these new features presented above, then you should use the next
tag:
npm install ellipse@next
Or simply install v0.5
which is the latest version, considered as stable.
But please notice that, those early versions (<=0.5
) are deprecated and no longer supported.
npm install ellipse
Please consider that async
and await
are not supported natively by Node prior to the latest v7
release,
so you need to transpile it as long as this feature is in staged
state.
This example shows a convenient way to do that.
Native support has been arrived recently with Node v7
,
but behind the --harmony_async_await
flag and you can use it at your own risk:
node --harmony_async_await ./foo.js # no need to transpile
Clone the repo, npm install
and then npm test
or npm run benchmarks
.