Skip to content

Commit 4303295

Browse files
authored
Merge pull request #94 from Staffbase/chore-formatting-updates
chore: update formatting
2 parents c238a55 + c5bae48 commit 4303295

2 files changed

Lines changed: 109 additions & 70 deletions

File tree

scaffoldTpl/app.js

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,79 @@
1-
let express = require('express');
2-
let path = require('path');
3-
let favicon = require('serve-favicon');
4-
let logger = require('morgan');
5-
let cookieParser = require('cookie-parser');
6-
let bodyParser = require('body-parser');
1+
let express = require("express");
2+
let path = require("path");
3+
let favicon = require("serve-favicon");
4+
let logger = require("morgan");
5+
let cookieParser = require("cookie-parser");
6+
let bodyParser = require("body-parser");
77

8-
let index = require('./routes/index');
9-
let users = require('./routes/users');
8+
let index = require("./routes/index");
9+
let users = require("./routes/users");
1010

1111
let app = express();
1212

1313
const staffbaseKey = null;
1414
const pluginID = null;
1515
let ssoMiddleWare;
16-
ssoMiddleWare = require('@staffbase/staffbase-plugin-sdk').middleware(staffbaseKey, pluginID);
17-
16+
ssoMiddleWare = require("@staffbase/staffbase-plugin-sdk").middleware(
17+
staffbaseKey,
18+
pluginID
19+
);
1820

1921
// view engine setup
20-
app.set('views', path.join(__dirname, 'views'));
21-
app.set('view engine', 'pug');
22+
app.set("views", path.join(__dirname, "views"));
23+
app.set("view engine", "pug");
2224

2325
// uncomment after placing your favicon in /public
2426
// app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
25-
app.use(logger('dev'));
27+
app.use(logger("dev"));
2628
app.use(bodyParser.json());
27-
app.use(bodyParser.urlencoded({extended: false}));
29+
app.use(bodyParser.urlencoded({ extended: false }));
2830
app.use(cookieParser());
29-
app.use(express.static(path.join(__dirname, 'public')));
31+
app.use(express.static(path.join(__dirname, "public")));
3032

31-
app.use('/', index);
32-
app.use('/users', users);
33+
app.use("/", index);
34+
app.use("/users", users);
3335

3436
// Frontend Handler
35-
app.use('/frontEnd', ssoMiddleWare);
36-
app.get('/frontEnd', function(req, res) {
37-
res.render('plugin', req.sbSSO);
37+
app.use("/frontEnd", ssoMiddleWare);
38+
app.get("/frontEnd", function (req, res) {
39+
res.render("plugin", req.sbSSO);
3840
});
3941

4042
// Setup SSO Milleware on the endpoint server
41-
app.use('/staffbase/sso/backoffice', ssoMiddleWare);
43+
app.use("/staffbase/sso/backoffice", ssoMiddleWare);
4244

4345
// Handle SSO response from server with decoded data
44-
app.get('/staffbase/sso/backoffice', function(req, res) {
46+
app.get("/staffbase/sso/backoffice", function (req, res) {
4547
// Middleware was able to decode the token
4648
if (req.sbSSO) {
47-
console.log('Decoded data on backend(admin):', req.sbSSO);
48-
res.render('plugin', req.sbSSO);
49+
console.log("Decoded data on backend(admin):", req.sbSSO);
50+
res.render("plugin", req.sbSSO);
4951
return res.end();
5052
}
5153
res.json({
5254
error: {
53-
msg: 'Unable to get token information.',
55+
msg: "Unable to get token information.",
5456
},
5557
});
5658
return res.end();
5759
});
5860

5961
// catch 404 and forward to error handler
60-
app.use(function(req, res, next) {
61-
let err = new Error('Not Found');
62+
app.use(function (req, res, next) {
63+
let err = new Error("Not Found");
6264
err.status = 404;
6365
next(err);
6466
});
6567

6668
// error handler
67-
app.use(function(err, req, res, next) {
69+
app.use(function (err, req, res, next) {
6870
// set locals, only providing error in development
6971
res.locals.message = err.message;
70-
res.locals.error = req.app.get('env') === 'development' ? err : {};
72+
res.locals.error = req.app.get("env") === "development" ? err : {};
7173

7274
// render the error page
7375
res.status(err.status || 500);
74-
res.render('error');
76+
res.render("error");
7577
});
7678

7779
module.exports = app;

scaffoldTpl/views/index.html

Lines changed: 77 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,97 @@
1-
<p><img src="https://staffbase.com/wp-content/themes/staffbase-theme/img/logo-blau.svg" alt="Staffbase Logo"></p>
2-
<p>Welcome to your Staffbase SSO plugin server. Please follow the following instructions
3-
to get started with your Plugin Application.</p>
1+
<p>
2+
<img
3+
src="https://staffbase.com/wp-content/themes/staffbase-theme/img/logo-blau.svg"
4+
alt="Staffbase Logo"
5+
/>
6+
</p>
7+
<p>
8+
Welcome to your Staffbase SSO plugin server. Please follow the following
9+
instructions to get started with your Plugin Application.
10+
</p>
411
<h2>Prerequisites</h2>
5-
<p>In order to get connected with the Staffbase SSO interface, you need a Valid Secret and an Audience ID.</p>
6-
<p>If you are here, you probably have a secret and audience ID registered with Staffbase. If you are not sure about it or you need more information about Staffbase SSO, feel free to contact the Customer Success team at Staffbase.</p>
12+
<p>
13+
In order to get connected with the Staffbase SSO interface, you need a Valid
14+
Secret and an Audience ID.
15+
</p>
16+
<p>
17+
If you are here, you probably have a secret and audience ID registered with
18+
Staffbase. If you are not sure about it or you need more information about
19+
Staffbase SSO, feel free to contact the Customer Success team at Staffbase.
20+
</p>
721
<h2>Configuration</h2>
8-
<p>After the scaffolding is complete, you need to provide some values for configuring your
9-
plugin server. The following values need to be configured.</p>
22+
<p>
23+
After the scaffolding is complete, you need to provide some values for
24+
configuring your plugin server. The following values need to be configured.
25+
</p>
1026
<ul>
11-
<li>Plugin Secret</li>
12-
<li>Plugin Audience</li>
27+
<li>Plugin Secret</li>
28+
<li>Plugin Audience</li>
1329
</ul>
14-
<p>You can either specify these values in environment variables or directly passing
15-
the values in the <code>app.js</code> file where the middleware is initialized.</p>
16-
<p>To configure values in <code>app.js</code> file, change the following lines:</p>
30+
<p>
31+
You can either specify these values in environment variables or directly
32+
passing the values in the <code>app.js</code> file where the middleware is
33+
initialized.
34+
</p>
35+
<p>
36+
To configure values in <code>app.js</code> file, change the following lines:
37+
</p>
1738
<p>app.js</p>
1839
<pre><code class="language-javascript">12 ...
1940
13 ...
2041
14 const key = null;
2142
15 const pluginID = null;
2243
16 ...
2344
</code></pre>
24-
<p>You can also specify these values using environment variables.
25-
Refer to the table to see which environment variables can be used.</p>
45+
<p>
46+
You can also specify these values using environment variables. Refer to the
47+
table to see which environment variables can be used.
48+
</p>
2649
<table>
27-
<thead>
28-
<tr>
29-
<th style="text-align:left"><em>Value</em></th>
30-
<th style="text-align:center"><em>Environment Variable</em></th>
31-
</tr>
32-
</thead>
33-
<tbody>
34-
<tr>
35-
<td style="text-align:left">Secret</td>
36-
<td style="text-align:center">STAFFBASE_SSO_SECRET</td>
37-
</tr>
38-
<tr>
39-
<td style="text-align:left">Audience</td>
40-
<td style="text-align:center">STAFFBASE_SSO_AUDIENCE</td>
41-
</tr>
42-
<tr>
43-
<td style="text-align:left">Server Port</td>
44-
<td style="text-align:center">PORT</td>
45-
</tr>
46-
</tbody>
50+
<thead>
51+
<tr>
52+
<th style="text-align: left"><em>Value</em></th>
53+
<th style="text-align: center"><em>Environment Variable</em></th>
54+
</tr>
55+
</thead>
56+
<tbody>
57+
<tr>
58+
<td style="text-align: left">Secret</td>
59+
<td style="text-align: center">STAFFBASE_SSO_SECRET</td>
60+
</tr>
61+
<tr>
62+
<td style="text-align: left">Audience</td>
63+
<td style="text-align: center">STAFFBASE_SSO_AUDIENCE</td>
64+
</tr>
65+
<tr>
66+
<td style="text-align: left">Server Port</td>
67+
<td style="text-align: center">PORT</td>
68+
</tr>
69+
</tbody>
4770
</table>
4871
<h2>Running the server</h2>
49-
<p><em>create-staffbase-plugin</em> installs the project dependencies for you.
50-
After configurations is done, the only thing you need to do is navigate to the
51-
folder where your app was generated and start the express server.</p>
72+
<p>
73+
<em>create-staffbase-plugin</em> installs the project dependencies for you.
74+
After configurations is done, the only thing you need to do is navigate to the
75+
folder where your app was generated and start the express server.
76+
</p>
5277
<pre><code class="language-bash">$ cd [path of generated app]
5378
$ npm start
5479
</code></pre>
5580
<h2>Further Reading</h2>
56-
<p>For getting more information about Staffbase SSO, please check out the following links:</p>
81+
<p>
82+
For getting more information about Staffbase SSO, please check out the
83+
following links:
84+
</p>
5785
<ul>
58-
<li><a href="https://developers.staffbase.com/concepts/customplugin-overview/">Developer Portal: Custom Plugins</a></li>
59-
<li><a href="https://github.com/Staffbase/plugins-sdk-nodejs/blob/master/README.MD">Staffbase Plugins SDK for Node.js</a></li>
86+
<li>
87+
<a href="https://developers.staffbase.com/concepts/customplugin-overview/"
88+
>Developer Portal: Custom Plugins</a
89+
>
90+
</li>
91+
<li>
92+
<a
93+
href="https://github.com/Staffbase/plugins-sdk-nodejs/blob/master/README.md"
94+
>Staffbase Plugins SDK for Node.js</a
95+
>
96+
</li>
6097
</ul>

0 commit comments

Comments
 (0)