https://github.com/codebanesr/anywhr-backend
Find your travel destinations, from famous movie spot
https://github.com/codebanesr/anywhr-backend
Last synced: 4 months ago
JSON representation
Find your travel destinations, from famous movie spot
- Host: GitHub
- URL: https://github.com/codebanesr/anywhr-backend
- Owner: codebanesr
- Created: 2019-12-25T16:58:21.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-03T11:24:25.000Z (about 3 years ago)
- Last Synced: 2025-01-20T11:29:28.318Z (over 1 year ago)
- Language: TSQL
- Size: 6.37 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# anywhr-backend
Find your travel destinations, from famous movie spot
# Documentation Coverage for frontend
http://3.1.20.178:3000/documentation
#### Entry point
` app.js is the entry point of the application, however when running in production run bin/www`
#### Features
>Implemented real time search functionality using rxjs's debounce, distinct until changed operator
>on angular form's input element, which exposes an event that is fired everytime value of input box
>changes
>
> Movie Location and definition from wiki pages
> On clicking any one of the locations, the app will look for that title on wikipedia and populate
> results on the grey area
>
>Pagination implementation in angular
>
Example
` http://3.1.20.178:3000/movie?title=180 `
### Running locally
`git clone https://github.com/shanurrahman/anywhr-backend.git`
`cd anywhr-backend`
`npm install`
`browse localhost:3000`
### To improve upon the frontend
`cd ..`
`git clone https://github.com/shanurrahman/anywhr-frontend.git`
`npm run compodoc`
`ng build --prod`
Now run your backend server
`cd ../anywhr-backend && npm start`
goto : localhost:3000
Note:
* For this process to run both anywhr-frontend and backend should be in the same folder
### Using Docker
From the root directory
`docker build --tag="anywhr:anywhr" ./`
docker image ls => find the id of your image and do a `docker run -d --restart=always -p 3000:3000 image_name:version`
In our case it is going to be `docker run -d --restart=always -p 3000:3000 `
goto `localhost:3000`
* you can also use the image id if tag was not created
> Building an image from dockerfile
>
> Running docker container from that image
>
>
>
### Production build instructions
update the .env file, your db credentials, put NODE_ENV=development to enable full logging
* You may use this docker image inside a docker stack and use it with production but that will require
* docker and docker compose installation first, for an app of this size I would not actually recommend
* going with that approach, Here I am using pm2 and pm2-logrotate for the same purpose
##### npm install
##### Install pm2 globally
```
$ pm2 stop
$ pm2 restart
$ pm2 delete
```
`$ sudo pm2 start bin/www`
##### Install pm2 logrotate, prevents memory leak issues on the server
`pm2 install pm2-logrotate`
### Notes to the reviewer [Handling memory leaks in postgres]
> For one line postgres statements that dont require a transaction block we can simply use pg pools
> that way we dont have to deal with closing the database queries
> More on it here
> https://node-postgres.com/api/pool
#### Database tables
```
create table movie
(
title varchar(256) not null
constraint movie_pkey
primary key,
release_year varchar(128),
fun_facts varchar(339),
production_company varchar(256) default 'N/A'::character varying,
distributor varchar(256),
director varchar(79),
writer varchar(49),
actor_1 varchar,
actor_2 varchar,
actor_3 varchar
);
```
```
create table movie_location
(
title varchar(45) not null,
locations varchar(110)
);
```