jsheridanwells / BeautifulDay

A web app for planning and tracking an ideal day

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BeautifulDay

A web app for planning and tracking an ideal day

Some Dev Usefulness...

Color Scheme:

MaterialPalette

Required Dependencies

This is a Node.js Express application that uses MongoDb for persistence and Angular for the client. The following dependencies will need to be installed for local development:

  • Node.js (Version 14 is ideal)

  • The Angular CLI (Version 11)

  • Typescript (Version 4)

  • Concurrently (an npm tool for running different Node.js processes simultaneously)

  • Docker Desktop. As well as testing container settings, we can run the MondoDb database through a Docker container instead of going through a local installation.

  • MongoDb (optional)

Configuration

An .env file will need to be created at the root of the project with the following settings:

APP_SECRET=<a secret to sign the app's JSON web tokens. This can be any string. Protect this.>

GOOGLE_CLIENT_ID=<register the app in the Google Dev Console: https://console.developers.google.com/>
GOOGLE_CLIENT_SECRET=<get your Google secret. Protect this.>

BD_USER=<The application user for the database. DbOwner of the application database>
BD_PWD=<The application user password. Protect this.>
MONGO_INITDB_ROOT_USERNAME=<The root user for the MongoDb Docker container. The DB can only be accessed with this account>
MONGO_INITDB_ROOT_PWD<The root user password. Protect this.>
DB_NAME=<The app database. 'beautifulDay' by default>

In Angular, ./client.src.environments/environment.ts will need the following values updated:

export const environment = {
  googleClientId: '<Must match GOOGLE_CLIENT_ID in .env>',
  googleSessionStorageKey: 'Can be anything. Used to identify the authentication token that gets returned from Google and saved in sessionStorage',
  jwtKey: 'Can be anything. Used to identify the apps JSON web token that is saved to localStorage'
}

Note that these values are assumed to be insecure.

Dev Scripts

Note, to

The package.json contains the following scripts for this project's dev tasks:

  • $ npm run clean - Clean out the ./dist directory before transpiling the Typescript files.

  • $ npm run clean:db - Remove all MongoDb artifacts from the ./data/db directory. Note, this command will request to be run under sudo if the files were created through Docker.

  • $ npm run cp:www - Copy the ./bin/www Express.js entry file to the output directory. This file is otherwise ignored in the regular Typescript compilation.

  • $ npm run cp:mongo - Copy the MongoDb init files to the output directory. These files are needed for bootstrapping the database through Docker.

  • $ npm run dev - Run the project with local configurations. This process will run ng build --watch for client-side scripts, tsc -p […config] --watch for application files, then it will run Nodemon to watch and restart the Express.js application. Note, there's some code in app.ts to refresh the browser whenever client-side code is updated, but sometimes this can lead to wonky performance. Comment it out if it' giving you grief.

  • $ npm run prod - Runs the project as above, but with production configurations.

  • $ npm run build:all - Compile all source code and files to './dist' for direct deployment.

  • $ npm run build:img - compile all source code and files to './dist' for Docker container deployment.

  • Use: docker-compose -f docker-compose-dev-yml up --force-recreate to run the MongoDb database in a Docker container. See the configuration section above for the required environment variables.

About

A web app for planning and tracking an ideal day

License:MIT License


Languages

Language:TypeScript 78.3%Language:HTML 9.1%Language:SCSS 7.8%Language:JavaScript 4.4%Language:Dockerfile 0.3%