Git Product home page Git Product logo

noire-server's Introduction

last commit Build Status Coverage

Dependencies Status DevDependencies Status

Maintainer: Rui Ferrão

Noire Server

Extremely opinionated Hapi boilerplate using a layered architecture for proper separation of concerns

WARNING: Noire is currently under active development and might not be ready for heavy production use

View Layer

  • Accept data
  • Apply style and formatting
  • Rendering

Controllers

  • Map routes
  • Extract route parameters
  • Kick off some work
  • Send the result to a View for rendering

Service Layer

  • Perform work for the Controller
  • Return the result for the Controller

Data Access Layer

  • Repository pattern for data entities
  • Thin models
  • ORM with transactional capabilities

Features

  • HTTP and HTTPS support
  • Server rendered views using the Semantic-UI front-end framework and Handlebars template engine
  • API routes for rendering on the client side and building SPAs
  • Automated API documentation generation
  • Stateless JWT auth for API endpoints
  • Cookie stored JWT auth for web app with CSRF protection
  • RBAC authorization
  • AJAX login, signup, registration and password reset forms
  • Email sending using handlebars templates
  • Client side caching of assets
  • Fast and flexible logging (Pino)
  • Testing, code coverage and Travis CI integration
  • Graceful server shutdown
  • Database ORM (Objection) with migrations (Knex) support
  • Usage of native Promises and async/await

Get it Running

Clone the repo

git clone [email protected]:academia-de-codigo/noire-server.git

Install the required Dependencies

npm install

Adjust the configuration files to suit your environment

Edit all lib/config* files

Setup environment variables

  • NODE_ENV should be set to either development, staging or production. If not set at all, defaults to development
  • JWT_SECRET should contain a secret which will be used to sign authentication tokens. A safe randomly generated secret can be obtained by running npm run secret.
  • SMTP credentials should be configured using the SMTP_USER and SMTP_PASS environment variables
  • Staging and Production environment need the DB_HOSTT, DB_NAME, DB_USER and DB_PASS environment variables for configuration the database connection
  • All environment variables can be setup inside a .env file which should not be commited and is sourced when the server starts. A sample example.env file is provided.

Reset the database to it's original state

npm run reset

Generate Frontend Build

npm run build

Run the unit tests

npm test

Launch the server in production mode

  • Make sure NODE_ENV=production
  • Update frontend build running npm run webpack:prod
  • Start the server with npm start

Development

  • Set NODE_ENV=development
  • Update frontend build running npm run webpack
  • Start the server in watch mode with npm run watch

Development Environment

Noire is developed using Vim and Visual Studio Code. With VSCode the following plugins are used:

  • Babel ES6/ES7
  • Document This
  • DotENV
  • EditorConfig for VS Code
  • ESLint
  • HTMLHint
  • Node.js Modules Intellisense
  • npm
  • Path Autocomplete
  • Prettier

For proper code formatting and module intellisense under VSCode, the following settings are recommended:

"settings": {
		"editor.formatOnSave": true,
		"node-module-intellisense.scanBuiltinModules": true,
		"node-module-intellisense.scanDevDependencies": true,
		"node-module-intellisense.scanFileModules": true,
		"node-module-intellisense.modulePaths": [
			"lib"
		],
		"node-module-intellisense.autoStripExtensions": [
			".js"
		]
	}

noire-server's People

Contributors

ferrao avatar pantoninho avatar p-brighenti avatar sgouveia avatar filipesantoss avatar jfstn avatar

Watchers

James Cloos 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.