npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gozy

v0.4.3

Published

go crazy

Downloads

65

Readme

gozy

Go crazy

Install

npm install -g gozy
cd NewProject
gozy init
node .

Main Usge

var http = require('http').createServer().listen(80),
	gozy = require('gozy');

gozy.bindModels('application/model/')
	.bindControllers('application/controller')
	.bindMongo('MyMongoDB', {
		'host': 'localhost',
		'port': 27017,
		"username": "username",
		"password": "password",
		"database": "database"
	})
	.bindRedis('MyRedis', {
		'host': 'localhost',
		'port': 6379,
		"password": "password"
	})
	.bindMySQL('MyMySQL', {
		'host': 'localhost',
		'port': 3306,
		"username": "username",
		"password": "password",
		"database": "database"
	})
	.bindMailer('MyMailer', { /* this option is used for nodemailer package option */
		'host': 'smtp.host.com',
		secureConnection: false,
		port: 587,
		auth: {
			user: '[email protected]',
			pass: 'password!!'
		}
	})
	.enableWebSocket()
	.listen(http);

View Usage

require('gozy').View(this, {
	'accept-url': /^\/path\/to\/resource$/,
	'accept-method': 'GET'
});

this.on('initialize', function () {
	
});

this.on('prerequest', function (request, response, done) {
	return done({ authentication: true });
});

this.on('*/*', function (request, response, preq_args) {
	if(preq_args.authentication)
		return response.OK().commit();
	else
		return response.Forbidden().commit(); 
});

MongoDB Model Usage

require('gozy').Model(this, 'MyMongoDB', {
	defaults: {
		Name: null,
		Mode: 0
	}
});

this.on('initialize', function (model) {
	model.prototype.setName = setName;	
});

MySQL Model Usage

require('gozy').Model(this, 'MyMySQL', {
	schema: {
		id: { Id: true, type: 'INTEGER' },
		Name: { type: 'STRING' },
		Password: { type: 'BINARY' },
		DateLastUpdated: { type: 'TIMESTAMP' }
	}
});

this.on('initialize', function (model) {
	model.prototype.setName = setName;	
});

Redis Model Usage

MyStringModel.js

require('gozy').Model(this, 'MyRedis', {
	type: 'STRING',
	defaults: {
		Name: { type: 'OBJECT' }
	}
});

this.on('initialize', function (model) {
});

exports.createNew = function (cb) {
	var model = exports.MyStringModel({ name: { prop1: 'value1 will be converted to JSON', prop2: 'value2 will be converted to JSON' });
	model.key('this_is_Redis_key');
	model.setnx(function (err, saved) {
		if(err) return cb(err);
		if(saved > 0) return cb(null, model);
		else return cb(null, null); 
	});	
};

MyHashModel.js

require('gozy').Model(this, 'MyRedis', {
	type: 'HASH',
	defaults: {
		Name: { type: 'STRING' }
		Value: { type: 'INTEGER' }
	}
});

this.on('initialize', function (model) {
});

exports.createNew = function (cb) {
	var model = exports.MyHashModel({ 
		Name: 'value1', 
		Value: 11
	});
	
	model.key('this_is_the_key');
	/* will store on redis as a key, "MyHashModel.this_is_the_key" */
	model.hmset(function (err) {
		if(err) return cb(err);
		
		console.log(model);
		return cb(null, model);
	});
};

exports.findModel = function (key, cb) {
	exports.hgetall(key, cb);
};

Mailer Usage

require('gozy').Mailer(this, 'MyMailer', {
	template: 'application/server/mailer/templates/MailTemplate.html', /* used for underscore's template function */
	from: '[email protected]'
});

this.on('initialize', function () {
});

this.on('mail', function (body, template_params, send) {
	console.log(body, template_params);
	send(template_params.ReceiverMail, template_params.SenderMail + ' welcomes you', body);
});

Template View Usage

require('gozy').View(this, {
	template: {
		'ko-kr': 'application/view/templates/TemplateA.ko-kr.html',
		'en-us': 'application/view/templates/TemplateB.en-us.html'
	},
	default_template: 'ko-kr'
});

this.on('initialize', function () {
});

Content View Usage

require('gozy').View(this, {
	content: content,
	mime: 'application/json'
});

function content(args) {
	return JSON.stringify(args);
}

Content View with Backbone Model provider

require('gozy').View(this, {
	'accept-url': /^\/path$/, 
	'accept-method': 'GET',
	'content': content,
	'mime': 'application/json',
	'backbone': {
		Type: 'model',
		RequireJS: true,
		ModelOptions: {
			idAttribute: 'id'
		}
	}
});

function content(args) {
	return JSON.stringify(args);
}

Content View with Backbone Collection provider

Note, you can override Backbone Collection's parse function

require('gozy').View(this, {
	'accept-url': /^\/path$/, 
	'accept-method': 'GET',
	'content': content,
	'mime': 'application/json',
	'backbone': {
		parse: function (response) {
			this.next_search_url = response.next_search_url;
			return response.data;
		},
		Type: 'collection',
		RequireJS: true,
		ModelOptions: {
			idAttribute: 'id'
		}
	}
});

function content(args) {
	return JSON.stringify(args);
}

Usage of Gozy RMI through Backbone Collection

require('gozy').View(this, {
	'accept-url': /^\/path\/f$/, 
	'accept-method': 'GET',
	'content': content,
	'mime': 'application/json',
	'backbone': {
		Type: 'collection',
		RequireJS: true,
		ModelOptions: {
			idAttribute: 'id'
		},
		CollectionOptions: {
			parse: function (response) {
				this.NextSearchUrl = response.next_search_url;
				return response.data;
			},
			AcceptRMI: ['rmi_test']
		}
	}
});

this.on('rmi_test', function (request, response) {
	return response('My Request is successfully completed');
});

function content(args) {
	return JSON.stringify(args);
}

License

MIT License