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

maglev

v5.0.13

Published

Preconfigured NodeJS framework

Downloads

48

Readme

Maglev (Preconfigured simple NodeJS framework)

Quality Dependencies Gitter chat Gittip

Maglev is a simple pre configured server based on Express web framework, Passport authentication middleware and Mongoose database layer. Maglev supports MVC patterns and RESTful routes.

Install

npm install maglev

Features

  • Predefined models and controllers (User, Token, Role, Permission, Logic...)
  • Extended routing for REST api based on Express
  • Token and session authentication
  • Role based access system
  • Swig template system with custom helpers

Require

Maglev is using two peerDependencies Mongoose and express-session. Please add it into your package.json if you want to use mongoose.

Usage

var mongoose = require('mongoose');
var Server = require('maglev');

var server = new Server({
	root: __dirname,
	db: mongoose.connect('mongodb://localhost/maglev'),
	session: {
		secret: '123456789'
	},
	favicon: false
});

server.start();

Directory Structure

  • controllers Contains the controllers that handle requests sent to an application.
  • models Contains the models for accessing and storing data in a database.
  • views Contains the views and layouts that are rendered by an application.
  • public Static files and compiled assets served by the application.

Models

Define new model

var mongoose = require('mongoose');
var Schema = mongoose.Schema;

function createSchema() {
	var schema = new Schema({
		city: { type: String, required: true },
		street: { type: String, required: true },
		state: { type: String, required: true }
	});

	return schema;
}

module.exports = function (server) {
	return server.db.model('Address', createSchema());   
};

Routes

var token = require('maglev/dist/controllers/token');
var message = require('../controllers/message');

module.exports = function(route) {
	route
		.api()
		.get('/messages', token.ensure, message.get)
		.put('/messages/mark/read/:id', token.ensure, message.markAsRead)
		.put('/messages/mark/unread/:id', token.ensure, message.markAsUnread);
};

There are other configuration parameters

{
	root: null, 

	rbac: {
		storage: null,
		role: {
			guest: 'guest'
		}
	},

	log: true,

	morgan: {
		format: process.env.NODE_ENV === 'development' ? 'dev' : 'combined',
		options: {
			immediate: false
			//stream: process.stdout
		}
	},
	
	server: {
		build: 1,
		host: process.env.HOST || '127.0.0.1',
		port: process.env.PORT || 4000
	},

	request: {
		timeout: 1000*60*5
	},

	compression: {},

	powered: {
		value: 'Maglev'
	},

	responseTime: {},

	methodOverride: {
		//https://github.com/expressjs/method-override
		enabled: true,
		getter: 'X-HTTP-Method-Override',
		options: {}
	},

	bodyParser: [{
		parse: 'urlencoded',
		options: {
			extended: true
		}
	}, {
		parse: 'json',
		options: {}
	}, {
		parse: 'json',
		options: {
			type: 'application/vnd.api+json'
		}
	}],

	cookieParser: {
		secret: null,
		options: {}
	},

	token: {
		secret: null,
		expiration: 60*24*14
	},

	session: {
		secret: null,
		cookie: {
			maxAge: 14 *24 * 60 * 60 * 1000 //2 weeks
		},
		resave: true,
		saveUninitialized: true
	},

	view: {
		engine: 'swig'
	},

	router: {
		api: {
			path: '/api'
		}
	},

	locale: {
		'default': 'en',
		available: ['en'],
		inUrl: false
	},

	country: {
		'default': null,
		available: [],
		inUrl: false
	},	

	registration: {
		simple: true
	},

	facebook: {
		clientID: null,
		clientSecret: null,
		namespace: null
	},

	upload: {
    	maxFieldsSize: 2000000,
    	maxFields: 1000,
    	path: null
    },

    cors: {},

    page: {
    	error: null,
    	notFound: null
    },

    strategies: [],

    css: {
		root: 'public/css',
		options: {}
	},

    'static': {
    	root: 'public',
    	options: {
    		index: false
    	}
    },

    favicon: {
    	root: 'public/favicon.ico',
    	options: {}
    }
};

Credits

Zlatko Fedor

License

The MIT License (MIT)

Copyright (c) 2015 Zlatko Fedor [email protected]

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.