-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetaStage.js
More file actions
45 lines (33 loc) · 1.25 KB
/
metaStage.js
File metadata and controls
45 lines (33 loc) · 1.25 KB
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
45
'use strict'
import dotenv from 'dotenv';
dotenv.config();
import express from 'express';
import bodyParser from 'body-parser';
import cors from 'cors';
import config from './config/config.js';
import { consoleBar, timeLog } from './lib/common.js';
import { ping } from './controller/system.js';
import { getNftCount } from './controller/blockchain.js';
import { startListeningRegister, startListeningTransfer, startListeningUnlock, startListeningUnregister } from './controller/eventListening.js';
import { getNftInfo } from './lib/db.js';
// ------------------ router set -----------------
const serverPort = config.SERVER_PORT;
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cors());
const router = express.Router();
// -------------------- api --------------------
router.route('/ping').get(ping);
router.route('/nft-count').get(getNftCount);
router.route('/nft-info').get(getNftInfo);
// ----------------- listener -------------------
startListeningTransfer();
startListeningUnlock();
startListeningRegister();
startListeningUnregister();
// ---------------- server start -----------------
app.use('/meta-stage-web3/api/v1', router);
app.listen(serverPort);
consoleBar();
timeLog('Test Server Started');