Skip to content

sabdul08/node-api-postgres

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RESTful API with Node.js, Express, and Postgres

Create, read, update, delete in a Node.js app with an Express server and Postgres database.

Database

brew install postgresql
brew services start postgresql
psql postgres
CREATE ROLE me WITH LOGIN PASSWORD 'password';
ALTER ROLE me CREATEDB;
CREATE DATABASE api;
GRANT ALL PRIVILEGES ON DATABASE api TO me;
psql -d api -U me
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

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

License

This project is open source and available under the MIT License.

About

RESTful API with Node.js, Express, and Postgres.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%