All Projects → alpersonalwebsite → node-express-postgresql

alpersonalwebsite / node-express-postgresql

Licence: MIT license
Node, Express and PostgreSQL

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to node-express-postgresql

book-store
Example of a book store management with MEAN STACK
Stars: ✭ 23 (-54%)
Mutual labels:  expressjs
mongo-crud
CRUD API built with MongoDB and Express
Stars: ✭ 18 (-64%)
Mutual labels:  expressjs
Online-Examination-System
Technologies : React js, Node js, Express js, Mongo Db, Ant Design, Redux js Key features: 1. User management 2. Modular code 3. Permission management 4. Persistent answers on page refresh in the test portal 5. Examination results using graphs 6. Results can directly be downloaded as excel sheet 7. Feedback system
Stars: ✭ 37 (-26%)
Mutual labels:  expressjs
main
Share your personal pronouns and stay updated on your friends' pronouns. Pronouny allows you to update your pronouns and send alerts to your friends.
Stars: ✭ 37 (-26%)
Mutual labels:  expressjs
dhiwise-nodejs
DhiWise Node.js API generator allows you to instantly generate secure REST APIs. Just supply your database schema to DhiWise, and a fully documented CRUD APIs will be ready for consumption in a few simple clicks. The generated code is clean, scalable, and customizable.
Stars: ✭ 224 (+348%)
Mutual labels:  expressjs
express-expeditious
flexible caching middleware for express endpoints
Stars: ✭ 42 (-16%)
Mutual labels:  expressjs
nodejs-clean
Clean Architecture with Node.js + Express.js
Stars: ✭ 136 (+172%)
Mutual labels:  expressjs
mini-express-boilerplate
A minimal Express boilerplate with passport user authentication, mongoose and some security setup configured
Stars: ✭ 15 (-70%)
Mutual labels:  expressjs
express-boilerplate
ExpressJS boilerplate with Socket.IO, Mongoose for scalable projects.
Stars: ✭ 83 (+66%)
Mutual labels:  expressjs
todo-list
A practical web application built with Node.js, Express, and MySQL for you to readily record, view, and manage your tasks with an account: Create, view, edit, delete, filter, and sort expenses are as easy as pie 🥧
Stars: ✭ 18 (-64%)
Mutual labels:  expressjs
pevn-starter
A basic example of how to use VueJS, Express and PostgreSQL in conjunction.
Stars: ✭ 53 (+6%)
Mutual labels:  expressjs
KodersHub
CodeEditor Mern WebApp specifically designed for Kids and Teens🤩
Stars: ✭ 25 (-50%)
Mutual labels:  expressjs
schematics
Schematics for adding Okta Auth to your projects
Stars: ✭ 60 (+20%)
Mutual labels:  expressjs
next
不再维护,请直接查看 https://github.com/notadd/notadd
Stars: ✭ 15 (-70%)
Mutual labels:  expressjs
ng-nest-cnode
Angular 10 Front-End and Nestjs 7 framework Back-End build Fullstack CNode
Stars: ✭ 17 (-66%)
Mutual labels:  expressjs
nodejs-simple-restfull-with-express
⚡ ExpressJS Rest API Sample
Stars: ✭ 19 (-62%)
Mutual labels:  expressjs
node-js-project-structure
No description or website provided.
Stars: ✭ 21 (-58%)
Mutual labels:  expressjs
media-scanner
A service used with CasparCG Server software for scanning media located on the server. Queried with query and thumbnail commands through CasparCG Server using AMCP.
Stars: ✭ 25 (-50%)
Mutual labels:  expressjs
probook-server
Backend for probook social media app using Nodejs, mongodb, express, jwt etc. Frontend is React, redux, material ui.
Stars: ✭ 17 (-66%)
Mutual labels:  expressjs
web-speech-demo
Learn how to build a simple text-to-speech voice app for the web using the Web Speech API.
Stars: ✭ 19 (-62%)
Mutual labels:  expressjs

Node, Express and PostgreSQL

js-standard-style License: MIT

Overview

This is an easy, basic and raw example of HOW to implement an API with Node, Express and PostgreSQL (with Sequelize ORM).

Requirements

  • Node 12+
  • NPM
  • PostgreSQL
  • Sequelize ORM
  • Optional: ElephantSQL account

Install dependencies

To avoid issues with husky, first enable git hooks (and add our hook):

npx husky install

npx husky add .husky/pre-commit

Then, install the dependencies as usual:

npm install

DB

Create database

createdb users

Populate data

psql users

Add data to users table

COPY users(id, firstname, lastname, age, gender, username, company, email, phone, address, created_at, updated_at)
FROM '/Users/your-user/data/node-express-postgresql/users.csv'
DELIMITER ','
CSV HEADER;

Dump data from local DB to external

pg_dump postgres://your-user:[email protected]/agency | psql postgres://your-user:[email protected]/your-database-name

Running the server

Development

npm run dev

Production

npm run build

npm start

API endpoints

GET /api/users

  • Returns an object with the key data containing an array of objects with 40 records.
  • Supports query string:
    • ?limit=integer
    • ?offset=integer

Request:

curl http://127.0.0.1:3333/api/users

Sample response:

{
  "data": [
    {
      "id": 1,
      "firstname": "Christian",
      "lastname": "Deackes",
      "age": 36,
      "gender": "Genderqueer",
      "username": "cdeackes0",
      "company": "Eayo",
      "email": "[email protected]",
      "phone": "602-240-5463",
      "address": "53 Lakewood Plaza",
      "createdAt": "2020-11-30T08:00:00.000Z",
      "updatedAt": "2021-03-28T07:00:00.000Z"
    },
    {
      "id": 2,
      "firstname": "Staford",
      "lastname": "Noice",
      "age": 27,
      "gender": "Female",
      "username": "snoice1",
      "company": "Oyoloo",
      "email": "[email protected]",
      "phone": "951-811-1800",
      "address": "18298 Crest Line Road",
      "createdAt": "2021-06-30T07:00:00.000Z",
      "updatedAt": "2021-07-14T07:00:00.000Z"
    }
  ]
}

Query string

GET /api/users?limit=1
  • Returns n record(s) where n is the value (type: Number) of the limit key.
Request:
curl http://127.0.0.1:3333/api/users?limit=1
Response:
{
  "data": [
    {
      "id": 1,
      "firstname": "Christian",
      "lastname": "Deackes",
      "age": 36,
      "gender": "Genderqueer",
      "username": "cdeackes0",
      "company": "Eayo",
      "email": "[email protected]",
      "phone": "602-240-5463",
      "address": "53 Lakewood Plaza",
      "createdAt": "2020-11-30T08:00:00.000Z",
      "updatedAt": "2021-03-28T07:00:00.000Z"
    },
  ]
}

Wrong type for n value will return all the users. Example: users?limit=%27Hello%27

GET /api/users?offset=10
  • Returns from n (PRIMARY KEY) where n is the value (type: Number) of the offset key.
Request:
curl http://127.0.0.1:3333/api/users?offset=10
Response:
{
  "data": [
    {
      "id": 11,
      "firstname": "Goldie",
      "lastname": "Dany",
      "age": 88,
      "gender": "Female",
      "username": "gdanya",
      "company": "Devcast",
      "email": "[email protected]",
      "phone": "954-161-7922",
      "address": "68 Drewry Plaza",
      "createdAt": "2021-03-28T07:00:00.000Z",
      "updatedAt": "2021-03-19T07:00:00.000Z"
    },
    {
      "id": 12,
      "firstname": "Kial",
      "lastname": "Hamberstone",
      "age": 53,
      "gender": "Male",
      "username": "khamberstoneb",
      "company": "Skipfire",
      "email": "[email protected]",
      "phone": "896-244-3662",
      "address": "68425 Buell Point",
      "createdAt": "2020-10-11T07:00:00.000Z",
      "updatedAt": "2021-06-02T07:00:00.000Z"
    }
  ]
}

GET /latency

  • Returns an object with a delay of 1 second (default)
  • Supports query string:
    • ?limit=integer
    • ?offset=integer

Request:

curl http://127.0.0.1:3333/latency

Response:

{
  "data": "Thanks for waiting 1 second"
}

Query string

GET /latency?delay=2000
  • Increases latency (delay) to n milliseconds where, min:1000 and max:4000. Default value: 1000ms.

Wrong type for n value will produce a default delay of 1000ms.

Request:
curl http://127.0.0.1:3333/latency?delay=2000
Response:
{
  "data": "Thanks for waiting 2 seconds"
}

GET everything else

  • Any other endpoint will retrieve an object

Request:

curl http://127.0.0.1:3333/

Response:

{
  "message": "Node.js, Express, and PostgreSQL API!"
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].