Example Node (Express + Postgres) codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the an API spec.
- NodeJS - A JavaScript runtime environment
- Express - A web application framework for NodeJS
- PostgreSQL - A relational database management system that extends SQL
- Sequelize - A promise-based ORM for NodeJS
- Passport - An authentication middleware for NodeJS
Follow these steps to set up the project in development mode
- Install Nodejs
- Install and setup PostgreSQL
- Clone the repository by running the command
git clone https://github.com/victorjambo/conduit.git
- Run
cd conduit
to enter the application's directory - Install the application's dependencies by running the command
yarn install
- Create a
.env
file in the root of your directory using the.env.example
file in the repository - Setup the database and migrations (see database setup)
- Start the application by running
The application should now be running at
yarn run start:dev
http://127.0.0.1:5000
-
Create a database in
PostgreSQL
and name itconduit
-
Set the following environment variables in
.env
:DATABASE_USERNAME
- this is the database usernameDATABASE_PASSWORD
- this is the database password. Ignore if you don't have a database passwordDATABASE_NAME
- set this toconduit
-
Run database migrations
yarn run db:migrate
-
Check the database and confirm that the
users
table has been created
After setting up your .env
from the template provided in the .env.example
file,
to use these variables anywhere in the app;
- import the
dotenv
package
import dotenv from 'dotenv'
- Make it available for use as early as possible in that file
dotenv.config()
- Access any variable in the
.env
process.env.MY_ENV_VARIABLE
Jest is used as the testing framework for both the unit tests and integration tests. To execute all tests, run the command
yarn test or make test
Victor Mutai ([email protected])
MIT License