Giter VIP home page Giter VIP logo

ph-locations's Introduction

Philippine Standard Geographic Code (PSGC) REST API

Star License Release

๐Ÿ“– API Documentation

The API Documentation can be found by accessing the url

http://localhost:6945/docs/index.html

Note: The host and port will change when you set a custom host and port in the build/app.env file.

๐Ÿ’ป Run locally

๐Ÿ“ Prerequisites

  1. git Installed in your system
  2. Docker Installed in your system
  3. golang-migrate/migrate Installed in your system
  4. ej-agas/psgc-publication-parser Installed in your system
  5. GNU Make (Optional)

๐Ÿ“ Steps

Clone the repository

git clone [email protected]:ej-agas/ph-locations.git && cd ph-locations

Copy .env.example and docker-compose.yaml.dist

cp build/app.env.example build/app.env
cp build/docker-compose.yaml.dist build/docker-compose.yaml

(Optional) Replace the default password of the PostgreSQL user in the build/app.env file you've just created.

POSTGRES_PASSWORD=SET_A_SECURE_PASSWORD

Run make docker

make docker

If you don't have GNU make installed in your system, run the following command

docker build -t ph-locations:latest . -f build/Dockerfile.dev && docker compose -f build/docker-compose.yaml up -d --build

Try to access the root path

curl localhost:6945

If you get the JSON below, then everything went well

{
  "status": 200,
  "message": "Philippine Standard Geographic Code (PSGC) REST API"
}

Enter the ph_locations_db container by running the command:

docker exec -it ph_locations_db bash

Inside the container, enter the PostgreSQL shell by running the command:

psql --user ph_locations_user --password -d postgres

Note: The shell will prompt for a password, use the POSTGRES_PASSWORD value in your build/app.env file

Once inside, execute a CREATE DATABASE SQL query.

CREATE DATABASE ph_locations_db;

Exit the PostgreSQL shell by running exit and also for the ph_locations_db container

exit

Run the migrations using golang-migrate/migrate

migrate -source file://migrations -database postgresql://ph_locations_user:YOUR_DATABASE_PASSWORD@localhost:5432/ph_locations_db?sslmode=disable up

Note: Change the YOUR_DATABASE_PASSWORD string in the command to the POSTGRES_PASSWORD value in your build/app.env file.

Run the PSGC publication parser

psgc-pub-parser parse publication_datafile.xlsx  --host localhost --port 5432 --db ph_locations_db --user ph_locations_user --password YOUR_DATABASE_PASSWORD

Note: Change the YOUR_DATABASE_PASSWORD flag value in the command to the POSTGRES_PASSWORD value in your build/app.env file.

ph-locations's People

Contributors

ej-agas avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.