Skip to content

AlexHff/node-metrics

Repository files navigation

node-metrics Build Status Coverage Status HitCount

Simple web API to work on metrics

Features

  • Authentication
  • CRUD users
  • CRUD metrics

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

To build and run this app locally you will need Node.js

Quick start

Clone the repository

git clone https://github.com/AlexHff/node-metrics.git
cd node-metrics

Install dependencies

npm install

Populate database

npm run populate

Build and run the project

npm run build
npm start

Finally, navigate to http://localhost:8081 and you should see the project being served and rendered locally.

Run in Docker

This app can also be launched in a Docker container. Go to the directory that has your Dockerfile and run the following command to build the Docker image.

docker build -t node-metrics .

Running your image with -d runs the container in detached mode, leaving the container running in the background. The -p flag redirects a public port to a private port inside the container. Run the image you previously built:

docker run -p 8081:8081 -d node-metrics

Now open http://localhost:8081 and you should see the app running locally.

Running the tests

Run unit tests

npm test

Deployment

This application has been deployed to an Elastic Beanstalk environment on AWS.

Deploy a Container with a Dockerfile

Use the Elastic Beanstalk CLI (EB CLI) to configure your local repository for deployment to Elastic Beanstalk.

eb init -p docker <application-name>

After testing your application locally, deploy it to an Elastic Beanstalk environment. Elastic Beanstalk uses the instructions in your Dockerfile to build and run the image.

Use the EB CLI to create an environment and deploy your application.

eb create <environment-name>

Once your environment has launched, use eb open to view it in a web browser.

eb open

Built With

  • Express - Fast, unopinionated, minimalist web framework for Node.js
  • EJS - Embedded JavaScript templating
  • Level - Fast & simple storage
  • Passport - Authentication middleware for Node
  • Chart.js - Simple yet flexible JavaScript charting

Authors

For more information, see the CONTRIBUTORS file

License

This project is licensed under the MIT License - see the LICENSE file for details

Routes

Method Route Description
GET / Displays the homepage
GET /login Displays the login form
POST /login Logs the user in
GET /logout Signs out the current out
GET /signup Displays the signup form
POST /signup Adds a user
GET /user Gets the current user
GET /metric Gets all metrics
GET /metric/:id Gets a metric given an id
POST /new Adds a new metric
POST /update Updates an existing metric
POST /delete Deletes a metric

Acknowledgments

About

Simple web API to work on metrics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages