mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
WIP: add flow api
This commit is contained in:
32
red/api/flow.js
Normal file
32
red/api/flow.js
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Copyright 2014, 2015 IBM Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var log;
|
||||
var redNodes;
|
||||
var settings;
|
||||
|
||||
module.exports = {
|
||||
init: function(runtime) {
|
||||
settings = runtime.settings;
|
||||
redNodes = runtime.nodes;
|
||||
log = runtime.log;
|
||||
},
|
||||
get: function(req,res) {
|
||||
var id = req.params.id;
|
||||
log.audit({event: "flow.get"},req);
|
||||
res.json(redNodes.getFlow(id));
|
||||
}
|
||||
}
|
@@ -24,6 +24,7 @@ var when = require('when');
|
||||
var ui = require("./ui");
|
||||
var nodes = require("./nodes");
|
||||
var flows = require("./flows");
|
||||
var flow = require("./flow");
|
||||
var library = require("./library");
|
||||
var info = require("./info");
|
||||
var theme = require("./theme");
|
||||
@@ -64,6 +65,7 @@ function init(_server,runtime) {
|
||||
auth.init(runtime);
|
||||
credentials.init(runtime);
|
||||
flows.init(runtime);
|
||||
flow.init(runtime);
|
||||
info.init(runtime);
|
||||
library.init(adminApp,runtime);
|
||||
locales.init(runtime);
|
||||
@@ -103,6 +105,8 @@ function init(_server,runtime) {
|
||||
adminApp.get("/flows",needsPermission("flows.read"),flows.get);
|
||||
adminApp.post("/flows",needsPermission("flows.write"),flows.post);
|
||||
|
||||
adminApp.get("/flow/:id",needsPermission("flows.read"),flow.get);
|
||||
|
||||
// Nodes
|
||||
adminApp.get("/nodes",needsPermission("nodes.read"),nodes.getAll);
|
||||
adminApp.post("/nodes",needsPermission("nodes.write"),nodes.post);
|
||||
|
Reference in New Issue
Block a user