Score Tracking app for Apex Legends (Node + Vue)

الـauthentication بالـnodejs صداع كبير :woozy_face:
فقررت اعمل حاجة بعيدة عن الـauthentication :grinning:

https://fast-brushlands-67141.herokuapp.com/

ده تطبيق بيتابع score الـ gamers في لعبة Apex Legends

جربو بالبيانات التالية:

platform: PlayStation
gamertag: Daltoosh

وأيضا:

platform: origin
gamertag: sniperAdmin

إليكم اختبار الـperformance;


:smiley:

4 Likes

هذا اللاعب Daltoosh عامل منكر في البقية :joy:

عمل جميل جدا صديقي نصر. ماشاء الله :rose:

ممكن فقط توضح لنا ما فائدة nodeJs في عملك هنا ؟

2 Likes

كتيير :smiley:

// server.js
const express = require('express')
const morgan = require('morgan')
const dotenv = require('dotenv')

// load config
dotenv.config({ path: './config.env' })

const app = express()

// dev log (adding middleware)
if (process.env.NODE_ENV === 'development') {
  app.use(morgan('dev'))
}

// profile routes
app.use('/api/v2/profile', require('./routes/profile')) // I attached the code below

// handle prod
if (process.env.NODE_ENV === 'production'){
  // set static folder
  app.use(express.static(__dirname + '/public/'))

  //  handle SPA
  // this is to replace the localhost thing
  app.get(/.*/, (req, res) => res.sendFile(__dirname + '/public/index.html'))
}

const port = process.env.PORT || 8000

app.listen(port, () => {
  console.log(`app running in ${process.env.NODE_ENV} mode on port ${port}!`)
})

// profile.js
const express = require('express')
const router = express.Router()
const fetch = require('node-fetch')

// route
router.get('/:platform/:gamertag', async (req, res) => {
  // console.log(req.params.platform, req.params.gamertag)
  // res.send('Hello')
  try {
    const headers = {
      'TRN-Api-Key': process.env.TRACKER_API_KEY
    }
    const { platform, gamertag }  = req.params

      const response = await fetch(`${process.env.TRACKER_API_URL}/profile/${platform}/${gamertag}`, {
        headers
      })

    const data = await response.json()

    // check for errors and return our custom err
    if (data.errors && data.errors.length  > 0) {
      return res.status(404).json({
        message: 'profile not found'
      })
    }
    
    res.json(data)

  } catch (err) {
    console.error(err)
    res.status(5000).json({
      message: 'server error! '
    })
  }
})

module.exports = router
2 Likes

اها أوكي

لماذا لم تطلب ال API الخاص بال Tracker مباشرة من ال front ؟

2 Likes

انا عارف انو مش صح، بس حبيت اخليها مباشرة عشان نوعية التطبيق simple

const response = await axios.get(`/api/v2/profile/${this.$route.params.platform}/${this.$route.params.gamertag}`)


2 Likes

بغض النظر عن التقنيات الممتعة التي استعملتها، أرى أن التصميم تبع الموقع جميل جدا ومناسب جدا جدا لموقع ألعاب :grin:

image

1 Like

الحمد لله مفيش خضروات اترمت في وشي :smiley: :carrot::potato::eggplant::corn:
دايما بتشجعني يا ياسر :smiley:
شكرا شكرا

1 Like