Simple Node + Express + Postgres Deployment with Railway and Supabase

Hary Dhimas Prakoso
3 min readNov 17, 2022

--

Requirement:

start script

Step 1 register railway and login, it’s better to have starter plan verified account

Railway Dashboard Page

Step 2 Create a new project, in this article i will use simple git repo above to deploy

New Project Page

Step 3 Give railway permission by clicking “Deploy from Github repo”, you can choose your repo to deploy

Choosing base repo to deploy

Step 4 Add environment variables that you used on your server repo, i use NODE_ENV and DATABASE_URL as environment variables. You can insert postgre connection string from app.supabase.com to DATABASE_URL

Adding environment variables
Make sure to have DATABASE_URL and NODE_ENV variables if you are using my repo

Step 5 Set your root directory folder, on my repo my server is located at /server folder directory, don’t forget to save the setup

Choosing root directory

Step 6 Click generate domain so your application can be accessed by HTTPS

Generating your domain

Step 7 When we try to hit one of our endpoints it shows us sequelizeDatabaseError. Why ? it’s because we need to migrate our database first

Error because not migrated yet

Step 8 Install railway CLI on your local machine https://docs.railway.app/develop/cli (you can use npm too for installation)

Step 9 Type railway login from your local terminal and press enter

login to railway from terminal

Step 10 Type railway status to see linked project to your local environment

railway status

Type railway link and choose your project if your current project is not written on railway status log message

railway link

Step 11 run migration and seeding from your local machine, make sure you have NODE_ENV=production on your railways variable environments

Migrating the database
Seeding the database

Step 12 Now you can try again to hit your endpoint ! And your data will be retrieved

That’s it folks ! Thanks for reading !

--

--

No responses yet