The purpose of this project was to create a simple API with basic CRUD (Create, Read, Update, Delete) operations using only native modules from Node, such as fs
to write and read files and http
to create the server and handle requests. No database was used, all the records are stored in a single .txt file that is single handed by Node file system module.
- NodeJS v.20 or higher
If you use NVM, just run nvm use
inside of the root folder.
Since the project was made using only native modules, there's no need to run npm i
ou yarn
, just clone this repository and you're good to go.
$ npm start # Project will start at http://localhost:8001/
route | HTTP method | params | description |
---|---|---|---|
/ |
GET | - | Home page |
/movies |
GET | - | List Movies |
/movies |
POST | - | Create Movie |
/movies/:id |
GET | :id |
Find Movie |
/movies/:id |
UPDATE | :id |
Update Movie |
/movies/:id |
DELETE | :id |
Delete Movie |
POST /movies
Request body:
{
"title": "Legally Blonde",
"year": 2001,
"genre": "comedy",
"duration": 96,
"ageRating": 13,
"director": "Robert Luketic"
}
PUT /movies/:id
Request body:
{
"title": "Legally Blonde",
"year": 2001,
"genre": "comedy",
"duration": 96,
"ageRating": 13,
"director": "Robert Luketic"
}