This repository was archived by the owner on Jan 10, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathserver.ts
More file actions
115 lines (91 loc) · 3.37 KB
/
Copy pathserver.ts
File metadata and controls
115 lines (91 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { AsciiDocModule } from './src/modules/asciidoc';
import { HyraxModule } from './src/modules/hyrax';
import { MarkdownModule } from './src/modules/markdown';
import { MenuBuilder } from './src/modules/menu-builder';
import express = require('express');
import http = require('http');
import path = require('path');
const app = express();
app.use(express.static(__dirname + '/website'));
app.use(express.static(__dirname + '/public'));
// AsciiDoc
const asciiDocModule = new AsciiDocModule();
const hyraxModule = new HyraxModule();
const markdownModule = new MarkdownModule();
const menuModule = new MenuBuilder();
app.get('/api/menu', (req, res) => {
res.status(200).send(menuModule.menu);
});
app.get('/api/adoc/:pageTitle', (req, res) => {
asciiDocModule.getStandardArticle(req.params['pageTitle']).subscribe(response => {
res.status(200).send(response);
}, error => {
res.status(error.errorCode).send(error);
});
});
// Legacy markdown
app.get('/api/content/faq', (req, res) => {
markdownModule.getFaq().subscribe(response => {
res.status(200).send(response)
}, error => {
res.status(error.errorCode).send(error);
});
});
app.get('/api/content/faq/:articleTitle', (req, res) => {
markdownModule.getFaqArticle(req.params['articleTitle']).subscribe(response => {
res.status(200).send(response);
}, error => {
res.status(error.errorCode).send(error);
});
});
// Hyrax
app.get('/api/versions', (req, res) => {
hyraxModule.getAllVersions().subscribe(response => {
res.status(200).send(response);
}, error => {
res.status(error.errorCode).send(error);
})
});
app.get('/api/versions/latest', (req, res) => {
hyraxModule.getVersion(-1).subscribe(response => {
res.status(200).send(response);
}, error => {
res.status(error.errorCode).send(error);
});
});
app.get('/api/versions/:version', (req, res) => {
hyraxModule.getVersion(req.params['version']).subscribe(response => {
res.status(200).send(response);
}, error => {
res.status(error.errorCode).send(error);
});
});
// Hyrax Guide
app.get('/api/hyrax/guide', (req, res) => {
hyraxModule.getGuide().subscribe(response => {
res.status(200).send(response);
}, error => {
res.status(error.errorCode).send(error);
});
})
// Images
app.use('/images', express.static(path.resolve(path.join('public', 'images'))));
// Public key
app.use('/security', express.static(path.resolve('public', 'security')));
// app.get('/api/image/:imageName', (req, res) => {
// hyraxModule.getGuide().subscribe(response => {
// res.status(200).send(response);
// }, error => {
// res.status(error.errorCode).send(error);
// });
// })
// Jira
// app.get('/api/jira/:issue', (req, res) => jira.getIssue(req, res));
// app.get('/api/jira/HK/versions', (req, res) => jira.getFixVersions(res));
// app.get('/api/jira/HK/versions/:fixVersionID', (req, res) => jira.getFixVersionByID(req, res));
// Routing
// app.get('', function (req, res) { return res.status(200).sendFile(path.join(__dirname, 'website', 'index.html')); });
app.all('*', function (req, res) { return res.status(200).sendFile(path.join(__dirname, 'website', 'index.html')); });
http.createServer(app).listen(process.env.PORT || 3001, () => {
console.log(`Server running on port ${process.env.PORT || 3001}.`)
});