-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
40 lines (32 loc) · 1.21 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
/*const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const { tokenCounter, mintToken } = require('./Active_SCMethods.js')
*/
import express from 'express';
import cors from 'cors';
import bodyParser from 'body-parser';
import { tokenCounter, mintToken } from './Active_SCMethods.js';
const app = express();
app.use(cors());
const port = 8080;
const my_address = "0x6f9e2777D267FAe69b0C5A24a402D14DA1fBcaA1";
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }));
// parse application/json
app.use(bodyParser.json());
app.use('/', express.static('public_static'));
app.get('api/tokenCounter', async (req, res) => {
console.log("**** GET /tokenCounter ****");
const counter = await tokenCounter();
res.status(200).set('Content-Type', 'application/json').send(counter);
});
app.post("/api/claimPOM", async (req, res) => {
const userAddress = req.body.address || my_addres;
console.log('**** Claiming POM... ****');
const minted = await mintToken(userAddress, 0);
res.status(200).set('Content-Type', 'application/json').send(minted.hash);
});
app.listen(port, () => {
console.log('server running on port 8080');
});