Comparing version 0.2.1 to 0.2.2
@@ -0,0 +0,0 @@ #!/usr/bin/env node |
require('./include.js')(); | ||
require('./includeController.js')(); | ||
var express = require('express'); | ||
var swig = require('swig'); | ||
var express = require('express'), | ||
swig = require('swig'), | ||
flash = require('connect-flash'); | ||
var path = require('path'); | ||
require('./workaround.js'); | ||
var log4js = require('log4js'); | ||
@@ -23,7 +29,11 @@ log4js.replaceConsole(); | ||
self.models = function(modelName) { | ||
if (!self.modelCache[modelName]) { | ||
var app = self; | ||
var absPath = global.BASE_DIR + app.constants.MODELS_DIR + '/' + modelName; | ||
var modelJs = require(absPath); | ||
self.includeModel = function(workingPath) { | ||
var app = self; | ||
var modelJs = include(workingPath); | ||
var modelName = modelJs.name; | ||
if (!modelName) { | ||
modelName = path.basename(workingPath, '.js'); | ||
} | ||
var conn; | ||
@@ -34,3 +44,3 @@ | ||
} else { | ||
if (connections.mainDb) { | ||
if (app.connections.mainDb) { | ||
conn = app.connections.mainDb; | ||
@@ -58,4 +68,12 @@ } else { | ||
self.modelCache[modelName] = model; | ||
return model; | ||
} | ||
global.includeModel = self.includeModel; | ||
self.models = function(modelName) { | ||
if (!self.modelCache[modelName]) { | ||
var workingPath = self.constants.MODELS_DIR + '/' + modelName; | ||
self.modelCache[modelName] = includeModel(workingPath); | ||
} | ||
@@ -67,2 +85,3 @@ //console.log("!!!!" + self.modelCache[modelName]); | ||
global.models = self.models; | ||
@@ -110,3 +129,19 @@ | ||
server.use(express.json()); | ||
server.use(express.urlencoded()); | ||
server.use(express.methodOverride()); | ||
server.use(express.cookieParser("hello oils 2014")); | ||
var oneDay = 86400000; | ||
server.use(express.cookieSession({cookie: {maxAge: oneDay}})); | ||
server.use(function(req, res, next) { | ||
res.request = req; | ||
next(); | ||
}); | ||
server.use(flash()); | ||
pluginUtils.execInitializeServer(self); | ||
require('./loaders/routes.js')(self); | ||
@@ -137,5 +172,6 @@ | ||
require('./loaders/connections.js')(self); | ||
require('./loaders/plugins.js')(self); | ||
require('./loaders/connections.js')(self); | ||
//require('./loaders/models.js')(self); | ||
@@ -142,0 +178,0 @@ } |
@@ -0,0 +0,0 @@ var constants = new Object(); |
@@ -0,0 +0,0 @@ module.exports = function(override) { |
@@ -0,0 +0,0 @@ var constants = require('./constants'); |
var app = require('./app.js'); | ||
module.exports = app; |
@@ -0,0 +0,0 @@ module.exports = function(app) { |
@@ -0,0 +0,0 @@ module.exports = function(app) { |
@@ -0,0 +0,0 @@ /* |
@@ -28,8 +28,16 @@ var fileUtils = require('../utils/fileUtils.js'); | ||
var pluginName = file; //later might get from conf | ||
if (pluginConf.enabled) { | ||
if ( typeof pluginConf.oils === 'undefined' ) { | ||
throw new Error('"oils" property not found in package.json of plugin: ' + pluginName); | ||
} | ||
if ( typeof pluginConf.oils.enabled === 'undefined' ) { | ||
throw new Error('"oils.enabled" property not found in package.json of plugin: ' + pluginName); | ||
} | ||
if (pluginConf.oils.enabled) { | ||
if (app.isDebug) { | ||
console.log('[plugin] %s', pluginName); | ||
} | ||
var myPlugin = require(absolutePath); | ||
app.plugins[pluginName] = require(absolutePath); | ||
app.plugins[pluginName] = new myPlugin(pluginConf,app); | ||
} else { | ||
@@ -45,3 +53,3 @@ if (app.isDebug) { | ||
function getPluginConf(dir) { | ||
var conf = require(dir + '/conf.js'); | ||
var conf = require(dir + '/package.json'); | ||
@@ -48,0 +56,0 @@ return conf; |
@@ -0,0 +0,0 @@ var fileUtils = require('../utils/fileUtils'); |
@@ -0,0 +0,0 @@ var fs = require('fs'); |
@@ -27,4 +27,13 @@ var routeUtils = require('./routeUtils.js'); | ||
exports.execInitializeServer = function(app, model) { | ||
loopPlugins(app, function(plugin) { | ||
if (plugin.initializeServer) { | ||
plugin.initializeServer(app); | ||
} | ||
}) | ||
} | ||
function loopPlugins(app, callback) { | ||
@@ -31,0 +40,0 @@ for (var i in app.plugins) { |
@@ -0,0 +0,0 @@ exports.applyRoute = function(app, route, obj) { |
exports.endsWith = function(str, suffix) { | ||
return str.indexOf(suffix, str.length - suffix.length) !== -1; | ||
} |
{ | ||
"name": "oils", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Oils js framework built on top of Express.", | ||
@@ -33,3 +33,4 @@ "keywords": [ | ||
"optimist" : "0.6.x", | ||
"ncp" : "0.5.x" | ||
"ncp" : "0.5.x", | ||
"connect-flash": "0.1.x" | ||
}, | ||
@@ -36,0 +37,0 @@ "devDependencies": {}, |
@@ -19,4 +19,9 @@ oils | ||
Directory Structure: | ||
#### Latest Release(s) | ||
Version 0.2.1 ([Download](https://github.com/mannyvergel/oils-js/archive/v0.2.1.zip)) | ||
* models are now accessed through ```models('ModelName')``` | ||
#### Directory Structure | ||
|-- lib //custom js | ||
@@ -84,2 +89,3 @@ |-- oils | ||
+ Uninterrupted server when there's an exception | ||
+ Plugin support | ||
@@ -89,4 +95,2 @@ Future Features: | ||
+ Scaffolding | ||
+ Helper Functions | ||
+ Support for SQL DB | ||
@@ -122,2 +126,11 @@ ### Set-Up | ||
### Plugins | ||
Check plugin folder's [README.md](https://github.com/mannyvergel/oils-js/tree/master/template/oils/plugins) for more information. | ||
### Authentication | ||
Authentication is implemented as a plugin: [oils-auth-local](http://github.com/mannyvergel/oils-auth-local). Just place it in your project's plugin folder. i.e. under ```/oils/plugins/oils-auth-local```. | ||
### Contact | ||
@@ -124,0 +137,0 @@ |
@@ -0,0 +0,0 @@ LIBRARY FOLDER |
@@ -0,0 +0,0 @@ /* |
@@ -0,0 +0,0 @@ /** |
PLUGINS FOLDER | ||
================== | ||
Simple plugin system. This is a WIP. Currently supported is routes and doAfterLoadModel. | ||
Simple plugin system. This is a WIP. Currently supported is routes and initializeServer. | ||
@@ -12,3 +12,3 @@ Each folder here will be read as a plugin of the system. | ||
| |-- basic-plugin //folder name is the plugin name | ||
| |-- conf.js //plugin configuration | ||
| |-- package.js //plugin configuration | ||
| |-- index.js //can be index.js, can have package.json. Same as node js. | ||
@@ -18,8 +18,9 @@ | ||
``` | ||
//conf.js | ||
var conf = { | ||
enabled: true | ||
} | ||
module.exports = conf; | ||
//package.js | ||
... | ||
"oils" : { | ||
"enabled": true, //required | ||
//custom configuration variables | ||
} | ||
... | ||
``` | ||
@@ -29,9 +30,11 @@ | ||
//index.js | ||
module.exports = { | ||
module.exports = function(pkg, app) { | ||
var self = this; | ||
doAfterLoadModel: function(app, model) { | ||
... | ||
}, | ||
self.initializeServer = function() { | ||
//custom server initialization | ||
}; | ||
routes: { | ||
self.routes = { | ||
'/hello-plugin' : function(req, res) { | ||
@@ -41,3 +44,5 @@ res.end('HELLO PLUGIN!'); | ||
} | ||
} | ||
``` |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ oils-js-quickstart |
@@ -0,0 +0,0 @@ #!/bin/env node |
@@ -0,0 +0,0 @@ var Book = models('Book'); |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ CONTROLLERS FOLDER |
@@ -1,2 +0,3 @@ | ||
var Book = { | ||
module.exports = { | ||
name: 'Book', | ||
//mongoose schema, see mongoosejs.com for more info | ||
@@ -21,4 +22,2 @@ schema: { | ||
***/ | ||
} | ||
module.exports = Book; | ||
} |
@@ -0,0 +0,0 @@ MODELS FOLDER |
@@ -0,0 +0,0 @@ //MOCHA test |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
51325
46
827
158
11
7
2
+ Addedconnect-flash@0.1.x
+ Addedconnect-flash@0.1.1(transitive)