-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (32 loc) · 955 Bytes
/
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
const express = require('express')
const path = require('path')
const { HOST } = require('./src/constants')
const db = require('./src/database')
const PORT = process.env.PORT || 5000
const app = express()
.set('port', PORT)
.set('views', path.join(__dirname, 'views'))
.set('view engine', 'ejs')
// Static public files
app.use(express.static(path.join(__dirname, 'public')))
app.get('/', function(req, res) {
res.send('Get ready for OpenSea!!');
})
app.get('/api/token/:token_id', function(req, res) {
const tokenId = parseInt(req.params.token_id).toString()
const aqar = db[tokenId]
const data = {
'name': aqar.name,
'attributes': {
'sq_foot': aqar.sq_foot,
'color': aqar.color,
'rating': aqar.rating,
'type': aqar.type
},
'image': `${HOST}/images/${tokenId}.jpg`
}
res.send(data)
})
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
})