The first insert call from our Node.js code will trigger its creation automatically. Note: With MongoDB, there’s no need to create a specific database like there might be in some RDBMS scenarios. That’s because, at one point in this tutorial, we’ll need to interact with MongoDB directly rather than via our Node.js code. We won’t explain the specifics of Mongoose and MongoDB that are used here, but to get the basics running, simply start the server in interactive mode (i.e., from the command line as mongo) rather than as a service. Next, make sure that you have MongoDB installed. For this article, I’ll be using version 14.9.0 it may also work on older versions. (Dejan Milosevic’s great article on JWT for secure REST applications in Java goes into further detail about this the principles are the same.) Node.js REST API Tutorial Setupįirst, make sure that you have the latest Node.js version installed. To that end, we will create another resource called auth that will expect a user’s email and password and, in return, will generate the token used for authentication on certain operations. We will also be using JSON web tokens (JWTs) for access tokens.
0 Comments
Leave a Reply. |