Coder Social home page Coder Social logo

task-tracker's Introduction

TASK TRACKER

Technologies used:

  • Database : MongoDB

  • Backend: Node, Express

  • Frontend: React

  • Dependencies: dotenv, mongoose, nodemon, httpstatus

1 Install dependencies

Updating package.json via npm install with: `{ "name": "task-tracker", "version": "1.0.0", "description": "", "main": "app.js", "scripts": { "start": "nodemon app.js" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "dotenv": "^8.2.0", "express": "^4.17.1", "mongoose": "^5.11.10" }, "devDependencies": { "nodemon": "^2.0.7" } }`

2 Add .gitignore for /node_modules && .dotenv

3 Create GitHub repo for "task-tracker" and to project on local machine

4 Setup basic express server:

`const app = require("express")(); const port = process.env.PORT || 3000;

const start = async () => { try { // DB Connection app.listen(port, console.log(Server listening on port ${port})); } catch (error) { console.log(error); } }; start();` 5 Setup DB connection:

  • Create "db" Folder
  • Create file "connect.js" in "db" folder

`const mongoose = require("mongoose");

const connectDB = (url) => { return mongoose.connect(url, { useNewUrlParser: true, useCreateIndex: true, useFindAndModify: false, useUnifiedTopology: true, }); };

module.exports = connectDB;`

6 Connect server with DB in app.js using .dotenv dependency

  • Create .env file with MONGO_URI
  • Add await connectDB() to app.js
  • Pass MONGO_URI as process.env.MONGO_URI from .env to connectDB() in app.js

7 Test DB connection

  • Manually create dummy task in mongoDB: a) create DB called "TASK-TRACKER", b) create DB collection called "TASKS"

  • Create "models" folder with file "Task.js" that uses the mongoose Schema

  • Create dummy middleware

  • Create dummy controller

  • Create dummy route

  • Test via Postman

  • QUICKNOTE: The call to mongoose.model establishes the name of the collection the model is tied to, with the default being the pluralized, lower-cased model name. I.E. mongoose.model("TASK", Task) will be mongoose.model("tasks", Task)

8 Clean up the folder structure and improve separation of concerns

8.1 At least get the server running with improved folder structure and improved separation of concerns

8.2 Get the GET all tasks route working with improved folder structure and improved separation of concerns

9 Finish adding all routes

  • GET single task route
  • PATCH/update route
  • DELETE route

10 Set up error handling

task-tracker's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.