<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Trish</title>
    <description>The latest articles on DEV Community by Trish (@trishtracking).</description>
    <link>https://dev.to/trishtracking</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F457479%2F6ce15a15-c8b5-46b2-a265-3d0c7fafb926.jpeg</url>
      <title>DEV Community: Trish</title>
      <link>https://dev.to/trishtracking</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/trishtracking"/>
    <language>en</language>
    <item>
      <title>Installing a github server/database project locally</title>
      <dc:creator>Trish</dc:creator>
      <pubDate>Tue, 25 Aug 2020 17:03:14 +0000</pubDate>
      <link>https://dev.to/trishtracking/installing-a-github-server-database-project-locally-1bh4</link>
      <guid>https://dev.to/trishtracking/installing-a-github-server-database-project-locally-1bh4</guid>
      <description>&lt;p&gt;On the &lt;a href="http://foundersandcoders.com/"&gt;Founders and Coders&lt;/a&gt; course, we make a new project each week, and then each team spends time at the end of the week reviewing the code of another team's project. &lt;/p&gt;

&lt;p&gt;When testing the projects (especially if the team hasn't managed to deploy them in our quick sprints-- which definitely happens-- it's the learning, not the finished product that matters!), we often want to install them locally and it confused me a couple of times so I've written it down. I hope you find it helpful, too! &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Clone &amp;amp; install dependencies&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Clone this repo to a new folder on your local machine using  &lt;code&gt;git clone&lt;/code&gt; + the HTTP link from the Code dropdown menu in the project. Move in to the folder with &lt;code&gt;cd&lt;/code&gt; + folder name&lt;/p&gt;

&lt;p&gt;First, we want to: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run &lt;code&gt;npm install&lt;/code&gt; in your terminal to install all npm packages &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Initialise a local database&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now we need to to create a local database for testing and connect to it with the project's init.sql file. &lt;/p&gt;

&lt;p&gt;Run:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;psql&lt;/code&gt; to enter into the postgres terminal&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;CREATE USER myuser SUPERUSER PASSWORD 'mypassword';&lt;/code&gt; to create a dedicated psql local user for the application&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;CREATE DATABASE test_database WITH OWNER myuser;&lt;/code&gt; to create a database&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;\connect test_database&lt;/code&gt; to connect to your test database file&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;\include init.sql&lt;/code&gt; to initialise and run the sql file&lt;/li&gt;
&lt;li&gt;handy hint: &lt;code&gt;ctrl + d&lt;/code&gt; at any time while running psql in the terminal to get out of it&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Create environment variables in a .env&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Next, set up your own environment variables for the JSON secret key, database_url and test_database_url (if applicable)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Create an .env file in the very &lt;em&gt;root&lt;/em&gt; of the project, the top file. It won't work anywhere else! &lt;/p&gt;

&lt;p&gt;Add the following to this file: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DATABASE_URL = "remote Heroku URI", if applicable &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Heroku config variables will be in the 'settings' section of your app, at a url like this: &lt;code&gt;https://dashboard.heroku.com/apps/APPNAME/settings&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TEST_DATABASE_URL  = "&lt;code&gt;postgres://username:password@localhost:5432/database_name&lt;/code&gt;" - sub in the details we created earlier&lt;/li&gt;
&lt;li&gt;SECRET- a secret key which will be used to create a JSON Web Token (JWT) for storing cookies&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;Now we can run it using commands in our terminal.  Check the package.json file under 'scripts' to see the project-specific commands, but they are likely to be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;npm run dev&lt;/code&gt; to start the server using nodemon. Nodemon auto restarts anytime you change something, so you don't have to do it! &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;npm test&lt;/code&gt; to run tests locally if there are tests to run&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And you're good to go! If I've missed something, let me know. 🐙 &lt;/p&gt;

</description>
      <category>github</category>
      <category>npm</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
