Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/n4kz/crixalis
Lightweight web framework for node.js
https://github.com/n4kz/crixalis
Last synced: 3 months ago
JSON representation
Lightweight web framework for node.js
- Host: GitHub
- URL: https://github.com/n4kz/crixalis
- Owner: n4kz
- License: lgpl-3.0
- Created: 2012-11-02T22:37:39.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2016-10-05T14:23:26.000Z (over 8 years ago)
- Last Synced: 2024-09-23T02:07:32.537Z (4 months ago)
- Language: CoffeeScript
- Size: 344 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- License: license.txt
Awesome Lists containing this project
README
# Crixalis
Lightweight web framework for node.js
# Features
- Small, documented and easily extendable core
- Advanced routing system (content type, method, host) with RegExp support and placeholders
- Compression support (gzip, deflate)
- Static file serving support (with __ETag__, __Last-Modified__, __Expires__ and LRU-cache)# Synopsis
General usage
```js
var Crixalis = require('crixalis');
Crixalis
/* Load plugins */
.plugin('shortcuts')
.plugin('access', { format: '%7T %-4m %s %9B %-15h %U%q' })/* Add route with placeholder */
.get('/hello/:name', function () {
/* Prepare data for response */
this.stash.json = {
message: 'Hello, ' + this.params.name + '!'
};/* Render response */
this.render();
})/* Add another route for GET and HEAD methods */
.route('/info', { methods: ['GET', 'HEAD'] }, function () {
var that = this;require('fs').readFile('./readme.md', function (error, result) {
if (error) {
/* Handle error */
that.error(error);
} else {
that.body = result;
that.render();
}
});
})/* Catch everything else */
.route('*', function () {
this.redirect('/hello/World');
})/* Start server on port 8080 */
.start('http', 8080);
```# Plugins
Available core plugins
- `access` Access log (with configurable CLF support)
- `compression` Compress response using `gzip` or `deflate` compression (also works with `static` plugin)
- `request` Thin wrapper around `http.request` and `https.request`
- `shortcuts` Route declaration helpers, `.get()`, `.post()`, etc.
- `static` Serve static files# Static server
Crixalis comes with script for serving static files
```bash
# Start web server on port `8080` and serve files from current folder
crixalis# Start web server on port `3000` and serve files from `~/www/`
crixalis --port 3000 --path ~/www/
```# Copyright and License
Copyright 2012-2016 Alexander Nazarov. All rights reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.