Git Product home page Git Product logo

website's Introduction

Vanilla Node Server

Vanilla Node Server was initially based off of the MEAN stack (with the client stripped out). This project has since:

  • Been converted to es6 syntax
  • Introduced; eslint, jshint, & babel
  • Introduced Webpack as a module bundler

Changes that are planned to happen are:

  • Increase logging granularity
  • Introduce the option for integration with CouchDB
  • Refactor large closures
  • Optimise passport authentication
  • Switch to use Express Router

About

The reason for developing this project (modify MEAN.js as I should say) is that I found it monotonous to re-write a basic server for every project I did. Future projects will now be cloned from this repo so it is much easier to spin up applications.
I differed from the standard MEAN stack for the reason that the syntax was still in es5. I give large credit to the MEAN.js contributors for the structural layout of this application.
Even though it is a base project, there are still features that should be addressed that are included here:

  • Node.js as a server
  • Webpack as the module bundler
  • Express as the API middleware
  • ACL for the auth of Express endpoints
  • Passport for the auth middleware to 3rd party services (i.e. Facebook)
  • Gulp as the task runner
  • MongoDB as the data store
  • Mongoose for object modelling
  • Winston as the logging mechanism
  • Socket.io for real-time bidirectional event-based comms
  • Mocha as the unit testing framework

Before You Begin

Before you begin we recommend you read about the basic building blocks that assemble a MEAN.JS application:

Prerequisites

Make sure you have installed all of the following prerequisites on your development machine:

Install

To install project dependencies, run:

$ npm install

Running Your Application

As mentioned above, the task runner is gulp. To run the default gulp tak, run:

$ npm start

Your application should run on port 3000 with the development environment configuration, so in your browser just go to http://localhost:3000

Explore config/env/development.js for development environment configuration options.

Running in Production mode

To run your application with production environment configuration:

$ npm run start:prod

Explore config/env/production.js for production environment configuration options.

Running with User Seed

To have default account(s) seeded at runtime:

In Development:

MONGO_SEED=true npm start

It will try to seed the users 'user' and 'admin'. If one of the user already exists, it will display an error message on the console. Just grab the passwords from the console.

In Production:

MONGO_SEED=true npm start:prod

This will seed the admin user one time if the user does not already exist. You have to copy the password from the console and save it.

Running with TLS (SSL)

Application will start by default with secure configuration (SSL mode) turned on and listen on port 8443. To run your application in a secure manner you'll need to use OpenSSL and generate a set of self-signed certificates. Unix-based users can use the following command:

$ npm run generate-ssl-certs

Windows users can follow instructions found here. After you've generated the key and certificate, place them in the config/sslcerts folder.

Finally, execute prod task npm run start:prod

  • enable/disable SSL mode in production environment change the secure option in config/env/production.js

Testing Your Application

You can run the full test suite included with MEAN.JS with the test task:

$ npm test

This will run both the server-side tests (located in the app/tests/ directory) and the client-side tests (located in the public/modules/*/tests/).

To execute only the server tests, run the test:server task:

$ npm run test:server

To execute only the server tests and run again only changed tests, run the test:server:watch task:

$ npm run test:server:watch

And to run only the client tests, run the test:client task:

$ npm run test:client

Development and deployment With Docker

  • Install Docker

  • Install Compose

  • Local development and testing with compose:

$ docker-compose up
  • Local development and testing with just Docker:
$ docker build -t vanilla_node_server .
$ docker run -p 27017:27017 -d --name db mongo
$ docker run -p 3000:3000 --link db:db_1 vanilla_node_server
$
  • To enable live reload, forward port 35729 and mount /app and /public as volumes:
$ docker run -p 3000:3000 -p 35729:35729 -v /Users/mdl/workspace/vanilla_node_server/public:/home/vanilla_node_server/public -v /Users/mdl/workspace/vanilla_node_server/app:/home/vanilla_node_server/app --link db:db_1 vanilla_node_server

Production deploy with Docker

  • Production deployment with compose:
$ docker-compose -f docker-compose-production.yml up -d
  • Production deployment with just Docker:
$ docker build -t mean -f Dockerfile-production .
$ docker run -p 27017:27017 -d --name db mongo
$ docker run -p 3000:3000 --link db:db_1 vanilla_node_server

Amazon S3 configuration

To save the profile images to S3, simply set those environment variables: UPLOADS_STORAGE: s3 S3_BUCKET: the name of the bucket where the images will be saved S3_ACCESS_KEY_ID: Your S3 access key S3_SECRET_ACCESS_KEY: Your S3 access key password

License

The MIT License

website's People

Contributors

wmash avatar

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.