api.js 795 Bytes
var express = require('express');

exports = module.exports = function (IoC, policies, settings) {
	var app = this;
	var router = express.Router();
	var controller = IoC.create('controllers/api');

	router.get(
		'/*',
		policies.ensureLoggedOut(),
		controller.get
	);

	router.post(
		'/*',
		policies.ensureLoggedOut(),
		controller.post
	);

	router.put(
		'/*',
		policies.ensureLoggedOut(),
		controller.put
	);

	router.patch(
		'/*',
		policies.ensureLoggedOut(),
		controller.patch
	);

	router.head(
		'/*',
		policies.ensureLoggedOut(),
		controller.head
	);

	router.delete(
		'/*',
		policies.ensureLoggedOut(),
		controller.delete
	);

	app.use(settings.prefix + 'api', router);
};

exports['@require'] = ['$container', 'policies', 'igloo/settings'];
exports['@singleton'] = true;