MCPcopy Create free account
hub / github.com/CloudBoost/cloudboost / getAppSettings

Function getAppSettings

api/auth/Auth.js:44–81  ·  view source on GitHub ↗
(req, res, next)

Source from the content-addressed store, hash-verified

42};
43
44const getAppSettings = async (req, res, next) => {
45 const appId = req.params.appId || null;
46
47 if (!appId) {
48 return res.status(400).send('AppId is invalid.');
49 }
50
51 try {
52 const allSettings = await appService.getAllSettings(appId);
53 if (!allSettings || allSettings.length === 0) {
54 return res.status(400).send('App Settings not found.');
55 }
56
57 const auth = _.first(_.where(allSettings, {
58 category: 'auth',
59 }));
60 let authSettings;
61 if (auth) {
62 authSettings = auth.settings;
63 }
64
65 if (!authSettings) {
66 return res.status(400).send('Authentication Settings not found.');
67 }
68
69 req.responseObject = {
70 appId,
71 authSettings,
72 };
73 return next();
74 } catch (error) {
75 winston.error({
76 error: String(error),
77 stack: new Error().stack,
78 });
79 return res.status(400).send(error);
80 }
81};
82
83module.exports = (app) => {
84 app.get('/auth/:appId/twitter', getAppSettings, async (req, res) => {

Callers

nothing calls this directly

Calls 2

firstMethod · 0.80
nextFunction · 0.50

Tested by

no test coverage detected