Skip to content

Latest commit

 

History

History
66 lines (42 loc) · 2.53 KB

README.md

File metadata and controls

66 lines (42 loc) · 2.53 KB

Hapi Nes Mongo

This is just an example of how to make a Hapi Webservice with its websockets module –Nes– and MongoDB.

Aim

This project it's inspired on the realtime timeline of Patrick Meier. It's an update to his tutorial to demonstrate how to utilize the Nes plugin to build a realtime project using websockets with Hapi, with the big difference that I decided to use MongoDB instead RethinkDB.

This is a short explanation on how to use websockets with Hapi, so that's why there's no use of a client-side framework (Angular, React, Vue, etc.).

There's a little bit of spanglish, specifically with the translation of "entry" as "entrada", just as a preview disclaimer.

Requirements

We can use an environment with Vagrant or a containter with Docker to host the database or use a database in the cloud (MongoDB Atlas).

Notes

The database only works with a replica set or a sharded cluster. MongoDB doesn't listen changes with a standalone instance.

Here is some information and tutorials that can be useful:

Scripts

Setting the environment variables

We need to copy the .env.example file, rename it as .env and put our own variables.

cp .env.example .env

Installing dependencies

npm install

Building the web bundle

npm run build

Start the service

npm start

Start the service as a developer

npm run dev