Skip to content

CadenetVincent/NodeFinal

Repository files navigation

Node Final

ECE Project : DevObs & Nodejs 2019 December

Get more details at codescene.io.

Badges

Build Status

Coverage Status

Build Status

Build Status

Known Vulnerabilities

Last Version

Size

docker-compose

Resume / Introduction

What we use ?

  • Language : NodeJS, EJS, express, Typescript, MongoDB (NoSQL), Linux,...
  • Database : MongoDB Atlas.
  • CI/CD : Travis-CI, Coveralls.
  • Unit Test : Mocha/Chai, Nodejs.
  • Code verification : Code-inspector,snyk.io.
  • Deployment : Docker, Docker-compose, Heroku (production).

See more about ...

Realisations URL
Heroku deployment : https://finalnodecadenet.herokuapp.com/
Code inspector : https://www.code-inspector.com/public/project/2264/NodeFinal/dashboard
Coverage Status : https://coveralls.io/github/CadenetVincent/NodeFinal?branch=master
Build Status : https://travis-ci.com/CadenetVincent/NodeFinal
Vulnerabilities : https://snyk.io/test/github/CadenetVincent/NodeFinal

Prerequisites

The project is running on Ubuntu 18.04.3 LTS (Linux).

The version of node used is : v12.13.0.

The version of npm used is : v6.12.1.

The version of :

  • Docker-compose version 1.18.0, build 8dd22a9
  • Docker version 19.03.5, build 633a0ea838
  • Heroku-CLI heroku/7.35.0 linux-x64 node-v12.13.

Dependencies, DevDependencies are accessible in the package.json.

Public file folder :

Bootstrap v4.3.1 (https://getbootstrap.com/)

jQuery v3.4.1 | (c) JS Foundation and other contributors | jquery.org/license

Chart.js v2.9.3 | https://www.chartjs.org | (c) 2019 Chart.js Contributors | Released under the MIT License

Install & build the application

Our public git :

https://github.com/CadenetVincent/NodeFinal

Install the application :

$ git clone https://github.com/CadenetVincent/NodeFinal
$ cd NodeFinal
$ npm install

Run & build Unit Test / populate in the application :

Build & start unit test with Nodejs, MongoDB Atlas, Mocha/Chai, Travis-CI and Coveralls :

Docker-compose :

$ sudo docker-compose up --build

Npm test :

$ npm run test

Npm populate the DATABASE :

$ npm run populate 

Run & build the Node Application :

Npm start (with Node / Nodejs):

$ npm run start

Npm start (with ts-node / Typescript):

$ npm run start_ts

Npm start (with nodemon / Nodejs):

$ npm run start_js

Dev start :

$ npm run dev 

Build with Typescript :

$ npm run build_app

Heroku deployment :

https://finalnodecadenet.herokuapp.com/

Contributors

See More about contributors

license & copyright

Vincent Cadenet and Fritel Ludovic, ECE Paris

Licensed under the MIT License

server.ts (main of the project)

const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
const path = require('path');
var session = require('express-session');
var MongoStore = require('connect-mongo')(session);

const authRoute = require('./route/auth.route');
const userRoute = require('./route/user.route');
const schoolRoute = require('./route/school.route');

var port =  process.env.PORT || 3000;

mongoose.Promise = global.Promise;
mongoose.connect("mongodb+srv://User:[email protected]/ececadenetfritel", { useNewUrlParser: true }).then(
  () => {console.log('Database is connected') },
  (err:any) => { console.log('Can not connect to the database'+ err)}
);

var db = mongoose.connection;

app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());

mongoose.set('useFindAndModify', false);

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(express.static(path.join(__dirname, '../public')));

app.use(session({
  secret: 'secret_Cadenet_Fritel',
  resave: true,
  saveUninitialized: false,
  store: new MongoStore({
    mongooseConnection: db
  })
}));

app.use('/', authRoute);
app.use('/user', userRoute);
app.use('/school', schoolRoute);

app.listen(port, function () {
  "use strict";
  console.log('Ready');
});

module.exports = app;