Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
change license
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Apr 21, 2011
1 parent c48d701 commit e7c9dff
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 15 deletions.
21 changes: 21 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,21 @@
This software is licensed under the MIT License.

Copyright (C) 2011 by fengmk2 <fengmk2@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
@@ -1,4 +1,4 @@
# A File Session Store for connect.session
# A File Store, could use in connect.session

Implement all the method for connect.session

Expand Down
25 changes: 11 additions & 14 deletions lib/filestore.js
@@ -1,22 +1,19 @@
/**
* File Session Store Implementation for Connect.session:
*
* Every session store _must_ implement the following methods
*
* - `.get(sid, callback)`
* - `.set(sid, session, callback)`
* - `.destroy(sid, callback)`
*
* Recommended methods include, but are not limited to:
*
* - `.length(callback)`
* - `.clear(callback)`
* Module dependencies.
*/

var fs = require('fs')
, path = require('path')
, crypto = require('crypto');

/**
* MD5 hash
*
* @param {String} s
* @param {String} encoding, optional, default is hex
* @return depend on encoding
* @api private
*/
function md5(s, encoding) {
var h = crypto.createHash('md5');
h.update(s);
Expand Down Expand Up @@ -48,14 +45,14 @@ FileStore.prototype.get = function(key, callback) {
FileStore.prototype.set = function(key, value, callback) {
var p = path.join(this.filedir, md5(key));
fs.writeFile(p, JSON.stringify(value), function (err) {
callback && callback(err)
callback && callback(err);
});
};

FileStore.prototype.destroy = function(key, callback) {
var p = path.join(this.filedir, md5(key));
fs.unlink(path, function(err) {
callback && callback()
callback && callback();
});
};

Expand Down
18 changes: 18 additions & 0 deletions package.json
@@ -0,0 +1,18 @@
{
"name": "filestore",
"description": "A File Store, could use in connect.session",
"version": "0.1.0",
"homepage": "https://github.com/fengmk2/filestore",
"repository": {
"type": "git",
"url": "git://github.com/fengmk2/filestore.git"
},
"author": "fengmk2 <fengmk2@gmail.com> (http://fengmk2.cnblogs.com)",
"main": "index",
"directories": {
"lib": "lib"
},
"engines": {
"node": "*"
}
}

0 comments on commit e7c9dff

Please sign in to comment.