UNPKG

3.96 kBJavaScriptView Raw
1/**
2 * @license
3 * MOST Web Framework 2.0 Codename Blueshift
4 * Copyright (c) 2017, THEMOST LP All rights reserved
5 *
6 * Use of this source code is governed by an BSD-3-Clause license that can be
7 * found in the LICENSE file at https://themost.io/license
8 */
9var HttpDataController = require('./data');
10var LangUtils = require('@themost/common/utils').LangUtils;
11var httpGet = require('../decorators').httpGet;
12var httpPost = require('../decorators').httpPost;
13var httpPut = require('../decorators').httpPut;
14var httpDelete = require('../decorators').httpDelete;
15var httpAction = require('../decorators').httpAction;
16var httpController = require('../decorators').httpController;
17var defineDecorator = require('../decorators').defineDecorator;
18var Q = require('q');
19/**
20 * @class
21 * @constructor
22 * @augments HttpDataController
23 */
24function HttpDataModelController() {
25 HttpDataModelController.super_.bind(this)();
26}
27LangUtils.inherits(HttpDataModelController, HttpDataController);
28defineDecorator(HttpDataModelController, 'constructor', httpController());
29
30HttpDataModelController.prototype.getItems = function() {
31 return Q.nbind(HttpDataModelController.super_.prototype.index,this)();
32};
33//apply descriptors
34defineDecorator(HttpDataModelController.prototype, 'getItems', httpGet());
35defineDecorator(HttpDataModelController.prototype, 'getItems', httpAction("index"));
36
37HttpDataModelController.prototype.postItems = function() {
38 return Q.nbind(HttpDataModelController.super_.prototype.index,this)();
39};
40//apply descriptors
41defineDecorator(HttpDataModelController.prototype, 'postItems', httpPost());
42defineDecorator(HttpDataModelController.prototype, 'postItems', httpAction("index"));
43
44HttpDataModelController.prototype.putItems = function() {
45 return Q.nbind(HttpDataModelController.super_.prototype.index,this)();
46};
47//apply descriptors
48defineDecorator(HttpDataModelController.prototype, 'putItems', httpPut());
49defineDecorator(HttpDataModelController.prototype, 'putItems', httpAction("index"));
50
51HttpDataModelController.prototype.deleteItems = function() {
52 return Q.nbind(HttpDataModelController.super_.prototype.index,this)();
53};
54//apply descriptors
55defineDecorator(HttpDataModelController.prototype, 'deleteItems', httpDelete());
56defineDecorator(HttpDataModelController.prototype, 'deleteItems', httpAction("index"));
57
58
59HttpDataModelController.prototype.showItem = function() {
60 return Q.nbind(HttpDataModelController.super_.prototype.show,this)();
61};
62//apply descriptors
63defineDecorator(HttpDataModelController.prototype, 'showItem', httpGet());
64defineDecorator(HttpDataModelController.prototype, 'showItem', httpAction("show"));
65
66HttpDataModelController.prototype.createItem = function() {
67 return {};
68};
69//apply descriptors
70defineDecorator(HttpDataModelController.prototype, 'createItem', httpGet());
71defineDecorator(HttpDataModelController.prototype, 'createItem', httpAction("create"));
72
73HttpDataModelController.prototype.getItem = function() {
74 return Q.nbind(HttpDataModelController.super_.prototype.edit,this)();
75};
76//apply descriptors
77defineDecorator(HttpDataModelController.prototype, 'getItem', httpGet());
78defineDecorator(HttpDataModelController.prototype, 'getItem', httpAction("edit"));
79
80HttpDataModelController.prototype.postItem = function() {
81 return Q.nbind(HttpDataModelController.super_.prototype.edit,this)();
82};
83//apply descriptors
84defineDecorator(HttpDataModelController.prototype, 'postItem', httpPost());
85defineDecorator(HttpDataModelController.prototype, 'postItem', httpAction("edit"));
86
87HttpDataModelController.prototype.deleteItem = function() {
88 return Q.nbind(HttpDataModelController.super_.prototype.edit,this)();
89};
90//apply descriptors
91defineDecorator(HttpDataModelController.prototype, 'deleteItem', httpDelete());
92defineDecorator(HttpDataModelController.prototype, 'deleteItem', httpAction("edit"));
93
94if (typeof module !== 'undefined') {
95 module.exports = HttpDataModelController;
96}
\No newline at end of file