The backend side will manage product
, with REST over HTTP API request:
- Create Web Server App using
Express.js
orHapi
to handle product data✅ - Backend side should use SQL database engine such:
Postgres/SQL Server/MySQL
wrapped with ORM✅ - For ORM library, please use
Sequelize/Knex
formigration
,seeding
, anddata processing
(CRUD). Prevent using sql script directly!✅ - Create
migration
for product schema with fields: ✅- id:
BIGINT
- name:
VARCHAR
- qty:
INT
- picture:
TEXT
with Base64 value - expiredAt:
DATE
YYYY-MM-DD - isActive:
BOOLEAN
- id:
- Don't forget to
seed
it with some initial data.✅ - HTTP response and request body payload should formated in JSON format✅
- Describe your endpoint as a REST, this is available endpoints for manage product:
- Add product:
/POST
/product
✅ - Get products:
/GET
/product
✅ - Get product by id:
/GET
/product/:id
✅ - Remove product by id:
/DELETE
/product/:id
✅ - Update product by id:
/PUT
/product/:id
✅
- Add product:
- With REST specification:
- For getting product should returned with
true
value inisActive
field✅ - Filtering product by specific criteria, sorter and pagination product is optional.✅
- While deleting product, we use "soft delete" with set
isActive
field tofalse
✅ - Post a product always set
isActive
value totrue
✅ - Updating product should block
isActive
value from body payloads✅
- For getting product should returned with
- Endpoint of logging activity, unit testing, and
Swagger
API docs are optional✅ - Write clean and effective code for example: proper project structure, exception handling, parameterize config, etc.✅
- Push your work to your GitHub repository, make sure your repository accessible to public.✅
Install semua dependencies yang dibutuhkan menggunakan npm
atau bisa juga dengan menggunakan yarn
:
npm install or yarn install
Salin .env.example
menjadi .env
lalu gunakan konfigurasi disini
NODE_ENV = development
PORT = 4002
Membuat database dan tabel dalam mode development
:
npm run db:start
Membuat database dan tabel dalam mode testing
:
npm run db:test:start
Menjalankan test :
npm run test
Jalankan servernya, bisa dengan menggunakan npm
atau yarn
:
npm run start or yarn start
Dokumtasi dan sample ada disini:
URL
: Documentation