api.js 952 Bytes
/*
 * @Descripttion: 
 * @version: 0.0.0
 * @Author: genglw
 * @Date: 2022-01-21 15:31:14
 * @LastEditors: genglw
 * @LastEditTime: 2022-02-10 20:37:04
 */
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;