Giter Site home page Giter Site logo

andres3m / bc13_w11d2_workshop_full-stack-deployment-back-end-room-22-louis-andres Goto Github PK

View Code? Open in Web Editor NEW

This project forked from schoolofcode/bc13_w11d2_workshop_full-stack-deployment-back-end-room-22-louis-andres

0.0 0.0 0.0 32 KB

bc13_w11d2_workshop_full-stack-deployment-back-end-room-22-louis-andres created by GitHub Classroom

JavaScript 100.00%

bc13_w11d2_workshop_full-stack-deployment-back-end-room-22-louis-andres's Introduction

Express/Postgres API for Shopping List Data

We suggest using Render for your first back end deploy as there's a suitable free tier, and it's fairly straightforward. However, just like for your front end, it's worth also investigating other services later on (including free Heroku credit available in the Github Student Pack).

When entering your build and start command, read the descriptions carefully. These are the instructions that the platform you're deploying with needs to run your app on their computer, so it should mirror what you use in the terminal to run it on your computer. For the build command, how do you normally make sure your app has all the libraries it needs? For the start command, how would you start your app in production (not dev) mode?

When attempting to deploy this repo, remember to set up your database and add your database URL as an environment variable!

  1. Locally run the npm run createTable script (to set up the required database table).

    • You'll need to have locally set a DATABASE_URL environment variable in a .env file. You can get your database URL from whatever source you'd like to set up your database on (Railway, Elephant, etc.).

    • Normally you wouldn't interact with production databases from a local machine, but we'll ignore this for now (as we're just focusing on getting things deployed).

  2. Ensure the DATABASE_URL variable is set (not just locally but also wherever you're deploying to). This means that you'll need to look for where to enter environment variables when you're setting up your deployment - they may be hidden in an "advanced" dropdown when you're configuring your settings! Once you've found where to enter it, it'll be a key/value pair just like in your .env file. This allows the platform that you're deploying to to have that variable ready in the environment in which it's running your code (just like .env does when running on your own computer's environment).

Bonus

Explore as many of the following as you like:

  • Extend the API and frontend so that they have more features and continue to talk to one another:
    • A way to mark an item in the database as "completed"
    • Filtering, sorting, paginating of items in the shopping list whilst keeping to a RESTful interface.
  • See the best practices for Express (see: https://expressjs.com/en/advanced/best-practice-performance.html) in production and try to implement as many as you can (where appropriate). For example:
  • Sanitising/validating/checking (especially user input) in the request (e.g. what's been sent in the query, params, body, headers, etc.) using something like: https://www.npmjs.com/package/express-validator
  • Explore the npm ci command vs. the npm i command we're used to. Start with this article and this blog post. What are the pros and cons of using this when deploying your app?

Make sure that you commit, push and deploy small increments of changes/code. Those changes should be reflected automatically, if you have automated deployments enabled.

bc13_w11d2_workshop_full-stack-deployment-back-end-room-22-louis-andres's People

Contributors

andres3m avatar github-classroom[bot] 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.