- RESTful Factorio API with full CRUD (Create, Read, Update, Delete) functionality for interacting with factorio game data.
- This project allowed me to learn how APIs work, how to set up routes and endpoints and interact with sql databases programmatically using HTTP methods.
- Full Create, Read, Update, Destroy (CRUD) functionality.
- Interacts with a SQL database which stores game data.
- Each entry has an incremented id.
- deprecate the
requesttypecolumn since all requests adding data will be POST requests. - integrate api keys.
- Normalize data by making each column its own table to avoid
NULLvalues in all other columns when adding to a column.
- Node.js
- Express.js
- SQL AND MySql Workbench
- Babel-node
- Morgan
- Dotenv
- MySql2
- Git Bash
- VS Code
- GitHub
- POSTMAN
- Base URL:
http://localhost:3001/api/ - items, fluids, enemies and terrains are the columns that stores the entries.
- Each column already has a dummy entry.
- Currently only 1 entry can be added or updated at a time.
A GET request sent to the url retrieves and logs all entries.
[
{
"items": "test_item",
"fluids": null,
"enemies": null,
"terrains": null,
"requesttype": "POST",
"id": 1
},
{
"items": null,
"fluids": "test_fluid",
"enemies": null,
"terrains": null,
"requesttype": "POST",
"id": 2
},
{
"items": null,
"fluids": null,
"enemies": "test_enemy",
"terrains": null,
"requesttype": "POST",
"id": 3
},
{
"items": null,
"fluids": null,
"enemies": null,
"terrains": "test_terrain",
"requesttype": "POST",
"id": 4
}
]Each entry will the fields: items, fluids, enemies, terrains, requesttype and id. Fields irrelevant to a specific entry will return null.
A GET request sent to http://localhost:3001/api/id retrieves and logs that particular entry. GET http://localhost:3001/api/4 logs:
{
"items": null,
"fluids": null,
"enemies": null,
"terrains": "test_terrain",
"requesttype": "POST",
"id": 4
}
]A POST request sent to the url with the response body containing a column and value will insert to the database like below:
"terrains": "test_terrain"
}A PUT request sent to http://localhost:3001/api/id with the response body containg the new column/value pair.
"terrains": "test_desert_terrain"
}
updated from:
"terrains": "test_terrain"
}
A DELETE request sent to http://localhost:3001/api/id deletes the entry from the database.
Video demonstration at Google Drive