Git Product home page Git Product logo

tc-project-service's Introduction

Topcoder Projects Service

Microservice to manage CRUD operations for all things Projects.

Note : Steps mentioned below are best to our capability as guide for local deployment, however, we expect from contributor, being a developer, to resolve run-time issues (e.g. OS and node version issues etc), if any.

Local Development

  • We use docker-compose for running dependencies locally. Instructions for Docker compose setup - https://docs.docker.com/compose/install/

  • Nodejs 8.9.4 - consider using nvm or equivalent to manage your node version

  • Install libpg

  • Install node dependencies npm install

  • Start local services

> cd local/
~/Projects/tc-projects-service/local
> docker-compose up

Copy config/sample.local.js as config/local.js, update the properties and according to your env setup

Database

Once you start your PostgreSQL database through docker, it will create a projectsdb. To create tables - note this will drop tables if they already exist

NODE_ENV=development npm run sync:db

Redis

Docker compose command will start a local redis instance as well. You should be able to connect to this instance using url $(docker-machine ip):6379

Elasticsearch

Docker compose includes elasticsearch instance as well. It will open ports 9200 & 9300 (kibana)

Sync indices and mappings

There is a helper script to sync the indices and mappings with the elasticsearch.

Run npm run sync:es from the root of project to execute the script.

NOTE: This will first clear all the indices and than recreate them. So use with caution.

NOTE: In production these dependencies / services are hosted & managed outside tc-projects-service.

Kafka

Kafka must be installed and configured prior starting the application. Following topics must be created:

notifications.connect.project.updated
notifications.connect.project.files.updated
notifications.connect.project.team.updated
notifications.connect.project.plan.updated
notifications.connect.project.topic.created
notifications.connect.project.topic.updated
notifications.connect.project.post.created
notifications.connect.project.post.edited

New Kafka related configuration options has been introduced:

"kafkaConfig": {
    "hosts": List of Kafka brokers. Default: localhost: 9092
    "clientCert": SSL certificate
    "clientCertKey": Certificate key
}

Environment variables:

  • KAFKA_HOSTS - same as "hosts"
  • KAFKA_CLIENT_CERT - same as "clientCert"
  • KAFKA_CLIENT_CERT_KEY - same as "clientCertKey"

Test

Each of the individual modules/services are unit tested.

To run unit tests run npm run test from root of project.

While tests are being executed the NODE_ENV environment variable has a value test and config/test.js configuration is loaded. The default test configuration refers to projectsdb_test postgres database. So make sure that this database exists before running the tests. Since we are using docker-compose for local deployment change local/docker-compose.yaml postgres service with updated database name and re-create the containers.

// stop already executing containers if any
docker-compose stop -t 1
// clear the containers
docker-compose rm -f
// re-run the services with build flag
docker-compose up --build

JWT Authentication

Authentication is handled via Authorization (Bearer) token header field. Token is a JWT token. Here is a sample token that is valid for a very long time for a user with administrator role.

eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJhZG1pbmlzdHJhdG9yIl0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJwc2hhaDEiLCJleHAiOjI0NjI0OTQ2MTgsInVzZXJJZCI6IjQwMTM1OTc4IiwiaWF0IjoxNDYyNDk0MDE4LCJlbWFpbCI6InBzaGFoMUB0ZXN0LmNvbSIsImp0aSI6ImY0ZTFhNTE0LTg5ODAtNDY0MC04ZWM1LWUzNmUzMWE3ZTg0OSJ9.XuNN7tpMOXvBG1QwWRQROj7NfuUbqhkjwn39Vy4tR5I

It's been signed with the secret 'secret'. This secret should match your entry in config/local.js. You can generate your own token using https://jwt.io

Local Deployment

Build image: docker build -t tc_projects_services . Run image: docker run -p 3000:3000 -i -t -e DB_HOST=172.17.0.1 tc_projects_services You may replace 172.17.0.1 with your docker0 IP.

You can paste swagger.yaml to swagger editor or import postman.json and postman_environment.json to verify endpoints.

Deploying without docker

If you don't want to use docker to deploy to localhost. You can simply run npm run start from root of project. This should start the server on default port 3000.

tc-project-service's People

Contributors

architectt1 avatar chq-matteo avatar coderreview avatar colinh84 avatar cwdcwd avatar gondzo avatar huangqun avatar maxceem avatar mdesiderio avatar mhikeo avatar morehappiness avatar mtwomey avatar narekcat avatar ngoctay avatar parthshah avatar phoenix303 avatar rishirajsahu avatar sachin-maheshwari avatar shawnduxy avatar thiyagu06 avatar

Watchers

 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.