Around the U.S. - Back End is a project to create a Node.js server with REST API endpoints to serve all the data requests of the Around the U.S. - Frontend React Project.
The technologies that have been used are:
- Node.js
- Express Framework (for development)
- Postman (for testing API endpoints)
- EsLint
- MongoDB
- Node (or more formally Node.js) is an open-source, cross-platform runtime environment that allows developers to create all kinds of server-side tools and applications in JavaScript.
- Node. js is primarily used for non-blocking, event-driven servers, due to its single-threaded nature.
- It's used for traditional web sites and back-end API services.
- Express is the most popular Node web framework, and is the underlying library for a number of other popular Node web frameworks.
- It provides mechanisms to:
- Write handlers for requests with different HTTP verbs at different URL paths (routes).
- Integrate with "view" rendering engines in order to generate responses by inserting data into templates.
- Set common web application settings like the port to use for connecting, and the location of templates that are used for rendering the response.
- Add additional request processing "middleware" at any point within the request handling pipeline.
- Postman is an API client that makes it easy for developers to create, share, test and document APIs.
- This is done by allowing users to create and save simple and complex HTTP/s requests, as well as read their responses.
- ESLint is an open-source Javascript linting utility used to find problematic patterns or code that doesn’t adhere to certain style guidelines.
- We are using Airbnb JavaScript Style Guide.
- MongoDB is a document database with the scalability and flexibility that the customer wants with the querying and indexing that the customer needs.
- MongoDB stores data in flexible, JSON-like documents.
- The document model maps to the objects in the application code, making data easy to work with.
- MongoDB is a distributed database at its core, so high availability, horizontal scaling, and geographic distribution are built in and easy to use.
- MongoDB is free to use.
The project has the following directory structure:
Directory | Purpose |
---|---|
/models |
Contains all MongoDB schemas and models - all data layers. |
/routes |
Contains routing files. |
/controllers |
Contains all the route handler callbacks. |
/utils |
Contains all the helper methods for general purpose tasks. |
HTTP Methods | REST API Endpoint | Purpose |
---|---|---|
GET |
/users |
Get JSON list of all the users |
GET |
/users/:userId |
Get a specific user profile with an ID |
POST |
/users |
Create a specific user profile |
PATCH |
/users/me |
Update the current user profile |
PATCH |
/users/me/avatar |
Update the current user avatar |
GET |
/cards |
Get JSON list of all the cards |
POST |
/cards |
Create a new card |
DELETE |
/cards/:cardId |
Delete a card by the given ID |
PUT |
/cards/:cardId/likes |
Update a card by liking it |
DELETE |
/cards/:cardId/likes |
Delete a like on the card |
Command | Purpose |
---|---|
npm run start |
To launch the server |
npm run dev |
To launch the server with the hot reload feature |