This is an example of a RESTful API that queries some movies from themoviedb.org and lets you register and select your favourites movies. It is written with:
- Node.js
- Typescript.js
- Express.js
It also uses:
- SQLite3
- Prisma
- express-validator
- mocha & chai & supertest
npm install
npx ts-node src
Default port: 7000 (.env file)
npm test
The REST API is described below. Only "Create user" and "Login" services are public. For the rest you must add an Authorization header "Bearer token" in order to call them. You can also import the Postman project "postman_movies.json" from the root folder to test the API.
POST /user
{
email: "[email protected]",
firstName= "first name",
lastName= "last name",
password="password1"
}
HTTP/1.1 200 OK
{ id:1, email: "[email protected]", firstName= "first name", lastName= "last name". password="password1" }
POST /session
{ email: "[email protected]", password="password1" }
HTTP/1.1 200 OK
{ token:"tokendata...", user: userData }
DELETE /session
Authorization: Bearer token....
HTTP/1.1 200 OK
GET /movie?keyWord=keyWord1
Authorization: Bearer token....
Returns list of movies
HTTP/1.1 200 OK
[ { "id": 635302, "adult": false, "original_language": "ja" ... .. }, { ... } ]
GET user/userId1/movie/movieId1
Authorization: Bearer token....
HTTP/1.1 200 OK
GET user/userId1/movie
Authorization: Bearer token....
HTTP/1.1 200 OK
Returns list of favourites movies of the user
HTTP/1.1 200 OK
[ { "id": 635302, "adult": false, "original_language": "ja" ... .. }, { ... } ]