npm install
npx sequelize db:create
npx sequelize db:migrate
npx sequelize db:seed:all
POST /users/register
Pada tab Body pilih x-www-form-url-encoded di Postman, Masukkan key email, username, dan password lalu isi valuenya.
POST /users/login
Pada tab Body pilih x-www-form-url-encoded di Postman, Masukkan key email,dan password lalu isi valuenya sesuai dengan data yg sudah di regist, maka akan ter-generate token pada respon.
Unruk mengakses Photo perlu login terlebih dahulu. Caranya Letakkan token yang didapat saat login. Pada tab Headers di tiap endpoint photos pada Postman, lalu pada key nya ketik token dan isi value dengan tokennya.
Mengambil seluruh data photos
GET /photos
Mengambil data photos berdasarkan id
GET /photos/:id
Membuat data photos
Pada tab Body pilih x-www-form-url-encoded di Postman, Masukkan key title, caption, dan image_url lalu isi valuenya.
POST /photos
Untuk menjalankan PUT dan DELETE akan diterapkan ketika UserId dan id yang sedang login sama. Pada tab Body pilih x-www-form-url-encoded di Postman, Masukkan key title, caption, dan image_url lalu ubah valuenya
PUT /photos/:id
Delete Photos berdasarkan id
Data akan terhapus sesuai dengan id yang dikirimkan dan sesuai dengan userId yang sedang login, jika tidak maka tidak bisa dihapus.
DELETE /photos/:id
Berikut langkah-langkahnya:
npm run db:create:test
npm run db:migrate:test
npm run test