Skip to content

wojciechszmelczerczyk/express-manage-birthday-api

Repository files navigation

Birthday party management

Description

Simple REST API for birthday party management.

Table of contents

Techstack

  • JavaScript
  • Express
  • PostgreSQL

Requirements

  • install node
  • install postgresql

To run app

Clone repository

git clone https://github.com/wojciechszmelczerczyk/express-manage-birthday-app

Navigate to project folder

cd /express-manage-birthday-app

Install dependencies

npm i

Run API

npm run dev

Env setup

Create .env file and setup variables.

# server port number
PORT=

# db user
DB_USER=

# db password
DB_PASSWORD=

# db name
DB_NAME=

# db host
DB_HOST=

# db port
DB_PORT=

# jwt expiration time in milliseconds
JWT_EXPIRATION_TIME=

# jwt secret string
JWT_SECRET=

# date yyyy:mm:dd hh:mm:ss format
BIRTHDAY_DATE=yyyy:mm:dd hh:mm:ss

# string data
BIRTHDAY_PLACE=

# name for invitation file
FILE_NAME=invitation.txt

Setup database

Login to postgresql as superuser.

In order to setup database run following script:

CREATE DATABASE birthday_party
    WITH
    OWNER = postgres
    ENCODING = 'UTF8'
    LC_COLLATE = 'en_US.UTF-8'
    LC_CTYPE = 'en_US.UTF-8'
    TABLESPACE = pg_default
    CONNECTION LIMIT = -1;

Create table

CREATE TABLE guest (
	guest_id serial PRIMARY KEY,
	name VARCHAR ( 50 )  NOT NULL,
	surname VARCHAR ( 50 ) NOT NULL,
	uuid VARCHAR ( 50 )  NOT NULL,
  "isOwner" BOOLEAN DEFAULT FALSE,
  status VARCHAR ( 50 )  DEFAULT NULL,
	modified_status TIMESTAMP DEFAULT NULL

);

Change in database one of the user isOwner field to true in order to use admin endpoints.

UPDATE guest
SET "isOwner" = true
WHERE guest_id = 1;

Setup Postman environment

Import file included in project.

Application Architecture

Application implements REST API architecture style

Database Architecture

Guest entity

Endpoints

Method Endpoint
POST /guest/register
POST /guest/auth
DELETE /guest/logout
PUT /guest/change-status
GET /guest/download-invitation
GET /owner/list/accepted
GET /owner/list/no-feedback
GET /owner/list/denied

Releases

No releases published

Packages

No packages published