Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

oils

Package Overview
Dependencies
Maintainers
1
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oils - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

0

bin/oils.js

@@ -0,0 +0,0 @@ #!/usr/bin/env node

55

oils-js-core/app.js

@@ -10,7 +10,58 @@ require('./include.js')();

var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var pluginUtils = require('./utils/pluginUtils');
var App = function(opts) {
var self = this;
global.oils = self;
self.constants = require('./constants');
self.modelCache = new Object();
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);
var conn;
if (modelJs.connection) {
conn = app.connections.mainDb;
} else {
if (connections.mainDb) {
conn = app.connections.mainDb;
} else {
for (var i in app.connections) {
//get the first connection
conn = app.connections[i];
break;
}
}
}
var schema = new Schema(modelJs.schema);
if (modelJs.initSchema) {
modelJs.initSchema(schema);
}
var model = conn.model(modelName, schema);
pluginUtils.execDoAfterLoadModel(app, model);
if (app.isDebug) {
console.log("Loaded model for the first time: " + modelName)
}
self.modelCache[modelName] = model;
}
//console.log("!!!!" + self.modelCache[modelName]);
return self.modelCache[modelName];
}
global.models = self.models;
/**

@@ -85,3 +136,3 @@ * terminator === the termination handler

require('./loaders/connections.js')(self);
require('./loaders/models.js')(self);
//require('./loaders/models.js')(self);
}

@@ -91,4 +142,2 @@

//convenience methods
global.oils = self;
global.models = self.models;
global.connections = self.connections;

@@ -95,0 +144,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) {

5

oils-js-core/loaders/models.js

@@ -0,1 +1,3 @@

/*
DEPRECATED, replaced by oils.models('model name')
var mongoose = require('mongoose');

@@ -80,2 +82,3 @@ var fileUtils = require('../utils/fileUtils');

}
}
*/

@@ -0,0 +0,0 @@ var fileUtils = require('../utils/fileUtils.js');

@@ -0,0 +0,0 @@ var fileUtils = require('../utils/fileUtils');

@@ -0,0 +0,0 @@ var fs = require('fs');

@@ -0,0 +0,0 @@ var routeUtils = require('./routeUtils.js');

@@ -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.0",
"version": "0.2.1",
"description": "Oils js framework built on top of Express.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -0,0 +0,0 @@ oils

@@ -0,0 +0,0 @@ LIBRARY FOLDER

@@ -0,0 +0,0 @@ /*

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ PLUGINS FOLDER

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ oils-js-quickstart

@@ -0,0 +0,0 @@ #!/bin/env node

@@ -1,2 +0,2 @@

var Book = models.Book;
var Book = models('Book');
module.exports = {

@@ -3,0 +3,0 @@ get : function(req, res) {

@@ -0,0 +0,0 @@ module.exports = {

@@ -0,0 +0,0 @@ module.exports = {

@@ -0,0 +0,0 @@ CONTROLLERS FOLDER

@@ -1,2 +0,2 @@

module.exports = {
var Book = {
//mongoose schema, see mongoosejs.com for more info

@@ -21,2 +21,4 @@ schema: {

***/
}
}
module.exports = Book;
MODELS FOLDER
===================
All models created here are accessible via Models.[Name]. It is a Mongoose Model.
All models created here are accessible via ```Models('ModelName')```. It will return a Mongoose Model.
Models directory do not officially support sub folders as of now.
e.g.
/web/models/Book.js ==> models.Book
/web/models/Book.js ==> ```models('Book')```

@@ -10,0 +12,0 @@ ###schema [required]

@@ -83,11 +83,12 @@ //MOCHA test

it('should have loaded models', function (done) {
setTimeout(function() {
var modelCount = 0;
for (var i in app.models) {
modelCount++;
}
assert.equal(modelCount, 1, 'Model count');
done();
}, 1500)
assert.doesNotThrow(function() {
var Book = models('Book');
if (!Book) {
throw new Error('Book is null')
}
}, 'Retrieving Book');
done();
});

@@ -94,0 +95,0 @@

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc