For Week 8's Assignment, we are to create a simple REST API Server using Express.js, Typescript, and Node.js, and then deployed through Railway or Render or any other back-end deployment platform.
- Start the project by creating necessary folders:
mkdir controllers src data assets
- And or files with:
touch app.ts .gitignore
, etc. - Create a package.json file that will be used to describe your app:
npm init -y
- Install all the needed dependencies (general):
npm i dotenv body-parser express
- Install all the needed dependencies for development side (DevDependencies):
npm i -D @types/dotenv @types/express @types/nodes concurrently nodemon typescript
- Include necessary steps in your script, such as:
"dev": "concurrently \"npx tsc --watch\" \"nodemon dist/app.js\"
(this particular script will allows you to run 2 commands simultaneously.To run the command, use:npm run dev
)
roofinancetracker-prod.up.railway.app/
Name | HTTP Method | Endpoint |
---|---|---|
Homepage | GET |
/ |
List All Transaction Data | GET |
/transactions |
Get Transaction Data by ID | GET |
/transactions/:id |
Create New Transaction Data | POST |
/transactions |
Update Whole Transaction Data by ID | PUT |
/transactions/:id |
Update Transaction Type by ID | PATCH |
/transactions/ttype/:id |
Update Transaction Name by ID | PATCH |
/transactions/tname/:id |
Update Transaction Detail by ID | PATCH |
/transactions/tdetail/:id |
Update Transaction Amount by ID | PATCH |
/transactions/tamount/:id |
Delete Transaction Data by ID | DELETE |
/transactions/:id |
Through Postman or Thunder Client, we will be able to test our API's routing and codes to ensure functionalities.
Postman : an API platform for building and using APIs
- To download postman, head to postman.com
Although we don't have to create an account for Postman, creating one will allow us to access workspace, a sidebar space where we can create and store our API requests for easier and faster testing.
- An example of neat workspace
Thunder Client : a lightweight GUI based Rest API Client Extension for Visual Studio Code
An alternative to Postman, Thunder Client can be easily installed by going to `extensions` in VSCode.
Railway : a Platform as a Service (PaaS) that offers a complete platform for building and delivering programs to the backend of the cloud. Which means Railway is one of the many options where we can deploy our back-end codes.
- First, head to railway.app, and click login with github account.
-
Click New Project and the github repository that houses your backend sourcecode
-
Railway will proceed to start building and deploying your project, when completed, you may set the website name and or custom domain
-
Your project is ready for use.
[email protected] [Personal]
[email protected] [Work]