-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathserver.ts
More file actions
35 lines (32 loc) · 833 Bytes
/
server.ts
File metadata and controls
35 lines (32 loc) · 833 Bytes
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
import http from 'node:http';
import {
ConsoleLogger,
HttpValidator,
MemoryCTIStore,
RedisCTIStore
} from '../src';
const store = process.env.REDIS_URL
? new RedisCTIStore(new URL(process.env.REDIS_URL))
: new MemoryCTIStore();
const httpValidator = new HttpValidator({
keys: [
{
kid: 'Symmetric256',
key: Buffer.from(
'403697de87af64611c1d32a05dab0fe1fcb715a86ab435f1ec99192d79569388',
'hex'
)
}
],
issuer: 'eyevinn',
store,
logger: new ConsoleLogger()
});
const server = http.createServer(async (req, res) => {
const result = await httpValidator.validateHttpRequest(req, res);
res.writeHead(result.status, { 'Content-Type': 'text/plain' });
res.end(result.message || 'ok');
});
server.listen(8080, '127.0.0.1', () => {
console.log('Server listening');
});