Painless PostgreSQL Node.js backend with Objection + Knex + Express. A mirror: https://github.com/cedrickchee/painless-pg-node
  • JavaScript 95.4%
  • Shell 2.5%
  • Dockerfile 2.1%
Find a file
2022-03-26 17:02:31 +08:00
controllers Fix wrong endpoint URLs 2020-06-29 15:20:27 +08:00
db Update seeds for schema changes 2020-06-29 02:50:27 +08:00
models Fix: remove hardcoded Knex connection 2020-06-28 21:14:14 +08:00
scripts Web/API container start script 2020-06-29 18:42:10 +08:00
.dockerignore Docker Compose for production stack 2020-06-29 18:41:20 +08:00
.gitignore Ignore SQLite3 database file 2020-06-28 19:40:16 +08:00
.prettierrc Add Prettier config 2020-06-28 20:26:07 +08:00
app.js API versioning 2020-06-29 03:05:37 +08:00
docker-compose.yml Docker Compose for production stack 2020-06-29 18:41:20 +08:00
Dockerfile Dockerfile for web app 2020-06-29 18:40:15 +08:00
knexfile.js Move Knex migrations & seeds files to db dir 2020-06-29 00:13:52 +08:00
package-lock.json Merge pull request #10 from cedrickchee/dependabot/npm_and_yarn/objection-2.2.16 2022-03-26 17:02:31 +08:00
package.json Bump objection from 2.2.0 to 2.2.16 2022-03-26 09:00:11 +00:00
README.md Add a minimal README 2020-06-29 01:33:28 +08:00

Painless Node.js API with SQL Database

A minimal scaffold project that shows how to painlessly build a robust API with SQL database on Node.js.

What's included

  • node-postgres - Node.js modules for interfacing with PostgreSQL database
  • Knex.js - SQL query builder
  • Objection.js - An SQL-friendly ORM built on Knex for Node.js
  • Express.js - Web framework for Node.js. A myriad of HTTP utility methods for creating API easily.

What does it do

It provides a simple idea/comment database and shows how relation can be modelled with Objection Model class. It also shows how to use eager loading to get related queries.

Development

  • Clone this repo: git clone https://github.com/cedrickchee/painless-pg-node.git
  • cd painless-pg-node
  • npm install to install required project dependencies.
  • Modify database connection according to your machine in knexfile.js.
  • Run it:
    • npm start to start the production server.
    • npm run dev to start the development server.
  • Point your browser to http://localhost:3000/ideas to test if it's working.