Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/taniarascia/node-api-postgres
RESTful API with Node.js, Express, and Postgres.
https://github.com/taniarascia/node-api-postgres
api crud crud-app database express node nodejs postgres postgresql rest restful-api
Last synced: about 2 months ago
JSON representation
RESTful API with Node.js, Express, and Postgres.
- Host: GitHub
- URL: https://github.com/taniarascia/node-api-postgres
- Owner: taniarascia
- License: mit
- Created: 2018-10-03T00:33:30.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-03-30T04:50:50.000Z (over 2 years ago)
- Last Synced: 2023-02-26T08:03:20.236Z (almost 2 years ago)
- Topics: api, crud, crud-app, database, express, node, nodejs, postgres, postgresql, rest, restful-api
- Language: JavaScript
- Homepage: https://blog.logrocket.com/setting-up-a-restful-api-with-node-js-and-postgresql-d96d6fc892d8/
- Size: 11.7 KB
- Stars: 90
- Watchers: 2
- Forks: 53
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RESTful API with Node.js, Express, and Postgres
Create, read, update, delete in a Node.js app with an Express server and Postgres database.
### [Read the tutorial](https://blog.logrocket.com/setting-up-a-restful-api-with-node-js-and-postgresql-d96d6fc892d8/)
## Database
```bash
brew install postgresql
brew services start postgresql
psql postgres
``````sql
CREATE ROLE me WITH LOGIN PASSWORD 'password';
ALTER ROLE me CREATEDB;
CREATE DATABASE api;
GRANT ALL PRIVILEGES ON DATABASE api TO me;
``````bash
psql -d api -U me
``````sql
CREATE TABLE users (
ID SERIAL PRIMARY KEY,
name VARCHAR(30),
email VARCHAR(30)
);INSERT INTO users (name, email)
VALUES ('Jerry', '[email protected]'), ('George', '[email protected]');
```## Installation
```bash
git clone [email protected]:taniarascia/node-api-postgres
cd node-api-postgres
npm install
node index.js
```## Commands
- GET: `curl http://localhost:3000/users`
- POST: `curl --data "name=Jerry&[email protected]" http://localhost:3000/users`
- PUT: `curl -X PUT -d "name=George" -d "[email protected]" http://localhost:3000/users/1`
- DELETE: `curl -X "DELETE" http://localhost:3000/users/1`## Author
- [Tania Rascia](https://www.taniarascia.com)
## License
This project is open source and available under the [MIT License](LICENSE).