DEV Community

badruti94
badruti94

Posted on

Catatan Belajar dari kelas "Belajar Membuat Aplikasi BE untuk Pemula"

  • Untuk URL gunakan kata benda daripada kata kerja, serta jamak. Kemudian gunakan hirarki. Misal, /articles/:id/comments

  • Pisahkan dev dan prod dengan NODE_ENV=production node app.js

  • Gunakan ESlint agar code lebih rapih

npm i eslint -D
npx eslint --init

//kemudian taruh ini di property script pada package.json
"lint": "eslint ./"

npm run lint

//taruh ini di property rules pada .eslintrc.json agar tak ada warning pada console.log
"no-console": "off"
Enter fullscreen mode Exit fullscreen mode
  • Gunakan NVM agar lebih mudah dalam memilih versi node js

  • response dari API yaitu status, message (biasanya tidak digunakan pada method GET kecuali jika status fail), dan data (tergantung)


res.status(200).json({
    status: 'success',
    message: 'Artikel berhasil ditambahkan',
    data: {
        articleId: 1
    }
})

res.status(200).json({
    status: 'success',
    data: {
        articles: [{
            /*   */
        }]
    }
})
Enter fullscreen mode Exit fullscreen mode

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay