@manyos/smileconnect-api 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/nodejs.yml +26 -0
- package/CHANGELOG.md +75 -0
- package/Dockerfile +21 -0
- package/README.md +1 -0
- package/app.js +316 -0
- package/conf/clients.json +2491 -0
- package/conf/mapping.json +1048 -0
- package/conf/scripts/p1.js +11 -0
- package/conf/scripts/p2.js +1 -0
- package/conf/scripts/p3.js +1 -0
- package/conf/scripts/p4.js +2 -0
- package/conf/scripts/script1.js +2 -0
- package/conf/scripts/script2.js +2 -0
- package/conf/scripts/script3.js +2 -0
- package/controller/cmdbobjectController.js +291 -0
- package/controller/eventLogController.js +78 -0
- package/controller/orgdataController.js +440 -0
- package/controller/relatedObjectsController.js +194 -0
- package/controller/scriptController.js +213 -0
- package/controller/taskController.js +368 -0
- package/controller/templateController.js +97 -0
- package/controller/ticketCIRelationController.js +522 -0
- package/controller/ticketController.js +329 -0
- package/controller/ticketWorkLogController.js +195 -0
- package/docs/.gitattributes +48 -0
- package/docs/404.html +13 -0
- package/docs/CNAME +1 -0
- package/docs/Gemfile +7 -0
- package/docs/Gemfile.lock +249 -0
- package/docs/_config.yml +257 -0
- package/docs/_data/SocialNetworks.yml +92 -0
- package/docs/_data/ui-text.yml +494 -0
- package/docs/_includes/disqus.html +17 -0
- package/docs/_includes/ext-css.html +7 -0
- package/docs/_includes/ext-js.html +7 -0
- package/docs/_includes/fb-comment.html +14 -0
- package/docs/_includes/footer-minimal.html +16 -0
- package/docs/_includes/footer-scripts.html +32 -0
- package/docs/_includes/footer.html +51 -0
- package/docs/_includes/google_analytics.html +14 -0
- package/docs/_includes/gtag.html +11 -0
- package/docs/_includes/gtm_body.html +6 -0
- package/docs/_includes/gtm_head.html +9 -0
- package/docs/_includes/head.html +131 -0
- package/docs/_includes/header.html +76 -0
- package/docs/_includes/just_comments.html +4 -0
- package/docs/_includes/matomo.html +17 -0
- package/docs/_includes/nav.html +57 -0
- package/docs/_includes/social-share.html +42 -0
- package/docs/_includes/staticman-comment.html +22 -0
- package/docs/_includes/staticman-comments.html +81 -0
- package/docs/_layouts/base.html +35 -0
- package/docs/_layouts/default.html +9 -0
- package/docs/_layouts/minimal.html +26 -0
- package/docs/_layouts/page.html +26 -0
- package/docs/_layouts/post.html +82 -0
- package/docs/_posts/2015-02-28-test-markdown.md +77 -0
- package/docs/aboutme.md +18 -0
- package/docs/css/bootstrap-social.css +147 -0
- package/docs/css/bootstrap-theme.css +476 -0
- package/docs/css/bootstrap-theme.css.map +1 -0
- package/docs/css/bootstrap-theme.min.css +5 -0
- package/docs/css/bootstrap.css +6566 -0
- package/docs/css/bootstrap.css.map +1 -0
- package/docs/css/bootstrap.min.css +5 -0
- package/docs/css/main-minimal.css +13 -0
- package/docs/css/main.css +788 -0
- package/docs/css/normalize.css +427 -0
- package/docs/css/pygment_highlights.css +61 -0
- package/docs/css/staticman.css +180 -0
- package/docs/eventlog/events.md +65 -0
- package/docs/feed.xml +24 -0
- package/docs/general/architecture.md +10 -0
- package/docs/general/config.md +192 -0
- package/docs/general/field-management.md +119 -0
- package/docs/general/release-notes.md +9 -0
- package/docs/getting-started.md +19 -0
- package/docs/howto/cmdbobjects.md +339 -0
- package/docs/howto/incident-worklogs.md +186 -0
- package/docs/howto/incidents.md +244 -0
- package/docs/howto/sample-config.md +518 -0
- package/docs/howto/token.md +71 -0
- package/docs/howto/worklog-attachment.md +113 -0
- package/docs/img/404-southpark.jpg +0 -0
- package/docs/img/architecture.jpeg +0 -0
- package/docs/img/attachment-upload.png +0 -0
- package/docs/img/avatar-icon.png +0 -0
- package/docs/img/bgimage.png +0 -0
- package/docs/img/gb-isapi.jpg +0 -0
- package/docs/img/install-steps.gif +0 -0
- package/docs/img/workflow.png +0 -0
- package/docs/index.md +41 -0
- package/docs/installation.md +123 -0
- package/docs/js/bootstrap.js +2306 -0
- package/docs/js/bootstrap.min.js +7 -0
- package/docs/js/jquery-1.11.2.min.js +4 -0
- package/docs/js/main.js +140 -0
- package/docs/js/staticman.js +54 -0
- package/docs/openapi.json +15097 -0
- package/docs/postinstall.md +169 -0
- package/docs/preinstall.md +19 -0
- package/docs/spec/index.html +24 -0
- package/docs/staticman.yml +110 -0
- package/docs/tags.html +34 -0
- package/docs/workflow.md +127 -0
- package/nodemon.json +3 -0
- package/package.json +46 -0
- package/routes/appConfigRoutes.js +352 -0
- package/routes/ciRelationRoutes.js +38 -0
- package/routes/cmdbObjectRoutes.js +154 -0
- package/routes/organisationRoutes.js +121 -0
- package/routes/peopleRelationRoutes.js +38 -0
- package/routes/personRoutes.js +131 -0
- package/routes/supportgroupRoutes.js +122 -0
- package/routes/taskRoutes.js +306 -0
- package/routes/templateRoutes.js +67 -0
- package/routes/ticketRoutes.js +181 -0
- package/routes/ticketWorkLogRoutes.js +185 -0
- package/screwdriver.yaml +52 -0
- package/test/appTest.js +3 -0
- package/test/changeTest.js +541 -0
- package/test/cmdbobjectTest.js +167 -0
- package/test/files/logo.png +0 -0
- package/test/incidentTest.js +539 -0
- package/test/orgdataTest.js +156 -0
- package/test/problemTest.js +512 -0
- package/test/templateTest.js +80 -0
- package/test/testUtils.js +21 -0
- package/test/workorderTest.js +544 -0
- package/util/arquery.js +416 -0
- package/util/auth.js +37 -0
- package/util/cache.service.js +52 -0
- package/util/config.js +361 -0
- package/util/constants.js +73 -0
- package/util/mappingUtil.js +96 -0
- package/util/paramHelper.js +43 -0
- package/util/relationUtil.js +63 -0
- package/util/responsehandler.js +92 -0
- package/util/schemas/clientConfigSchema.js +180 -0
- package/util/schemas/fieldMappingSchema.js +211 -0
- package/util/searchUtil.js +148 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Node CI
|
|
2
|
+
|
|
3
|
+
on: [push]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
|
|
10
|
+
strategy:
|
|
11
|
+
matrix:
|
|
12
|
+
node-version: [8.x, 10.x, 12.x]
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v1
|
|
16
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
17
|
+
uses: actions/setup-node@v1
|
|
18
|
+
with:
|
|
19
|
+
node-version: ${{ matrix.node-version }}
|
|
20
|
+
- name: npm install, build, and test
|
|
21
|
+
run: |
|
|
22
|
+
npm ci
|
|
23
|
+
npm run build --if-present
|
|
24
|
+
npm test
|
|
25
|
+
env:
|
|
26
|
+
CI: true
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# CHANGELOG
|
|
2
|
+
|
|
3
|
+
This file lists all non-trivial changes to Beautiful Jekyll.
|
|
4
|
+
|
|
5
|
+
I often make small changes to documentation, to the demo site, or to the general look-and-feel. These changes will not be listed here. Any other minor changes will also not be listed here.
|
|
6
|
+
|
|
7
|
+
**2018-12-24** Add support for Staticman comments (#440) (thanks @VincentTam)
|
|
8
|
+
|
|
9
|
+
**2018-10-19** Move Google Analytics to the head (#419) (thanks @jpvicari)
|
|
10
|
+
|
|
11
|
+
**2018-06-08** Add support for Facebook comments (#350) (thanks @npes87184)
|
|
12
|
+
|
|
13
|
+
**2018-02-22** Automatically generate sitemap (#323) (thanks @JosemyDuarte)
|
|
14
|
+
|
|
15
|
+
**2018-01-18** Add clickable tags to each post and a tags index page, works for GitHub sites (#307) (thanks @OCram85)
|
|
16
|
+
|
|
17
|
+
**2018-01-14** Redo Dockerfile (#302) (thanks @jennydaman)
|
|
18
|
+
|
|
19
|
+
**2018-01-06** More color personalization options (#297 and #299) (thanks @jennydaman)
|
|
20
|
+
|
|
21
|
+
**2018-01-05** Abstract the social networks logic (thanks @OCram85)
|
|
22
|
+
|
|
23
|
+
**2018-01-03** Avatar image no longer causes a ghost click (thanks @alefi87)
|
|
24
|
+
|
|
25
|
+
**2017-10-16** Add GitHub buttons to posts (#265) (thanks @yonicd)
|
|
26
|
+
|
|
27
|
+
**2017-09-04** Ability to change colour/image of navbar/footer/body
|
|
28
|
+
|
|
29
|
+
**2017-08-17** Add support for notification, error, and warning boxes in markdown (#227) (thanks @OCram85)
|
|
30
|
+
|
|
31
|
+
**2017-08-12** Add social buttons for twitch, yelp, and steam (#234) (thanks @TheRealBenForce)
|
|
32
|
+
|
|
33
|
+
**2017-03-30** Make the footer contact links friendly for screen readers (thanks @eugenius1)
|
|
34
|
+
|
|
35
|
+
**2017-03-30** Started a CHANGELOG file (thanks @eugenius1)
|
|
36
|
+
|
|
37
|
+
**2017-01-28** Add Subresource Integrity (SRI) support (#164) (thanks @tony-ho)
|
|
38
|
+
|
|
39
|
+
**2017-01-09** Add Google Tag Manager Integration (#157) (thanks @csarigoz)
|
|
40
|
+
|
|
41
|
+
**2017-01-06** Add options to configure HTML document title (#154) (thanks @tony-ho)
|
|
42
|
+
|
|
43
|
+
**2016-12-25** Allow dynamic images on each blog post (#143) (thanks @bbritten)
|
|
44
|
+
|
|
45
|
+
**2016-12-15** Support `title-img` config param to have image in the navbar instead of text
|
|
46
|
+
|
|
47
|
+
**2016-12-08** Add support for phone numbers in footer; fix #136
|
|
48
|
+
|
|
49
|
+
**2016-12-06** Update gemfile (#134) (thanks @stephentuso)
|
|
50
|
+
|
|
51
|
+
**2016-10-09** Add Docker deployment (#114) (thanks @mangar)
|
|
52
|
+
|
|
53
|
+
**2016-08-06** Add social share buttons for posts (thanks @rtlee9)
|
|
54
|
+
|
|
55
|
+
**2016-07-29** Add CSS styling to code chunks
|
|
56
|
+
|
|
57
|
+
**2016-07-27** Add clickable tags that lead to a tag page (doesn't work for GitHub hosted sites) (thanks @epwalsh)
|
|
58
|
+
|
|
59
|
+
**2016-07-21** Add support for twitter cards (sharing on Twitter will be better); fixes #70
|
|
60
|
+
|
|
61
|
+
**2016-03-18** Support full-width images in page headers; fixes #37
|
|
62
|
+
|
|
63
|
+
**2016-03-18** Support menus in navigation bar
|
|
64
|
+
|
|
65
|
+
**2016-02-07** Avatar is now conditional (thanks @hristoyankov)
|
|
66
|
+
|
|
67
|
+
**2016-02-02** Migrate (forced to...) to jekyll 3
|
|
68
|
+
|
|
69
|
+
**2016-01-22** Make sure not to include JQuery twice, fixes #29
|
|
70
|
+
|
|
71
|
+
**2015-11-19** Support external links in navigation bar; fixes #3
|
|
72
|
+
|
|
73
|
+
... Many small changes because the site was in its infancy
|
|
74
|
+
|
|
75
|
+
**2015-03-12** Beautiful Jekyll version 0.0000001 is released!
|
package/Dockerfile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
### STAGE 1: Build ###
|
|
2
|
+
|
|
3
|
+
# We label our stage as 'builder'
|
|
4
|
+
FROM node:12.14 as builder
|
|
5
|
+
|
|
6
|
+
COPY package.json package-lock.json ./
|
|
7
|
+
|
|
8
|
+
RUN npm set progress=false && npm config set depth 0 && npm cache clean --force
|
|
9
|
+
|
|
10
|
+
## Storing node modules on a separate layer will prevent unnecessary npm installs at each build
|
|
11
|
+
RUN npm i
|
|
12
|
+
|
|
13
|
+
WORKDIR /home/node/app
|
|
14
|
+
|
|
15
|
+
COPY . .
|
|
16
|
+
|
|
17
|
+
## Build the angular app in production mode and store the artifacts in dist folder
|
|
18
|
+
|
|
19
|
+
EXPOSE 3000
|
|
20
|
+
|
|
21
|
+
CMD npm start
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
The documentation can be found here: <https://smileconnect.manyosdocs.de>
|
package/app.js
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
|
|
2
|
+
const app = require('express')();
|
|
3
|
+
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect_' + path.basename(__filename));
|
|
6
|
+
|
|
7
|
+
const passport = require('passport');
|
|
8
|
+
const JwtStrategy = require('passport-jwt').Strategy,
|
|
9
|
+
ExtractJwt = require('passport-jwt').ExtractJwt;
|
|
10
|
+
|
|
11
|
+
const bodyParser = require('body-parser');
|
|
12
|
+
|
|
13
|
+
const config = require('./util/config');
|
|
14
|
+
|
|
15
|
+
const cors = require('cors');
|
|
16
|
+
|
|
17
|
+
const rateLimit = require("express-rate-limit");
|
|
18
|
+
|
|
19
|
+
const fileUpload = require('express-fileupload');
|
|
20
|
+
|
|
21
|
+
const CONSTANTS = require('./util/constants');
|
|
22
|
+
|
|
23
|
+
const ticketRoutes = require('./routes/ticketRoutes');
|
|
24
|
+
const templateRoutes = require('./routes/templateRoutes');
|
|
25
|
+
const ticketWorkLogRoutes = require('./routes/ticketWorkLogRoutes');
|
|
26
|
+
const taskRoutes = require('./routes/taskRoutes');
|
|
27
|
+
const cmdbObjectRoutes = require('./routes/cmdbObjectRoutes');
|
|
28
|
+
const personRoutes = require('./routes/personRoutes');
|
|
29
|
+
const organisationRoutes = require('./routes/organisationRoutes');
|
|
30
|
+
const supportgroupRoutes = require('./routes/supportgroupRoutes');
|
|
31
|
+
const ciRelationRoutes = require('./routes/ciRelationRoutes');
|
|
32
|
+
const peopleRelationRoutes = require('./routes/peopleRelationRoutes');
|
|
33
|
+
const appConfigRoutes = require('./routes/appConfigRoutes');
|
|
34
|
+
const relatedObjectsController = require('./controller/relatedObjectsController');
|
|
35
|
+
const addRequestId = require('express-request-id')();
|
|
36
|
+
const compression = require('compression');
|
|
37
|
+
const ticketController = require('./controller/ticketController');
|
|
38
|
+
|
|
39
|
+
const responseHandler = require('./util/responsehandler');
|
|
40
|
+
|
|
41
|
+
const relationUtil = require('./controller/ticketCIRelationController');
|
|
42
|
+
const {getIncludeArray} = require('./util/paramHelper');
|
|
43
|
+
|
|
44
|
+
const http = require('http');
|
|
45
|
+
const https = require('https');
|
|
46
|
+
|
|
47
|
+
const maxHTTPSockets = process.env.MAX_HTTP_SOCKETS || 10;
|
|
48
|
+
|
|
49
|
+
http.globalAgent.maxSockets = maxHTTPSockets;
|
|
50
|
+
https.globalAgent.maxSockets = maxHTTPSockets;
|
|
51
|
+
|
|
52
|
+
log.info('Set max HTTP(S) Sockets to', maxHTTPSockets);
|
|
53
|
+
|
|
54
|
+
require('dotenv').config();
|
|
55
|
+
|
|
56
|
+
// The signals we want to handle
|
|
57
|
+
// NOTE: although it is tempting, the SIGKILL signal (9) cannot be intercepted and handled
|
|
58
|
+
var signals = {
|
|
59
|
+
'SIGHUP': 1,
|
|
60
|
+
'SIGINT': 2,
|
|
61
|
+
'SIGTERM': 15
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const opts = {};
|
|
65
|
+
|
|
66
|
+
opts.jwtFromRequest = ExtractJwt.fromAuthHeaderAsBearerToken();
|
|
67
|
+
|
|
68
|
+
let audienceArray = [];
|
|
69
|
+
const audience = process.env.SSO_AUDIENCE;
|
|
70
|
+
if (typeof audience === 'string') {
|
|
71
|
+
audienceArray = audience.split(',');
|
|
72
|
+
}
|
|
73
|
+
audienceArray = audienceArray.map(element => element.trim());
|
|
74
|
+
|
|
75
|
+
opts.secretOrKey = '-----BEGIN PUBLIC KEY-----\n' + process.env.SSO_PUBLIC_KEY + '\n-----END PUBLIC KEY-----';
|
|
76
|
+
if (process.env.SSO_ISSUER != null && process.env.SSO_ISSUER != undefined) {
|
|
77
|
+
opts.issuer = process.env.SSO_ISSUER;
|
|
78
|
+
}
|
|
79
|
+
if (audienceArray.length > 0) {
|
|
80
|
+
opts.audience = audienceArray;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Do any necessary shutdown logic for our application here
|
|
84
|
+
const shutdown = (signal, value) => {
|
|
85
|
+
console.log("shutdown!");
|
|
86
|
+
server.close(() => {
|
|
87
|
+
console.log(`server stopped by ${signal} with value ${value}`);
|
|
88
|
+
process.exit(128 + value);
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// Create a listener for each of the signals that we want to handle
|
|
93
|
+
Object.keys(signals).forEach((signal) => {
|
|
94
|
+
process.on(signal, () => {
|
|
95
|
+
console.log(`process received a ${signal} signal`);
|
|
96
|
+
shutdown(signal, signals[signal]);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
//set transactionID
|
|
102
|
+
app.use(addRequestId);
|
|
103
|
+
|
|
104
|
+
//activate rate-limiter
|
|
105
|
+
|
|
106
|
+
// Enable if you're behind a reverse proxy (Heroku, Bluemix, AWS ELB, Nginx, etc)
|
|
107
|
+
// see https://expressjs.com/en/guide/behind-proxies.html
|
|
108
|
+
app.set('trust proxy', 1);
|
|
109
|
+
|
|
110
|
+
const limiter = rateLimit({
|
|
111
|
+
windowMs: 15 * 60 * 1000, // 15 minutes
|
|
112
|
+
max: process.env.RATE_LIMIT || 10000 // limit each IP to 100 requests per windowMs
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
/* app.use(function (req, res, next) {
|
|
116
|
+
log.debug(req);
|
|
117
|
+
next();
|
|
118
|
+
}); */
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
// apply to all requests
|
|
122
|
+
app.use(limiter);
|
|
123
|
+
|
|
124
|
+
app.use(cors());
|
|
125
|
+
|
|
126
|
+
app.use(compression()); //Compress all routes
|
|
127
|
+
|
|
128
|
+
log.debug('Passport Opts', opts);
|
|
129
|
+
passport.use(
|
|
130
|
+
new JwtStrategy(opts, function (jwt_payload, done) {
|
|
131
|
+
//log.info(jwt_payload);
|
|
132
|
+
//log.info('token', jwt_payload.sub);
|
|
133
|
+
//TODO: Config error abfangen
|
|
134
|
+
//TODO: Add AdminScope and Impersonate
|
|
135
|
+
const user = {
|
|
136
|
+
'id': jwt_payload.sub,
|
|
137
|
+
'azp': jwt_payload.azp,
|
|
138
|
+
'scope': jwt_payload.scope,
|
|
139
|
+
'exp': jwt_payload.exp,
|
|
140
|
+
'config': config.getClientConfig(jwt_payload.azp),
|
|
141
|
+
'username': jwt_payload.preferred_username
|
|
142
|
+
}
|
|
143
|
+
log.debug('Passport User', jwt_payload);
|
|
144
|
+
const resource_access = jwt_payload.resource_access;
|
|
145
|
+
log.debug('User Resource Access', resource_access);
|
|
146
|
+
if (resource_access !== null && resource_access !== undefined && resource_access[user.azp] !== null && resource_access[user.azp] !== undefined) {
|
|
147
|
+
user.accessRoles = resource_access[user.azp].roles;
|
|
148
|
+
}
|
|
149
|
+
log.debug('Access Roles', user.accessRoles);
|
|
150
|
+
return done(null, user, {scope: 'read'});
|
|
151
|
+
}));
|
|
152
|
+
|
|
153
|
+
// parse body
|
|
154
|
+
|
|
155
|
+
app.use(bodyParser.json({limit: '200mb'}));
|
|
156
|
+
app.use(bodyParser.urlencoded({limit: '200mb', extended: true}));
|
|
157
|
+
|
|
158
|
+
const maxFilesize = process.env.MAX_FILESIZE || 5;
|
|
159
|
+
|
|
160
|
+
app.use(fileUpload({
|
|
161
|
+
limits: { fileSize: maxFilesize * 1024 * 1024 },
|
|
162
|
+
abortOnLimit: true
|
|
163
|
+
}));
|
|
164
|
+
|
|
165
|
+
//global check for compatibility
|
|
166
|
+
app.use(function (req, res, next) {
|
|
167
|
+
if (req.query.include && req.query.includeObjects) {
|
|
168
|
+
req.errorStatus = 400;
|
|
169
|
+
return next ('includeObjects is deprecated and cannot be used together with include. Use only include instead.');
|
|
170
|
+
} else if (req.query.include && req.body && req.body.getRelations) {
|
|
171
|
+
req.errorStatus = 400;
|
|
172
|
+
return next ('getRelations is deprecated and cannot be used together with include. Use only include instead.');
|
|
173
|
+
} else next();
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
//Check for includedObjects parameter globally
|
|
177
|
+
app.use(function (req, res, next) {
|
|
178
|
+
let includeObjects = false;
|
|
179
|
+
if (req.query) {
|
|
180
|
+
if (req.query.includeObjects && req.query.includeObjects.toLowerCase() === 'true') {
|
|
181
|
+
includeObjects = true;
|
|
182
|
+
req.includeObjects = includeObjects;
|
|
183
|
+
}
|
|
184
|
+
//for backwards compatibility
|
|
185
|
+
if (req.includeObjects) {
|
|
186
|
+
req.query.include = req.query.include + ',ciRelations,personRelations,organisationRelations,supportGroupRelations,persons,organisations,supportGroups';
|
|
187
|
+
}
|
|
188
|
+
if (req.body && req.body.getRelations) {
|
|
189
|
+
req.query.include = req.query.include + ',ciRelations,personRelations,organisationRelations,supportGroupRelations,ticketRelations';
|
|
190
|
+
}
|
|
191
|
+
if (req.query.include) {
|
|
192
|
+
req.includeArray = getIncludeArray(req.query.include);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
next();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// debugger
|
|
200
|
+
/*
|
|
201
|
+
app.get('/debug', function (req, res, next) {
|
|
202
|
+
|
|
203
|
+
console.log('user', req.user);
|
|
204
|
+
|
|
205
|
+
});*/
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
//global authentication
|
|
209
|
+
app.use(passport.authenticate('jwt', {session: false}), responseHandler.logRequest);
|
|
210
|
+
|
|
211
|
+
// setup routes
|
|
212
|
+
|
|
213
|
+
app.use('/v1/cmdbobjects', cmdbObjectRoutes);
|
|
214
|
+
app.use('/v1/persons', personRoutes);
|
|
215
|
+
app.use('/v1/supportgroups', supportgroupRoutes);
|
|
216
|
+
app.use('/v1/organisations', organisationRoutes);
|
|
217
|
+
app.use('/v1/cirelations', ciRelationRoutes);
|
|
218
|
+
app.use('/v1/peoplerelations', peopleRelationRoutes);
|
|
219
|
+
app.use('/v1/appconfig', appConfigRoutes);
|
|
220
|
+
|
|
221
|
+
//tickethandling
|
|
222
|
+
app.use('/v1/(|incidents|problems|workorders|changes)', function(req, res, next) {
|
|
223
|
+
log.debug('dad');
|
|
224
|
+
const ticketType = req.baseUrl.split('/')[2];
|
|
225
|
+
req.ticketType = ticketType;
|
|
226
|
+
req.parentType = ticketType;
|
|
227
|
+
req.requestType = ticketType;
|
|
228
|
+
req.ticketConfig = config.ticketConfig[req.ticketType];
|
|
229
|
+
setParentForm(req);
|
|
230
|
+
next();
|
|
231
|
+
}, ticketRoutes);
|
|
232
|
+
|
|
233
|
+
//templatehandling
|
|
234
|
+
app.use('/v1/templates/(|incidents|problems|workorders|changes|tasks)', function(req, res, next) {
|
|
235
|
+
const ticketType = req.baseUrl.split('/')[3];
|
|
236
|
+
req.ticketType = ticketType;
|
|
237
|
+
req.parentType = ticketType;
|
|
238
|
+
req.requestType = ticketType;
|
|
239
|
+
req.ticketConfig = config.ticketConfig[req.ticketType];
|
|
240
|
+
setParentForm(req);
|
|
241
|
+
next();
|
|
242
|
+
}, templateRoutes);
|
|
243
|
+
|
|
244
|
+
//tickethandling worklogs
|
|
245
|
+
app.use('/v1/:ticketType/:parentId/worklogs', function(req, res, next) {
|
|
246
|
+
log.debug('params1', req.params);
|
|
247
|
+
req.ticketType = req.params.ticketType;
|
|
248
|
+
const parentId = req.params.parentId;
|
|
249
|
+
req.parentId = parentId;
|
|
250
|
+
const allowedTypes = ['incidents', 'problems', 'workorders', 'changes'];
|
|
251
|
+
if (allowedTypes.includes(req.ticketType)) {
|
|
252
|
+
req.ticketConfig = config.ticketConfig[req.ticketType];
|
|
253
|
+
next();
|
|
254
|
+
} else {
|
|
255
|
+
const error = new Error('worklog handling only allowed for ' + allowedTypes);
|
|
256
|
+
next(error);
|
|
257
|
+
}
|
|
258
|
+
}, ticketWorkLogRoutes);
|
|
259
|
+
//tickethandling tasks
|
|
260
|
+
app.use('/v1/:requestType/:parentId/tasks', function(req, res, next) {
|
|
261
|
+
log.debug('params1', req.params);
|
|
262
|
+
log.debug('route', req.baseUrl);
|
|
263
|
+
const requestType = req.params.requestType;
|
|
264
|
+
const parentId = req.params.parentId;
|
|
265
|
+
const allowedTypes = ['incidents', 'problems', 'workorders', 'changes'];
|
|
266
|
+
if (allowedTypes.includes(requestType)) {
|
|
267
|
+
req.parentId = parentId;
|
|
268
|
+
req.requestType = requestType;
|
|
269
|
+
setParentForm(req);
|
|
270
|
+
next();
|
|
271
|
+
} else {
|
|
272
|
+
const error = new Error('task handling only allowed for ' + allowedTypes);
|
|
273
|
+
next(error);
|
|
274
|
+
}
|
|
275
|
+
}, taskRoutes);
|
|
276
|
+
|
|
277
|
+
app.use(relatedObjectsController.getRelatedObjects);
|
|
278
|
+
|
|
279
|
+
app.get("/health", function (req, res) {
|
|
280
|
+
res.status(200).send();
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
app.use(responseHandler.eventQueueHandler);
|
|
284
|
+
|
|
285
|
+
app.use(responseHandler.logErrors);
|
|
286
|
+
app.use(responseHandler.errorHandler);
|
|
287
|
+
|
|
288
|
+
const server = app.listen(3000, function () {
|
|
289
|
+
var host = server.address().address
|
|
290
|
+
var port = server.address().port
|
|
291
|
+
|
|
292
|
+
log.info("itsm proxy http://%s:%s", host, port)
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
function setParentForm(req) {
|
|
296
|
+
if (req.requestType === 'incidents') {
|
|
297
|
+
req.parentForm = CONSTANTS.FORM_INCIDENT;
|
|
298
|
+
req.parentEventBase = CONSTANTS.EVENT_BASE_INC;
|
|
299
|
+
} else if (req.requestType === 'problems') {
|
|
300
|
+
req.parentForm = CONSTANTS.FORM_PROBLEM;
|
|
301
|
+
req.parentEventBase = CONSTANTS.EVENT_BASE_PBM;
|
|
302
|
+
} else if (req.requestType === 'workorders') {
|
|
303
|
+
req.parentForm = CONSTANTS.FORM_WORKORDER;
|
|
304
|
+
req.parentEventBase = CONSTANTS.EVENT_BASE_WOI;
|
|
305
|
+
} else if (req.requestType === 'changes') {
|
|
306
|
+
req.parentForm = CONSTANTS.FORM_CHANGE;
|
|
307
|
+
req.parentEventBase = CONSTANTS.EVENT_BASE_CHG;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
server.timeout = 6000000;
|
|
312
|
+
|
|
313
|
+
//check config on startuo
|
|
314
|
+
config.checkConfig();
|
|
315
|
+
//for testing only
|
|
316
|
+
module.exports = app;
|