Code Monkey home page Code Monkey logo

attendance-system's People

Contributors

jrichardsz avatar lexyblazy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

attendance-system's Issues

change code in app.js for running success

const express = require("express");
const app = express();
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const session = require("express-session");
const flash = require("connect-flash");
const moment = require("moment");

const seedDB = require("./seed");
const removeUsers = require("./remove");
const routes = require("./routes/index");
// const generatePDF = require('./generatePdf');
require('dotenv').config({path:'variables.env'});

mongoose.Promise = global.Promise; //tell mongoose to use ES6 promises
mongoose.connect('mongodb://localhost:27017/', err => { // <- here 
  if (err) {
    console.log("Cannot connect to database");
    console.log(err);
  } else {
    console.log("Connection to database was succesful");
  }
});

const User = require("./models/user");

app.set("view engine", "ejs");
app.set("views", `${__dirname}/views`);
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(express.static(`${__dirname}/public`));

app.use(
  session({
    secret: process.env.SECRET,
    resave: false,
    saveUninitialized: false
  })
);
app.use(flash());
app.use((req, res, next) => {
  res.locals.error = req.flash("error");
  res.locals.success = req.flash("success");
  res.locals.moment = moment;
  next();
});

//ROUTES
app.use(routes);
// removeUsers();
// seedDB();

app.listen("3000", () => { // <- here
  console.log("Server is up and running");
  
});

ref:
[app.js]
https://gist.github.com/goish135/4fc38a7732c8a8747fb26daddd25a06a

[line 16](https://gist.github.com/goish135/4fc38a7732c8a8747fb26daddd25a06a#:~:text=use%20ES6%20promises-,mongoose,-.connect(%27mongodb%3A//localhost)

[line 53](https://gist.github.com/goish135/4fc38a7732c8a8747fb26daddd25a06a#:~:text=//%20seedDB()%3B-,app,-.listen(%223000%22%2C%20()%20%3D%3E%20%7B)

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.