awslabs/startup-kit-nodejs

Name: startup-kit-nodejs

Owner: Amazon Web Services - Labs

Owner: AWS Samples

Description: A Node.js sample workload for use with the AWS Startup Kit.

Created: 2017-01-25 19:21:53.0

Updated: 2018-01-13 18:31:17.0

Pushed: 2017-09-12 18:19:18.0

Homepage: null

Size: 40

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

AWS Startup Kit Node.js Workload

An example AWS Elastic Beanstalk project built using Node.js as the platform. It includes a RESTful API created with Express. Use this example to test out your VPC and database setup on AWS, or as a starting point for your own projects.

LAUNCHING THE APP ON AWS

To create an Elastic Beanstalk app on AWS using this code:

{
    "DB_CLIENT": "pg",
    "DB_HOST": "localhost",
    "DB_USER": "startupadmin",
    "DB_PASSWORD": "changeme",
    "DB_NAME": "StartupDB",
    "DB_MAX_CONNS": 100,
    "AWS_REGION": "us-east-1",
    "AUTH_ENABLED": false,
    "AUTH_JWT_SECRET": "my-secret",
    "AUTH_JWT_TOKENTIME":  6000
}
STEPS TO BUILD AND RUN LOCALLY
TESTING THE APP
curl http://localhost:8081/api/todo/all

curl -X POST -H 'Content-Type: application/json' -d '{"active": true, "description": "What TODO next?"}' http://localhost:8081/api/todo/new
curl -X POST -H 'Content-Type: application/json' -d '{"username": "FirstUser", "password": "MyPassword"}' http://localhost:8081/api/auth

curl -H 'Authorization: Bearer MY_AUTH_TOKEN' http://localhost:8081/api/todo/all

curl -X POST -H 'Authorization: Bearer MY_AUTH_TOKEN' -H 'Content-Type: application/json' -d '{"active": true, "description": "What TODO next?"}' http://localhost:8081/api/todo/new
DEPLOYMENT NOTES

Environment variables: this app uses the nconf module to provide a hierarchy for variable overriding. For this app, the order is command line, environment variables, then lastly the local config.json file, which provides defaults for talking to a developer's local database. For the connection to a RDS database, the developer specifies relevant environment variables when creating the database stack using the db.cfn.yml CloudFormation template. These values, which are never committed to source control for security reasons, flow through to the app creation template.

To deploy a modified version of the app: set up the Elastic Beanstalk CLI, and use the eb deploy command. Alternatively, you could use a continuous delivery solution such as AWS CodePipeline.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.