Pattern yang digunakan: Middleware. Karena aplikasi express adalah susunan fungsi middleware.
To run my app, simply copy and paste these commands in your terminal:
git clone https://github.com/NurAlif/alif_app_express.git
cd alif_app_express
npm install
npm start
Now, you can go to http://localhost:3000/api-docs to test the API. You can use Postman instead of Swagger. The API run on http://localhost:3000
Note: You don't have to setup a database. The database is stored in database.sqlite
OpenAPI Doc: apidoc.json
-
Run the app on terminal
-
You need a user. You can either create a new one or login with registered user. If you want to create a new user select Create user endpoint.
Or, you can use this account to login:
{ id: 1, password: alif1234 }
-
Press try out to test the endpoint
-
Press execute to send a GET request. Then, the response will appear:
The response of create user endpoint is a token. Copy the token, and paste it in Authorize. This will make every endpoint that needs bearer token will be filled with this token. Otherwise the server will return code 403.
If you want to log out, you can press log out inside Authorize modal. Without a bearer token, the response would look like this:
-
Now we can send a request with any endpoint. This is a request to get a poster url of Rambo:
Try with any movie title you remember!
-
Add your favorite movies
Add as many as you want!
-
Read all your favorite movies
If you run into a problem feel free to contact me