Building a socket api with node js, express, websocket, mongoDB and firecamp: (User profile)
Okay let us get started by creating a middleware for our application. We dont want just anyone to create a profile unless authenticated.
- Create an auth.js file with and exported authenticate function which accepts a jwt token as a parameter.
- the function decodes the jwt and verify if user
Create a profile.action.js file and create all your actions in it and export them
Create a profileController.js file and import the actions and middleware modules
Now lets solder all the parts together in the server.js file. Import the profile controller
Next let us update our message with the exported modules in the profile controller.
Project link Github
After the next article on validation, there will be a code clean up and advance it.