项目作者: mihalskiy

项目描述 :
Node, Express and Postgres (using Sequelize and ElasticSearch)
高级语言: JavaScript
项目地址: git://github.com/mihalskiy/node-telephone-user-search.git
创建时间: 2018-03-05T15:52:47Z
项目社区:https://github.com/mihalskiy/node-telephone-user-search

开源协议:MIT License

下载


This repo houses code for search the contacts (using Sequelize and PostgreSQL)”

  1. $ NODE_ENV=aws-dev npm run db:init
  2. $ NODE_ENV=aws-dev npm start

If you dont have install node-js, please go this link https://nodejs.org

Elasticsearch Setup for Mac

I am installing on the Mac. So type the following command in your terminal to install Elasticsearch via homebrew.

  1. brew install elasticsearch

It will install it and now start the services using the following command.

  1. brew services start elasticsearch

PostgreSQL Setup for LINUX

You need to add the latest PostgreSQL repository for the latest version.

sudo add-apt-repository "deb https://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main"

Update and Install PostgreSQL 9.6:

  1. sudo apt-get update
  2. sudo apt-get install postgresql-9.6

Default postgres super user and postgres database is created. You need to set a password for the postgres super user.

  1. ubuntu@:~$ sudo passwd postgres
  2. Enter new UNIX password:****
  3. Retype new UNIX password:****
  4. passwd: password updated successfully

If service is not started, you can start the PostgreSQL service.

sudo service postgresql start

Connect PostgreSQL server using postgres user:

  1. ubuntu@:~$ su postgres
  2. Password:****

Create a sample database:

createdb database_name

Connect to that database:

psql -d database_name

Config Setup

go to directory /you_project/server/config and open file config.json and change settings under your database

  1. {
  2. "development": {
  3. "username": "you_DATABASE_username",
  4. "password": "you_DATABASE_password",
  5. "database": "you_DATABASE_name",
  6. "host": "127.0.0.1",
  7. "port": 5432,
  8. "dialect": "postgres"
  9. },
  10. }

Project Setup

  1. Use command npm install for install dependices
  2. Now try running the application by executing npm run start:dev
    and visiting http://localhost:8000.
    You should see {“message”:”Welcome to the beginning of nothingness.”}
  3. Running the migrations to do this, we run the following command: sequelize db:migrate
  4. You can seed your database with this data by running this sequelize-cli command: sequelize db:seed:all

under run project need use postmean or another application

for get contacts all names the saved under one phone number, use example query 127.0.0.1:8000/contact?phoneNumber=94

alt text

for save array contacts use post query which is listed below

alt text.

transfer request, name or last name or companyName and get the most matching phone numbers. Example query http://localhost:8000/contacts?phoneNumber=94&companyName=o

alt text.

Get a list of phone numbers with information (name, surname, companyName), by key. Example query http://localhost:8000/contacts

alt text.

  1. $ NODE_ENV=aws-dev npm run db:init
  2. $ NODE_ENV=aws-dev npm start
  3. $ sudo docker build -t getcontact .
  4. $ sudo docker run -e getcontact .

Have fun! smile