Skip to content

Node.js Express API for a pizza delivery POC with POSTGRES

Notifications You must be signed in to change notification settings

waytooheaven/node-express-postgres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 

Repository files navigation

node-express-postgres

Type "npm test" to activate test routes

The endpoint parts

//user part app.get('/users', db.getUsers)
app.get('/users/:id', db.getUserById)
app.post('/user', db.createUser)
//order part
app.get('/orders', db.getOrders)
app.get('/orders/:id', db.getOrderById)
app.post('/order', db.createOrder)
app.delete('/orders/:id', db.deleteOrder)
app.put('/orders/:id', db.updateOrder)
app.get('/orders/filter/status/:status', db.getOrdersByStatus)
app.get('/orders/filter/user/:id', db.getOrdersByUser)
app.get('/orders/track/:status', db.trackOrder)

Database part

1 Create Orders Table

CREATE TABLE public.orders
(
id integer NOT NULL DEFAULT nextval('orders_id_seq'::regclass),
naming character varying(150) COLLATE pg_catalog."default" NOT NULL,
sizes character varying(355) COLLATE pg_catalog."default" NOT NULL,
statuses character varying COLLATE pg_catalog."default",
quantity integer,
custid integer,
CONSTRAINT orders_pkey PRIMARY KEY (id)
)

TABLESPACE pg_default;

ALTER TABLE public.orders
OWNER to postgres;

2 Create Users Table

CREATE TABLE public.users
(
address character varying COLLATE pg_catalog."default",
name character varying COLLATE pg_catalog."default",
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
CONSTRAINT users_pkey PRIMARY KEY (id)
)

TABLESPACE pg_default;

ALTER TABLE public.users
OWNER to postgres;

About

Node.js Express API for a pizza delivery POC with POSTGRES

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published