Skip to content

rafhaini/local-library-turma-alpha

 
 

Repository files navigation

local-library

Creating the local project

Create the project

Create a project using Express Generator

express express-locallibrary-tutorial --view=pug

Install all dependencies

cd express-locallibrary-tutorial
npm install

Enable server restart on file changes

Install nodemon

npm install --save-dev nodemon

Enable the application to use nodemon

Change your scripts section to be as follows:

"scripts": {
  "start": "node ./bin/www",
  "devstart": "nodemon ./bin/www",
  "serverstart": "DEBUG=express-locallibrary-tutorial:* npm run devstart"
},

Run the app

npm run devstart

Setting up the database

Install Mongoose and MongoDB

npm install mongoose

We'll be using MongoDB Atlas cloud-based database as a service free tier to provide the database. Go to the MongoDB Atlas page and create a free cluster.

Go to the Collections tab and create a new database named local_library and enter the name of the collection as Collection0. Set the connection to Allow Access from Anywhere.

Install async dependency

The async dependency is used by the script that generates some random data.

npm install async

Run the script do populate the database

Download the populatedb.js file in the root of your directory and run:

node populatedb <your mongodb url>

You can also use Mockaroo to generate some mock data. Some are available in the data/ folder. For that, you'll need to install async:

npm install async

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 77.3%
  • Pug 22.6%
  • CSS 0.1%