-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (31 loc) · 1.14 KB
/
index.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
const express = require("express");
const app = express();
const path = require("path");
const axios = require("axios");
const sslRedirect = require("heroku-ssl-redirect");
const bodyParser = require("body-parser");
const cors = require("cors");
const Sha256Streaming = require("@bitmatrix/sha256streaming");
// enable ssl redirect
app.use(sslRedirect.default());
// support parsing of application/json type post data
app.use(bodyParser.json());
//support parsing of application/x-www-form-urlencoded post data
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cors());
// app.set("view engine", "ejs");
// app.set("views", path.join(__dirname, "views"));
app.listen(process.env.PORT || 8080);
app.get("/", (req, res) => {
res.send("hello");
});
app.post("/sha256initialize", (req, res) => {
const param1 = req.body.param1;
const sha256contextResult = Sha256Streaming.sha256Initializer(param1.toString());
res.send(sha256contextResult);
});
// app.get("/result", (req, res) => {
// const { text } = req.query;
// const sha256contextResult = sha256context(text);
// res.render("result.ejs", { result: sha256contextResult });
// });