diff --git a/.gitignore b/.gitignore index a72b52e..ae8fdba 100644 --- a/.gitignore +++ b/.gitignore @@ -6,10 +6,3 @@ lib-cov *.out *.pid *.gz - -pids -logs -results - -npm-debug.log -node_modules diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 0baa188..0000000 --- a/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Julio Biason - -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. diff --git a/app.js b/app.js deleted file mode 100644 index 3aa5360..0000000 --- a/app.js +++ /dev/null @@ -1,70 +0,0 @@ -var express = require('express'); -var http = require('http'); -var path = require('path'); -var favicon = require('static-favicon'); -var logger = require('morgan'); -var bodyParser = require('body-parser'); - -var routes = require('./routes'); -var users = require('./routes/user'); - -var db = require('./models'); - -var app = express(); - -app.use(favicon()); -app.use(logger('dev')); -app.use(bodyParser.json()); -app.use(bodyParser.urlencoded()); -// app.use(cookieParser()); -app.use(app.router); - -/// catch 404 and forwarding to error handler -app.use(function(req, res, next) { - var err = new Error('Not Found'); - err.status = 404; - next(err); -}); - -/// error handlers - -// development error handler -// will print stacktrace -if (app.get('env') === 'development') { - app.use(function(err, req, res, next) { - res.render('error', { - message: err.message, - error: err - }); - }); -} - -// production error handler -// no stacktraces leaked to user -app.use(function(err, req, res, next) { - res.render('error', { - message: err.message, - error: {} - }); -}); - -module.exports = app; - -// routes -app.get('/', routes.index); - -// database and start up -db - .sequelize - .sync({ force: true }) - .complete(function (err) { - if (err) { - throw err; - } - - port = app.get('port') || 3000; - - http.createServer(app).listen(port, function () { - console.log('Express server listening on port ' + port); - }); - }); diff --git a/bin/www b/bin/www deleted file mode 100755 index 3cfbf77..0000000 --- a/bin/www +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env node -var debug = require('debug')('my-application'); -var app = require('../app'); - -app.set('port', process.env.PORT || 3000); - -var server = app.listen(app.get('port'), function() { - debug('Express server listening on port ' + server.address().port); -}); diff --git a/models/index.js b/models/index.js deleted file mode 100644 index 47fe94e..0000000 --- a/models/index.js +++ /dev/null @@ -1,34 +0,0 @@ -// Taken directly from Sequelize documentation - -var fs = require('fs'), - path = require('path'), - Sequelize = require('sequelize-sqlite').sequelize, - sqlite = require('sequelize-sqlite').sqlite, - lodash = require('lodash'), - db = {}; - -var sequelize = new Sequelize('database', 'username', null, { - dialect: 'sqlite', - storage: './luncho.sq' -}); - -fs - .readdirSync(__dirname) - .filter(function(file) { - return (file.indexOf('.') !== 0) && (file !== 'index.js'); - }) - .forEach(function(file) { - var model = sequelize.import(path.join(__dirname, file)); - db[model.name] = model; - }); - -Object.keys(db).forEach(function(modelName) { - if ('associate' in db[modelName]) { - db[modelName].associate(db); - } -}); - -module.exports = lodash.extend({ - sequelize: sequelize, - Sequelize: Sequelize -}, db); diff --git a/models/users.js b/models/users.js deleted file mode 100644 index 87201fe..0000000 --- a/models/users.js +++ /dev/null @@ -1,21 +0,0 @@ -module.exports = function(sequelize, DataTypes) { - var User = sequelize.define('User', { - username: DataTypes.STRING, - passhash: DataTypes.STRING, - token: DataTypes.STRING, // this forces only one hash per user - issuedDate: DataTypes.DATE // since tokens are one way only, we need to make sure the token is valid for today - }, { - classMethods: { - userToken: function (reqToken, next) { - User.find({ token: reqToken }).success(user) { - // check if the token is valid for today - if (next) { - next (user); - } - } - } - } - }); - - return User; -}; diff --git a/package.json b/package.json deleted file mode 100644 index b8c0d58..0000000 --- a/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "Lunch-o", - "version": "0.1.0", - "private": true, - "scripts": { - "start": "node ./bin/www" - }, - "dependencies": { - "express": "~3.4.8", - "static-favicon": "~1.0.0", - "morgan": "~1.0.0", - "body-parser": "~1.0.0", - "debug": "~0.7.4", - "sequelize-sqlite": "", - "lodash": "" - } -} diff --git a/routes/index.js b/routes/index.js deleted file mode 100644 index c5d2037..0000000 --- a/routes/index.js +++ /dev/null @@ -1,4 +0,0 @@ -/* GET home page. */ -exports.index = function(req, res){ - res.send({"status": "ERROR", "error": "No index method, go away"}); -}; diff --git a/routes/user.js b/routes/user.js deleted file mode 100644 index 3b8bd2c..0000000 --- a/routes/user.js +++ /dev/null @@ -1,4 +0,0 @@ -/* GET users listing. */ -exports.list = function(req, res){ - res.send('respond with a resource'); -};