A base project to implement a RESTful API using Node.js and Express server and Mongoose. Endpoints are accessible and public, no key or authorization is required. The published version is v1.
Clone this repository by git and enter it:
git clone https://github.com/michelecerruto/nodejs-code-challenge.git
cd nodejs-code-challenge
npm install- Run
npm run startornpm run devto use nodemon - Open
http://localhost:3030/v1/to test the endpoint
Using mongodb-memory-server to create a db in memory. To load the data into the db you can use the endpoint /v1/setup or you can create it through the endpoint with post method
Add the versioning /v1 to use the following endpoint
| Path | Method | Description | Params |
|---|---|---|---|
| /v1/ | GET | getAllFilms | |
| /v1/:id | GET | getOneFilm | Film._id |
| /v1/ | POST | createOneFilm | |
| /v1/update/:id | PATCH | updateOneFilm | Film._id |
| /v1/delete/:id | DELETE | deleteOneFilm | Film._id |
| /v1/setup | POST | loadData DB |
{
"title": "",
"original-title": "", (optional)
"production-year": 0, (optional)
"genre": "", (optional)
}{
"title": {
"type": "String",
"required": [true, "A film must have a title"],
},
"original-title": {
"type": "String",
"required": false,
},
"production-year": {
"type": "Number",
"required": false,
},
"genre": {
"type": "String",
"required": false,
},
},
{ "timestamps": { "createdAt": "created_at", "updatedAt": "updated_at" } },
This project is available under the MIT license