https://github.com/luqmanoop/node-postgres-api
A simple blog API built with Node.js + Express + PostgreSQL
https://github.com/luqmanoop/node-postgres-api
es6 express nodejs postgres postgresql rest-api
Last synced: 4 days ago
JSON representation
A simple blog API built with Node.js + Express + PostgreSQL
- Host: GitHub
- URL: https://github.com/luqmanoop/node-postgres-api
- Owner: luqmanoop
- License: mit
- Created: 2018-09-23T12:33:24.000Z (over 7 years ago)
- Default Branch: develop
- Last Pushed: 2018-09-27T21:06:23.000Z (over 7 years ago)
- Last Synced: 2025-02-14T22:07:32.237Z (about 1 year ago)
- Topics: es6, express, nodejs, postgres, postgresql, rest-api
- Language: JavaScript
- Homepage:
- Size: 117 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Introduction
A simple blog API built using NodeJS + Express + Postgres.
## Installation
```bash
$ git clone git@github.com:codeshifu/node-postgres-api.git
$ cd node-postgres-api
$ npm install
```
### Rename _.env.sample_ to .env and set database connection
```
DB_URL=postgres://user:password@host:port/database
```
## Run
```bash
$ npm run dev
```
Visit http://localhost:8000/api/v1
### Available endpoints
`/api/v1/authors`
| method | route | description |
| ------ | ------------------ | -------------------- |
| GET | /authors | Get authors |
| POST | /authors | Create author |
| GET | /authors/:id | Get author by ID |
| GET | /authors/:id/posts | Get posts by author |
| PUT | /authors/:id | Update author |
| DELETE | /authors/:id | Delete/remove author |
`/api/v1/posts`
| method | route | description |
| ------ | ---------- | -------------------- |
| GET | /posts | Get posts |
| POST | /posts | Create post |
| GET | /posts/:id | Get posts by ID |
| PUT | /posts/:id | Update author |
| DELETE | /posts/:id | Delete/remove author |