Git Product home page Git Product logo

week-8-sanhendrindp's Introduction

Banner

Link Project

newfinance-tracker.fly.dev

Project Description

In week 7, a Financial Tracking app was already created. Now in week 8, we are trying to build a simple REST API server based on the Financial Tracking, so user can perform basic CRUD operations on the provided data.

Preparation

To create this project, we want to install depedencies that we need for this project. First, we need to create Node.js project by using npm init in terminal. After that, install the dependecies, such as :

  1. express.js and dotenv package:
npm i express dotenv
  1. Install Typescript, @types/express, and @types/node package:
npm i -D typescript @types/express @types/node
  1. Install nodemon as devDependencies:
npm i -D nodemon
  1. Install concurrently as devDependencies:
npm i -D concurrently
  1. Install body-parser:
npm i body-parser
  1. Install @types/body-parser as devDependencies:
npm i -D @types/body-parser
  1. Update the script in package.json:

After all dependencies already installed to the project, generating tsconfig.json using npx tsc --init , then change outDir in tsconfig.json as: "outDir": "./dist"

Deploy the REST API server with fly.io

After the REST API server already build, it's time to deploy it with fly.io. To use fly.io, we need to install it to our PC before we can use it.

  1. Run the PowerShell, then use this command to install flyctl:
pwsh -Command "iwr https://fly.io/install.ps1 -useb | iex"
  1. Sign in / Sign up to fly.io.
  2. We need to authorize our login with PowerShell, so use this command:
flyctl auth login
  1. Change the PowerShell directory to the project directory.
  2. Launch the app using this command:
flyctl launch
  1. Here, we can enter the name of the app and then select a region to deploy in.

  1. Finally, flyctl will ask you if you would like to deploy. Use this command:
flyctl deploy
  1. After deploy is success, we can use command flyctl status to show the app basic detail.

  1. App successfully deployed.

Install Postman & test the APIs

To test the APIs, we need to install Postman so we can perform basic CRUD (Create, Read, Update, Delete) operations. The financial tracking API that has been created has endpoints with the following HTTP methods:

  1. GET/expenses : Get all expenses data.
  2. GET/expenses/:id : Get expense data by using ID.
  3. POST/expenses : Create new expense data.
  4. PUT/expenses/:id : Updates an existing data with the given ID.
  5. PATCH/expenses/:id : Partially update an existing data with the given ID.
  6. DELETE/expenses/:id : Delete an existing data with the given ID.


Postman with GET http request


Thank you ๐Ÿ™

week-8-sanhendrindp's People

Contributors

sanhendrindp avatar github-classroom[bot] avatar

Watchers

Alvian Zachry Faturrahman avatar

Forkers

sanhendrindp

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.