From the course: TypeScript for Node.js Developers

Template a Node.js and Express project

From the course: TypeScript for Node.js Developers

Start my 1-month free trial

Template a Node.js and Express project

- [Instructor] For this course, I've prepared for you a template node.js project. That was built in another course of mine. So feel free to use any of your own node.js projects and convert it as well, or you can leverage mine. So the first thing we'll do is leverage mLab for the MongoDB. So instead of installing MongoDB locally on your system, we'll leverage mLab, and there's a free version of mLab that you can use. So go to mLab.com first, and register for an account, and once you have done this, and you're logged in and you see this screen here, create new. So click on the button here, that says create new, and then select a sandbox, click continue. And then select a region that is closest to you so in this case we'll select the US East, and then click continue. And then simply name the database, so in this case I'm going to name it LinkedIn APIs, and then submit order. And while the database is actually setting up, what we'll do is go to our desktop and create a new folder, and name this folder, so for example, type script underscore node. And then we'll go in the exercise files to grab the template project from the resources, so click on resources, and make sure that you see the dot babel RC file. If you don't see this file, that means that your system is not showing the hidden files. If it isn't, then go on the web to search for how to show hidden files in your system, and then once you see this, then you can copy the entire directory, and then place it in the new folder we just created. So command V on Mac. So once you see this, let's go ahead and drop that into VS code. And then before we actually install all the dependencies, we'll go into the index.js and then change the code here where you see mongoose dot connect to the actual reference to your account. So in my case I already have my credentials here, so this is all good. And then once you have your credentials, so basically, what you need to do is change here, for your user of your database, and then the password of the database, and then the actual database. And you can find all that information in the actual link of the website. Let's go back to mLab, and then click on the newly created database, in this case LinkedIn APIs, click on this. And you will get all those details right here. Make sure that you create a database user and a database password, and you can create this in the user section here. So in this case I don't have any, but I'm going to use the other one that I actually created for this course. So this is just to give you an example of how to create a database in mLab, and then create a user that you will insert in here. So once you copy this particular link, and you have your users, you can basically paste that information in the link here, or the code here. So mongoose dot connect, and then enter the credentials right here. Once you have all this done, you need to install all the dependencies. So we're going to click on view, click on terminal, and then do NPM install to install all the dependencies. And our project will be good to go.

Contents