Git Product home page Git Product logo

sample-service's Introduction

Demo sample backend

Overview

This is a simple Node.js backend app that creates and stores hypothetical product listings. Together with sample-app, its purpose is to demonstrate how to deploy a simple app on the Humanitec internal developer platform.

The app exposes an API on /products that allows you to create and list product items. Products are stored in a single table in a Postgres database.

Diagram: Architecture of the Humanitec demo app

Configuration

You can configure the app's database connection using these environmental variables:

Variable Description
CONNECTION_STRING The connection string for the PostgreSQL database in URL form

Running with docker-compose

The whole system can be run locally using docker-compose. This will run the product-be server and expose it on localhost:8080 and initialize a PostgreSQL database which can be accessed on localhost:5432. The admin password to the database is pgsqlDev01.

Run the following commands in the root of the repository:

$ docker-compose build
$ docker-compose up

Testing

Tests can be run with:

$ npm run test

Running locally

When running locally, you must have a PostgreSQL server up and running with a database created and with a PostgreSQL ROLE that has LOGIN rights.

After that, the server can be run with the following command:

$ CONNECTION_STRING="postgresql://product_robot:pr0dr0b0t@productdb:5432/product" \
  node bin/www

Now the database server is running on localhost:5432 with a database called product created by a user called product_robot with password pr0dr0b0t.

sample-service's People

Contributors

damien-duignan avatar chrishumanitec avatar lemkeb avatar nukdcbear avatar nilsty 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.