Medical Departures Test

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

URL:- https://medical-departures-test.onrender.

com/swagger/
To check if the api is working :- https://medical-departures-test.onrender.com/ping

Github link:- https://github.com/yisacc/medical-departures-test

I have expanded the README.md with information on the environment setup and how to run
the API locally.

Here is the .env file that you need to use to run it locally

PORT=3000
SECRET=jkjkjkjkjkjjkjjuhbbdd
saltRounds= 10
DATABASE_URL=
postgres://yisacc:cTVuSAng8DMv1ImdkktB2gpDDVBJgSMN@dpg-cfufltda499030bdqbng-a.oregon-p
ostgres.render.com/medical_departues_test

To connect to the database and run a query locally, use the database url. I connected locally to
the database using DBeaver.

Remaining things/futures

The documentation for Swagger is still lacking; I'll update it the following day. Unit tests and
integration tests are also still unfinished. I will add both tomorrow and get back to you; please
contact me with any feedback or questions.

Instead of using methods from the object relational mapping tool, I wrote RAW queries to show
my SQL query abilities.

The SQL queries I used to create the tables are listed below. Due to the short time frame and
the desire to avoid a broad scope, they currently do not include migrations or seeders.

CREATE TABLE IF NOT EXISTS public.blogs(


id SERIAL NOT NULL,
title VARCHAR NOT NULL,
author VARCHAR NOT NULL,
url VARCHAR NULL,
created_by integer NOT NULL,
created_date timestamp without time zone NOT NULL DEFAULT timezone('UTC'::text,
now()),
modified_by integer NULL,
modified_date timestamp without time zone NULL,
deleted boolean NOT NULL DEFAULT false,
deleted_by integer NULL,
deleted_date timestamp without time zone NULL,
CONSTRAINT pk_blogs PRIMARY KEY (id),
CONSTRAINT ak_blogs UNIQUE (title)
)

CREATE TABLE IF NOT EXISTS public.users(


id SERIAL NOT NULL,
name VARCHAR NOT NULL,
username VARCHAR NOT NULL,
hashpass VARCHAR NOT NULL,
created_by integer NOT NULL,
created_date timestamp without time zone NOT NULL DEFAULT timezone('UTC'::text,
now()),
modified_by integer NULL,
modified_date timestamp without time zone NULL,
deleted boolean NOT NULL DEFAULT false,
deleted_by integer NULL,
deleted_date timestamp without time zone NULL,
CONSTRAINT pk_users PRIMARY KEY (id),
CONSTRAINT ak_users UNIQUE (username)
)

CREATE TABLE IF NOT EXISTS public.user_blogs(


id SERIAL NOT NULL,
id_user INTEGER NOT NULL,
id_blog INTEGER NOT NULL,
CONSTRAINT pk_user_blogs_id PRIMARY KEY (id),
CONSTRAINT fk_user_blogs_user_pk FOREIGN KEY (id_user) REFERENCES users (id),
CONSTRAINT fk_user_blog_blog_pk FOREIGN KEY (id_blog) REFERENCES blogs (id),
CONSTRAINT uk_user_blogs UNIQUE (id_user, id_blog)
)

You might also like