Giter VIP home page Giter VIP logo

movies-explorer-api's Introduction

Movies Explorer - Backend

This repository contains the backend code for the project Movies Explorer. The project is a web application developed using React.

Description

This repository contains the backend code for a website built using Node.js, MongoDB, and Express.js. The backend provides the necessary APIs and functionality to interact with the database and handle various operations required by the website. It implements features such as registration, login, profile editing, and managing saved movies.

Frontend

Check out the frontend of this project made with React.js.

Features

  • Secure HTTP-only Cookies: The backend uses secure HTTP-only cookies for session management and authentication, ensuring that user data is securely stored and transmitted.
  • Error Handling: The code includes robust error handling mechanisms to handle and manage various types of errors that may occur during the execution of the application.
  • Winston: The backend utilizes Winston, a versatile logging library for Node.js, to write logs. This helps in monitoring and troubleshooting the application's behavior.
  • Joi: Data validation is performed using Joi, a powerful schema description language and data validator for JavaScript. It ensures that the data received by the backend conforms to the specified rules.
  • User Authentication and Authorization: Implemented an authentication system using JSON Web Tokens (JWT). This allows users to securely register, log in, and access protected resources based on their roles and permissions.
  • Password Encryption: Enhanced security by encrypting user passwords using a hashing algorithm like bcrypt. This ensures that sensitive user information is not stored in plain text and helps protect against unauthorized access.
  • Rate Limiting: The backend is protected from abuse or malicious activities by implementing rate limiting mechanisms. These help prevent excessive requests from a single client or IP address, ensuring fair usage and protecting server resources.

Installation

Clone the repository:

git clone https://github.com/bellabzhu/movies-explorer-api

Install dependencies:

npm install

Run the project:

npm start

The server should now be running on http://localhost:3000, ready to handle API requests.

movies-explorer-api's People

Contributors

bellabzhu avatar

Watchers

 avatar

movies-explorer-api's Issues

Создать 5 контроллеров для роутов

Для этих роутов:

# возвращает информацию о пользователе (email и имя)
GET /users/me

# обновляет информацию о пользователе (email и имя)
PATCH /users/me

# возвращает все сохранённые текущим  пользователем фильмы
GET /movies

# создаёт фильм с переданными в теле
# country, director, duration, year, description, image, trailer, nameRU, nameEN и thumbnail, movieId 
POST /movies

# удаляет сохранённый фильм по id
DELETE /movies/_id 

Создать на сервере .env файл.

Добавьте в этот файл переменные окружения:

NODE_ENV=production;
JWT_SECRET с секретным ключом для создания и верификации JWT.

.env файл должен храниться только на сервере. В репозитории хранить переменные окружения нельзя — это небезопасно.
В режиме разработки код должен запускаться и работать без этого файла. Задайте условие, чтобы dev-сборка запускалась, когда process.env.NODE_ENV !== 'production'.

Подготовка бэкэнда

  • создать ветку level-1
  • Добавьте все необходимые инфраструктурные файлы: .gitignore, .editorconfig, .eslintrc. Можете взять эти файлы из проекта Mesto.
  • Инициализируйте package.json
  • Поля name и author заполните на своё усмотрение.
  • Заполните раздел scripts. В нём должны быть команды dev и start. dev запускает проект в режиме разработки с хот-релоадом, а start — в продакшн-режиме без хот-релоада.

Создать роуты

# возвращает информацию о пользователе (email и имя)
GET /users/me

# обновляет информацию о пользователе (email и имя)
PATCH /users/me

# возвращает все сохранённые текущим  пользователем фильмы
GET /movies

# создаёт фильм с переданными в теле
# country, director, duration, year, description, image, trailer, nameRU, nameEN и thumbnail, movieId 
POST /movies

# удаляет сохранённый фильм по id
DELETE /movies/_id

# создаёт пользователя с переданными в теле
# email, password и name
POST /signup

# проверяет переданные в теле почту и пароль
# и возвращает JWT
POST /signin

# для логауте если в куках авторизация
POST /signout

Сделать логирование

Настройте два файла для хранения логов:

  • request.log, чтобы хранить информацию о всех запросах к API;

  • error.log, чтобы хранить информацию об ошибках, которые возвращает API.

Логи должны быть в формате JSON. Файлы логов не должны добавляться в репозиторий.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.