Giter VIP home page Giter VIP logo

my-mean-website-server's Introduction

Travis Build AppVeyor Build Code Climate CodeClimate Coverage Coveralls Coverage Known Vulnerabilities

My M.E.A.N. website server/back-end (Alpha)

This is the server side. Client side is available HERE

Informations

My MEAN website is a MEAN's web application that I'm creating as a personal website, but also for other users. It's composed by:

  • M: a MongoDb's database
  • E: a back-end with Express js
  • A: a front-end in Angular >= 4
  • N: a back-end in Node.js
  • redis
  • webpack
  • and other stuff

A possible extension of this project will be a configurable template to build a custom web app very quickly. This is my final goal, please be patient :)

Attention! This project is still an alpha, so it's not production ready. Please be careful. If you are interested, star this project on GitHub, share it and create pull requests.

Testing:

  • back-end unit: almost done (only the necessary things)*. coverage >=90%
  • back-end integration: almost done*. coverage >=90%

(*) I unit-tested only public functions and I tested all APIs (integration) except for OAUTH2/PassportJS. This is because, it's extremely difficult to test passportjs (for 3dparty services, not for the local auth) without to use browsers (like Zombie or Phantom). In my opinion an integration-test for a back-end api must use only backend's code, not also a browser (browser is on client and not on server :) ). The problem is that to test PassportJS without a browser it's really difficult. I asked on StackOverflow HERE, without receive any answers. For this reason, I decided to unit-tests these APIs (not APIs theirself but their functions/logics). If you want to help me to write integration-test's case for PassportJS, check this file

Requirements

  • macOS, Linux or Windows 10 with admin privileges
  • Node.js + npm
  • MongoDB and redis
  • some global npm dependencies
  • work in progress... (this is only an alpha, please be patient)

News

  • 10/06/2017 - My MEAN website Alpha 9 public release HERE
  • 08/20/2017 - My MEAN website Alpha 8 public release HERE
  • 08/10/2017 - My MEAN website Alpha 7 public release HERE
  • 04/09/2017 - My MEAN website Alpha 6 public release HERE
  • 01/21/2017 - My MEAN website Alpha 5 public release HERE
  • 12/30/2016 - My MEAN website Alpha 4 public release HERE
  • 11/28/2016 - My MEAN website Alpha 3 public release HERE
  • 10/27/2016 - My MEAN website Alpha 2 public release HERE
  • 08/15/2016 - My MEAN website Alpha 1 public release HERE

How to install (MacOS)

  • from the setup folder of this project, run bash install-macos.sh
  • import the db dump (.bson) from db-dump-prod's folder either running db-dump-prod/init.sh to do it automatically thanks to both mongo ad mongorestore CLIs, or using Studio 3T (previously MongoChef)

How to install (Linux)

Tested only on Ubuntu

  • from the setup folder of this project, run bash install-ubuntu.sh
  • import the db dump (.bson) from db-dump-prod's folder either running db-dump-prod/init.sh to do it automatically thanks to both mongo ad mongorestore CLIs, or using Studio 3T (previously MongoChef)

How to install (Windows)

Tested only on Windows 10

  • install both Mozilla Firefox and Google Chrome
  • install Node.js from the official website
  • install MongoDb Community from the official website
  • create a db called KS (obviously you have to start MongoDb to do that). You can configure this value later, but for debug/local environment I suggest this name
  • import the db dump (.bson) from db-dump-prod's folder either running db-dump-prod/init.sh to do it automatically thanks to both mongo ad mongorestore CLIs (if available in your PATH variable), or using Studio 3T (previously MongoChef)
  • install redis-server for Windows (file .msi) HERE
  • install Python 2.7.x from the official website
  • from the setup folder of this project, run with PowerShell as administator bash install-windows.sh

If you'll have problems with node-zopfli, you have to install it properly following this tutorial. There are two options, try with the first one npm install --global --production windows-build-tools, if it will fail, use option 2. Both options will require to download really big files from microsoft.com (manually or automatically). So, be careful.

How to setup

  1. You have to rename .env_example's file into .env (debug/local config - mandatory) and create another copy called .env_prod (production config)
    1a. Configure FRONT_END_PATH with the relative position of the main folder of THE CLIENT SIDE OF THIS PROJECT. For .env_prod you should use simply public
    1b. Configure REDIS_HOST, REDIS_PORT and REDIS_TTL. If you are in a debug/local environment you should use the example values
    1c. Configure both MONGODB_URI and MONGODB_TESTING_URI with your db path. I suggest to use the example value without user/password and with a db called KS
    1d. replace YOU KEY/ID with the keys obtained from facebook/github... oauth applications.
    1e. replace YOUR_EMAIL and YOUR_PASSWORD with the data of your e-mail account
    1f. replace YOUR GOOGLE RECAPTCHA... with Google Recaptcha2's keys
    1g. reaplace INSERT A JWT SECRET HERE with an alphanumerical string (I'm using a random string with a length = 72)
  2. execute this command npm install into the root folder (if it will fail, run it again :))
  3. start redis-server (both on Linux and Mac run redis-server, on Windows start C:\Program files\Redis\redis-server.exe)
  4. start MongoDb (on Linux run mongod, on Mac run sudo mongod and on Windows start C:\Program Files\MongoDB\Server\<your version here>\bin\mongod.exe)
  5. execute this command npm start into the root folder to start this application (back-end)

How to run both unit and integration tests (server-side)

  • npm test

How to start (development mode)

How to start (production mode)

I decided to use pm2 (with pm2.json config file) to run in cluster mode (max processes) this project in a production environment

Features

Work in progress... (this is only an alpha, please be patient)

Future extensions

Work in progress... (this is only an alpha, please be patient)

Images

alt tag

alt tag

alt tag

alt tag

alt tag

alt tag

alt tag

alt tag

Note: updated local profile info alt tag

Note: multiple account connected (Facebook and Github) alt tag

Configuration

From Alpha 5 I created many entries in .env, so you could start to configure this application. Work in progress... (this is only an alpha, please be patient)

Thanks

A special thanks to the authors of this book, because very useful to understand how to develop a modern web application: BOOK1

License

Copyright 2015-2017 Stefano Cappa

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


**Created by Stefano Cappa**

my-mean-website-server's People

Contributors

greenkeeper[bot] avatar ks89 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

nemanator

my-mean-website-server's Issues

Improve code quality using codeclimate

For example, improve these files:

  • F app_server/utils/util.js
  • D app_server/controllers/authentication/3dparty/3dparty-passport.js
  • D app_server/controllers/authentication/local/auth-local.js
  • D app_server/controllers/profile.js
  • C app_client/src/app/pages/project-list/timeline.scss

Improve `Password reset`

When the user clicks on the link to rest password received by mail, the reset page will appear.
User inserts the new password and clicks on Change password, everything works very well. Ok, but... After click on Change Password, this button must be disabled to prevent multiple requests.

AppVeyor

Configure appveyor in addition to travis ci

test everything

This requires many releases.
For alpha2 I scheduled only some tests.
I prefer to have a good test config before.

rest service not found => returns 403 (instead of 404 NOT FOUND)

HTTP specifications says:
The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.

This is a bug, because if I'm calling /api/dssjhdshd I pass over all unprotected services and this is ok, but rest-auth-mddleware will catch my request and if req.session.authToken is false/null/undefined (not logged in), it will return a 403.

This is very stupid. I should find a way to manage this correctly.

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.