Showing
1 changed file
with
33 additions
and
47 deletions
| ... | @@ -2,7 +2,7 @@ const express = require('express'); | ... | @@ -2,7 +2,7 @@ const express = require('express'); |
| 2 | const app = express(); | 2 | const app = express(); |
| 3 | const logger = require('morgan'); | 3 | const logger = require('morgan'); |
| 4 | const bodyParser = require('body-parser'); | 4 | const bodyParser = require('body-parser'); |
| 5 | - | 5 | +const fs = require('fs'); |
| 6 | const apiRouter = express.Router(); | 6 | const apiRouter = express.Router(); |
| 7 | 7 | ||
| 8 | app.use(logger('dev', {})); | 8 | app.use(logger('dev', {})); |
| ... | @@ -13,42 +13,50 @@ app.use(bodyParser.urlencoded({ | ... | @@ -13,42 +13,50 @@ app.use(bodyParser.urlencoded({ |
| 13 | 13 | ||
| 14 | app.use('/api', apiRouter); | 14 | app.use('/api', apiRouter); |
| 15 | 15 | ||
| 16 | -apiRouter.post('/sayHello', function(req, res) { | 16 | +apiRouter.post('/champion', function(req, res) { |
| 17 | + console.log(req.body) | ||
| 18 | + const championName = req["detailParams"]["champion_name"]["value"]; | ||
| 19 | + let championRawData = fs.readFileSync('data/json data/champions.json'); | ||
| 20 | + let championData = JSON.parse(championRawData); | ||
| 21 | + var i = 0; | ||
| 22 | + for (i; i < championData.length; ++i){ | ||
| 23 | + if(championData[i].name == championName){ | ||
| 24 | + break; | ||
| 25 | + } | ||
| 26 | + }; | ||
| 27 | + const championQuery = (championData[i].championID).replace(/"TF3_"/g,''); | ||
| 17 | const responseBody = { | 28 | const responseBody = { |
| 18 | - version: "2.0", | 29 | + "version": "2.0", |
| 19 | - template: { | 30 | + "template": { |
| 20 | - outputs: [ | 31 | + "outputs": [ |
| 21 | { | 32 | { |
| 22 | - simpleText: { | 33 | + "basicCard": { |
| 23 | - text: "hello I'm Ryan" | 34 | + "title": championName, |
| 35 | + "description": "비용 : " + championData[i].cost + "\n" + "시너지 : " + championData[i].traits, | ||
| 36 | + "thumbnail": { | ||
| 37 | + "imageUrl": "data/Image data/champions/" + championName + ".png" | ||
| 38 | + }, | ||
| 39 | + "buttons": [ | ||
| 40 | + { | ||
| 41 | + "action": "webLink", | ||
| 42 | + "label": "상세한 정보 확인", | ||
| 43 | + "webLinkUrl": "https://lolchess.gg/champions/set3.5/" + championQuery | ||
| 44 | + } | ||
| 45 | + ] | ||
| 24 | } | 46 | } |
| 25 | } | 47 | } |
| 26 | ] | 48 | ] |
| 27 | } | 49 | } |
| 28 | - }; | 50 | + } |
| 29 | 51 | ||
| 30 | res.status(200).send(responseBody); | 52 | res.status(200).send(responseBody); |
| 31 | }); | 53 | }); |
| 32 | 54 | ||
| 33 | -apiRouter.post('/showHello', function(req, res) { | ||
| 34 | - console.log(req.body); | ||
| 35 | - | ||
| 36 | - const responseBody = { | ||
| 37 | - version: "2.0", | ||
| 38 | - template: { | ||
| 39 | - outputs: [ | ||
| 40 | - { | ||
| 41 | - simpleImage: { | ||
| 42 | - imageUrl: "https://t1.daumcdn.net/friends/prod/category/M001_friends_ryan2.jpg", | ||
| 43 | - altText: "hello I'm Ryan" | ||
| 44 | - } | ||
| 45 | - } | ||
| 46 | - ] | ||
| 47 | - } | ||
| 48 | - }; | ||
| 49 | 55 | ||
| 50 | - res.status(200).send(responseBody); | 56 | +app.listen(23023, function() { |
| 57 | + console.log('Example skill server listening on port 23023!'); | ||
| 51 | }); | 58 | }); |
| 59 | + | ||
| 52 | /* | 60 | /* |
| 53 | const fs = require('fs'); | 61 | const fs = require('fs'); |
| 54 | app.post('/champion',function(req,res){ | 62 | app.post('/champion',function(req,res){ |
| ... | @@ -63,26 +71,4 @@ app.post('/champion',function(req,res){ | ... | @@ -63,26 +71,4 @@ app.post('/champion',function(req,res){ |
| 63 | } | 71 | } |
| 64 | } | 72 | } |
| 65 | }) | 73 | }) |
| 66 | - | ||
| 67 | - | ||
| 68 | - | ||
| 69 | -app.get('/', function(req, res){ | ||
| 70 | - res.send('Hello, World!'); | ||
| 71 | -}) | ||
| 72 | - | ||
| 73 | -app.get('/test', function(req, res){ | ||
| 74 | - res.send('Hello, TEST!'); | ||
| 75 | -}) | ||
| 76 | -app.put('/oss', function(req, res){ | ||
| 77 | - res.send('Hello, OSS!'); | ||
| 78 | -}) | ||
| 79 | - | ||
| 80 | -app.get('/users/:userId/books/:bookId', function(req, res){ | ||
| 81 | - console.log(req.params.userId) | ||
| 82 | - console.log(req.params.bookId) | ||
| 83 | - res.send(req.params); | ||
| 84 | -}) | ||
| 85 | */ | 74 | */ |
| 86 | -app.listen(3000, function(){ | ||
| 87 | - console.log("Example skill server listening on port 3000!"); | ||
| 88 | -}); | ... | ... |
-
Please register or login to post a comment