-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
41 lines (33 loc) · 1.25 KB
/
app.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
export default (express, bodyParser, createReadStream, crypto, http) => {
const app = express();
const CORS = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET,POST,PUT,DELETE,OPTIONS',
'Access-Control-Allow-Headers':'x-test,Content-Type,Accept, Access-Control-Allow-Headers'
};
app.use((r, res, next) => { r.res.set(CORS); next(); });
app.use(bodyParser.urlencoded({ extended: true }));
app.get('/sha1/:input', (req, res) => {
var hash = crypto.createHash('sha1');
hash = hash.update(req.params.input);
hash = hash.digest('hex');
res.send(hash);
});
app.get('/login/', (req, res) => res.send('andreipavlevich'))
app.get('/code/', (req, res) => {
const path = import.meta.url.substring(7);
createReadStream(path).pipe(res);
});
app.all('/req/', (req, res) => {
http.get(req.query.addr, (resp) => {
let contents = '';
resp.on('data', (chunk) =>
{
contents += chunk;
})
resp.on('end', () => res.send(contents));
});
});
app.all('/*', (req, res) => res.send('andreipavlevich'));
return app;
};