Create an Image and video sharing App using Nodejs

In This Tutorial We’ll create an application for uploading photographs and videos with user authentication utilizing MongoDB and Mongoose; then we will see the pictures that are going to be the top results of our work.

Preview of our App

Inserting images in the application using the upload form

Inserting video files into the application using the upload form

Lets start with the package.json file. The packages.json is main file  of the application.

  1. Create a folder called dunebookapp
  2. Create a new file called package.json and save it in the dunebookapp folder with the following code:
          { 
            "name": "dunebookapp", 
            "description": "multimedia App with Node.js", 
            "license": "MIT", 
            "author": { 
              "name": "dunebook Tutorial", 
              "url": "https://github.com/yourlinkhere" 
           }, 
            "repository": { 
              "type": "git", 
              "url": "https://github.com/yourlinkhere" 
            }, 
            "keywords": [ 
              "MVC", 
              "Express Application", 
              "Expressjs", 
              "Expressjs images upload", 
              "Expressjs video upload" 
            ], 
            "version": "0.0.1", 
            "private": true, 
            "scripts": { 
              "start": "node app.js" 
            }, 
             "dependencies": { 
              "bcrypt-nodejs": "0.0.3", 
              "body-parser": "~1.13.2", 
              "connect-flash": "^0.1.1", 
              "connect-mongo": "^1.1.0", 
              "cookie-parser": "~1.3.5", 
              "debug": "~2.2.0", 
              "ejs": "~2.3.3", 
               "express": "~4.13.1", 
              "express-session": "^1.13.0", 
              "gravatar": "^1.4.0", 
              "mongoose": "^4.4.5", 
              "morgan": "~1.6.1", 
              "multer": "^1.1.0", 
              "node-sass-middleware": "0.8.0", 
              "passport": "^0.3.2", 
              "passport-local": "^1.0.0", 
              "serve-favicon": "~2.3.0" 
            }, 
            "devDependencies": { 
              "nodemon": "^1.9.1" 
            } 
          }

 

Recommended :  Laravel And PHP

Now let’s Add some of useful files to our project:

  1. Create a file called .editorconfig and save it in the dunebookapp folder with the following code:
          # http://editorconfig.org 
          root = true 
     
          [*] 
          indent_style = tab 
          indent_size = 4 
          charset = utf-8 
          trim_trailing_whitespace = true 
          insert_final_newline = true 
     
          [*.md] 
          trim_trailing_whitespace = false 
    
  2. Create a file called .gitignore, save it in dunebookapp , and include the following code:
          # Logs 
          logs 
          *.log 
     
          # Runtime data 
          pids 
          *.pid 
          *.seed 
      
          # Directory for instrumented libs generated by jscoverage/JSCover 
          lib-cov 
     
          # Coverage directory used by tools like newyork 
              coverage 
     
          # Grunt intermediate 
          storage (http://gruntjs.com/creating-plugins#storing-task-files) 
          .grunt 
     
          # node-waf configuration 
          .lock-wscript 
     
          # Compiled binary addons (http://nodejs.org/api/addons.html) 
          build/Release 
     
          # Dependency directory 
          # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-
          my-node_modules-folder-into-git- 
          node_modules 
     
          # Debug log from npm 
          npm-debug.log 
    
  3. Create a file called app.js.

Add essential server folders

We will now create the directories that store controls, the templates, and other files of the application:

  1. Create a folder called public, and inside of it, create the following folders:
    • /images
    • /javascripts
    • /stylesheets
    • /uploads
    • / videos
  2. Create a folder called server, and inside of it, create these folders:
    • /config
    • /controllers
    • /models
    • /views
  3. At this time, our project has all the basic directories and files; let’s install the Node modules from package.json.
  4. Open your terminal/shell at the root project folder and type the following command:
    npm install
    

    Let’s starting creating the app.js file content.



Pin It on Pinterest

Shares
Scroll Up

Get the best in web dev

Join dunebook.com and recieve best in web dev , once a week FREE

An email has been Sent to your Inbox ! Please Confirm your Subscription :)