Code Monkey home page Code Monkey logo

backend-template's Introduction

Thinkful Backend Template

A template for developing and deploying Node.js apps.

Getting started

Setting up a project

  • Move into your projects directory: cd ~/YOUR_PROJECTS_DIRECTORY
  • Clone this repository: git clone https://github.com/Thinkful-Ed/backend-template YOUR_PROJECT_NAME
  • Move into the project directory: cd YOUR_PROJECT_NAME
  • Install the dependencies: npm install
  • Create a new repo on GitHub: https://github.com/new
    • Make sure the "Initialize this repository with a README" option is left unchecked
  • Update the remote to point to your GitHub repository: git remote set-url origin https://github.com/YOUR_GITHUB_USERNAME/YOUR_REPOSITORY_NAME

Working on the project

  • Move into the project directory: cd ~/YOUR_PROJECTS_DIRECTORY/YOUR_PROJECT_NAME
  • Run the development task: npm start

Databases

By default, the template is configured to connect to a MongoDB database using Mongoose. It can be changed to connect to a PostgreSQL database using Knex by replacing any imports of db-mongoose.js with imports of db-knex.js, and uncommenting the Postgres DATABASE_URL lines in config.js.

Deployment

Requires the Heroku CLI client.

Setting up the project on Heroku

  • Move into the project directory: cd ~/YOUR_PROJECTS_DIRECTORY/YOUR_PROJECT_NAME

  • Create the Heroku app: heroku create PROJECT_NAME

  • If your backend connects to a database, you need to configure the database URL:

    • For a MongoDB database: heroku config:set DATABASE_URL=mongodb://USERNAME:PASSWORD@HOST:PORT/DATABASE_NAME
    • For a PostgreSQL database: heroku config:set DATABASE_URL=postgresql://USERNAME:PASSWORD@HOST:PORT/DATABASE_NAME
  • If you are creating a full-stack app, you need to configure the client origin: heroku config:set CLIENT_ORIGIN=https://www.YOUR_DEPLOYED_CLIENT.com

Deploying to Heroku

  • Push your code to Heroku: git push heroku master

backend-template's People

Contributors

bookcasey avatar cklanac avatar oampo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

backend-template's Issues

why switch to `index.js`?

@oampo, just curious... why switch from server.js to index.js?

I know it's not terribly important but I'm torn between the two names.

  • server.js is a standard in npm since npm start runs node server.js by default
  • index.js is a standard cause well, it's index.js and it seems like it should be the default. And require() automatically loads the index of a folder but that doesn't seem to apply for this situation.

Of course opt for app.js 'cause it is used in Express Generator or main.js 'cause its' a classic.

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.