Skip to content

cplan85/Sprint9-Backend

Repository files navigation

Authentication-MEAN

This project was generated with Node, Nodemon, Express, and MongoDB for the backend.

Built With

Angular is used for the front-end UI Components. Node and Express comprise the backend, and the database is served with MongoDB. Other packages include bcrypt.js, cors, jsonwebtoken, express-validator, and mongoose.

  • MongoDB
  • Express.JS
  • Angular
  • Node.JS

Tools Used:

  • Postman

(back to top)

🎓 What did I learn from this project

In this project I learned how to create Rest API back-end server that validates users using JWT web tokens. The back-end uses a MVC design pattern, and I learned to implement middlewares in the main index.js.

In addition to operations dealing with Users, I included CRUD operations for Events, which are handlded through the interfaces in the front end. Each User is defined with an array of Events, for which they may be able add, update, delete, or get events.


📜 Endpoints

USERS:

  • POST Login -> localhost:4000/api/auth
  • POST Register -> localhost:4000/api/auth/new
  • GET RenewToken-> localhost:4000/api/auth/renew

EVENTS:

  • GET All Events -> localhost:4000/api/events
  • GET All Events by User's Email -> localhost:4000/api/events/user-events
  • POST Add Event -> localhost:4000/api/events/add
  • POST Delete Event -> localhost:4000/api/events/delete
  • POST Update Event -> localhost:4000/api/events/update

*MAPS:

  • GET All Maps -> localhost:4000/api/maps
  • GET All Maps by User's Email -> localhost:4000/api/maps/user-maps
  • POST Add Map -> localhost:4000/api/maps/add
  • POST Delete Map -> localhost:4000/api/maps/delete

How to Run Back-End Server

Clone the repo, then

node index.js

Or with nodemon (recommended)

nodemon

You will need bcryptsjs, cors, dotenv, express, express-validator,jsonwebtoken, and mongoose. Official installation guide: https://docs.mongodb.com/manual/installation/. Then:

npm i bcryptjs cors dotenv express express-validator jsonwebtoken mongoose

Development server for Angular Front-end

Run ng serve for a dev server. Navigate to http://localhost:4200/. The application will automatically reload if you change any of the source files.

Code scaffolding

Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.

Build

Run ng build to build the project. The build artifacts will be stored in the dist/ directory.

Running unit tests

Run ng test to execute the unit tests via Karma.

Running end-to-end tests

Run ng e2e to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI Overview and Command Reference page.

About

Backend Server for Sprint 9 Event App

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published