This backend tutorial was based on the boilerplate developed by USC Code the Change! Thank you to all the developers who contributed to it over the years :)
This boilerplate has a and backend/
directories, which contains an Express API server.
Here are some of the technologies used in this boilerplate (along with links to docs!):
- Typescript - Javascript but with types...much better autocomplete & debugging
- NodeJS - a runtime for JS that lets you run JS on the server, your laptop, or any other computing environment
- Express - web app framework for JS that we use for our API
- Sequelize - ORM for NodeJS that we use to interface with our database
- sequelize-typescript - makes it easier to use Typescript with Sequelize
- express-validator - middlewares for express that validate requests
- Postgres - open source SQL database that is awesome
We recommend using Visual Studio Code for your development environment.
- Install XCode and the XCode Command Line Tools using
xcode-select --install
- Install Homebrew
- Install Node.js and npm via Homebrew
brew install node
- Install Yarn (npm++) via Homebrew using
brew install yarn
- Install PostgreSQL via Homebrew using
brew install postgresql
- Clone this repository to a local directory on your computer (
git clone <repo_url> <dir>
) cd <dir>/backend
and runyarn install
, which will install all NPM packages specified by thepackage.json
located in the backend directory of this repository
- Install WSL
- Install Node.js, npm, and Yarn using WSL following these instructions
- Install PostgresSQL following these instructions
- Clone this repository to a local directory on your computer (
git clone <repo_url> <dir>
) cd <dir>/backend
and runyarn install
, which will install all NPM packages specified by thepackage.json
located in the backend directory of this repository
If you look inside package.json
, you'll see a key called scripts
. Yarn allows you to run these scripts in Terminal using the yarn run <script_name>
format. There are a bunch of scripts set up that will allow you to build the server for production, run the server or client in development mode, and test/lint the server (and soon, the client).
❗️ Make sure Postgres is running before doing anything on the backend!
Navigate into the backend
directory and run:
yarn start
to start the serveryarn test
to run backend testsyarn lint
to fix your ESLint errors
See the README in the backend directory