forked from jgkaplan/gemini-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
53 lines (41 loc) · 1.04 KB
/
example.js
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
const fs = require('fs');
const gemini = require('./index.js');
const options = {
cert: fs.readFileSync('cert.pem'),
key: fs.readFileSync('key.pem')
};
const app = gemini(options);
app.on('/', (req, res) => {
res.file('test.gemini');
});
app.on('/input', (req, res) => {
if(req.query){
res.data('you typed ' + req.query);
}else{
res.input('type something');
}
});
app.on('/testMiddlewear', gemini.requireInput("enter something"), (req, res) => {
res.data('thanks. you typed ' + req.query);
});
app.on('/other', (req, res) => {
res.data('welcome to the other page');
})
app.on('/test', gemini.static('./src/things'));
app.on('/redirectMe', gemini.redirect('/other'));
app.on('/cert', (req, res) => {
if(!req.fingerprint){
res.certify();
}else{
res.data('thanks for the cert');
}
})
app.on('/protected', gemini.requireCert, (req, res) => {
res.data('only clients with certificates can get here');
});
// app.on('*', (req, res) => {
// res.data('nyaa');
// });
app.listen(() => {
console.log("Listening...");
});