-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
91 lines (70 loc) · 2 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
'use strict';
/**
* Serverless Model Plugin
*/
module.exports = function(S) {
const path = require('path'),
SUtils = S.utils,
SError = require(S.getServerlessPath('Error')),
SCli = require(S.getServerlessPath('utils/cli')),
_ = require('lodash'),
BbPromise = require('bluebird');
/**
* Action instantiation. Used to resemble the SLS core layout to
* make it easy to integrate into core later.
*/
let ModelsCreate = require('./lib/actions/ModelsCreate')(S);
ModelsCreate = new ModelsCreate();
let ModelsList = require('./lib/actions/ModelsList')(S);
ModelsList = new ModelsList();
let ModelsShow = require('./lib/actions/ModelsShow')(S);
ModelsShow = new ModelsShow();
let ModelsRemove = require('./lib/actions/ModelsRemove')(S);
ModelsRemove = new ModelsRemove();
let ModelsImport = require('./lib/actions/ModelsImport')(S);
ModelsImport = new ModelsImport();
let ModelsDeploy = require('./lib/actions/ModelsDeploy')(S);
ModelsDeploy = new ModelsDeploy();
// Create pseudo core objects
S.classes.Models = require('./lib/Models')(S);
/**
* ServerlessModel
*/
class ServerlessModel extends S.classes.Plugin {
/**
* Constructor
*/
constructor() {
super();
}
/**
* Define your plugins name
*/
static getName() {
return 'com.serverless.' + ServerlessModel.name;
}
/**
* Register Actions
*/
registerActions() {
return BbPromise.join(
ModelsCreate.registerActions(),
ModelsList.registerActions(),
ModelsShow.registerActions(),
ModelsImport.registerActions(),
ModelsRemove.registerActions()
);
}
/**
* Register Hooks
*/
registerHooks() {
S.addHook(ModelsDeploy.modelsDeploy.bind(ModelsDeploy), {
action: 'endpointBuildApiGateway',
event: 'pre'
});
return BbPromise.resolve();
}
}
return ServerlessModel;
};