This is the vanilla NodeJS & PostgreSQL backend of the Markdown Blog. Scripts encapsulate the build and run logic, making it quite simple.
Follow these instructions to build and run the app. Three simple steps.
- Run
npm install
in thebackend/
directory to install the npm packages. - Run
npm run init
to initialize the app.- Right now this just runs
npm run init_db
, which in turn runs theinit_db.sh
script that builds the DB, installs the DB extensions, and builds the DB tables.
- Right now this just runs
- Run
npm start
to run the server.
Contains the NodeJS server and database query logic.
The NodeJS server code. This defines the endpoints and the business logic in each. In a logic project I would break this up into different files with their own routers, usually organized by REST resource like /api/articles/*
and /api/users/*
This is the Node-PostgreSQL database query library. Here you can see the exact SQL queries used for each REST operation. Just like the server.js
file, this would likely be broken into a file for each table or some other subdivision if this were a larger project, but I tried to keep it simple for this project.
Contains the psql scripts to build the DB and tables, and the init_db.sh
script (run with npm run init
or npm run init_db
) which orchestrates all of these