|
43 | 43 | "The mount point of the app. Has to be url-encoded."
|
44 | 44 | )
|
45 | 45 | };
|
| 46 | + var scriptName = { |
| 47 | + type: joi.string().required().description( |
| 48 | + "The name of an app's script to run." |
| 49 | + ) |
| 50 | + }; |
46 | 51 | var fs = require("fs");
|
47 | 52 | var defaultThumb = require("/lib/defaultThumbnail").defaultThumb;
|
48 | 53 |
|
|
212 | 217 | res.json(FoxxManager.configure(mount, {configuration: data}));
|
213 | 218 | }).queryParam("mount", mountPoint);
|
214 | 219 |
|
| 220 | + |
| 221 | + /** Run a script for an app |
| 222 | + * |
| 223 | + * Used to trigger any script of an app |
| 224 | + */ |
| 225 | + controller.post("/scripts/:name", function (req, res) { |
| 226 | + var mount = validateMount(req); |
| 227 | + var name = req.params("name"); |
| 228 | + res.json(FoxxManager.runScript(name, mount)); |
| 229 | + }).queryParam("mount", mountPoint).pathParam("name", scriptName); |
| 230 | + |
215 | 231 | /** Trigger setup script for an app
|
216 | 232 | *
|
217 | 233 | * Used to trigger the setup script of an app
|
218 | 234 | */
|
219 | 235 | controller.patch("/setup", function(req, res) {
|
220 | 236 | var mount = validateMount(req);
|
221 |
| - res.json(FoxxManager.setup(mount)); |
| 237 | + res.json(FoxxManager.runScript("setup", mount)); |
222 | 238 | }).queryParam("mount", mountPoint);
|
223 | 239 |
|
224 | 240 | /** Trigger teardown script for an app
|
|
227 | 243 | */
|
228 | 244 | controller.patch("/teardown", function(req, res) {
|
229 | 245 | var mount = validateMount(req);
|
230 |
| - res.json(FoxxManager.teardown(mount)); |
| 246 | + res.json(FoxxManager.runScript("teardown", mount)); |
231 | 247 | }).queryParam("mount", mountPoint);
|
232 | 248 |
|
233 | 249 |
|
|
0 commit comments