-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
44 lines (37 loc) · 1.04 KB
/
server.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 Moralis = require("moralis/node");
const fs = require("fs");
const dotenv = require("dotenv");
const app = express();
dotenv.config();
// Moralis.initialize(process.env.APPLICATION_ID);
// Moralis.serverURL = process.env.SERVER_URL;
const serverUrl = process.env.SERVER_URL;
const appId = process.env.APPLICATION_ID;
const masterKey = process.env.MASTER_KEY;
await Moralis.start({ serverUrl, appId, masterKey });
const init = async () => {
global.web3 = await Moralis.Web3.enable();
const user = await Moralis.User.current();
};
const login = async () => {
await Moralis.Web3.authenticate();
const user = await Moralis.User.current();
};
const logout = async () => {
await Moralis.User.logOut();
};
const PORT = 5003;
//
app.get("/", (req, res) => {
init();
login();
res.status(201).send(`<button onClick = login() >Login</button>`);
});
app.all("*", (req, res) => {
return res.send("Cannot find that page");
});
//
app.listen(PORT, () => {
console.log(`server started online @ ${PORT}`);
});