Commentami - React Comments system (Google doc like)
Commentami React components requires React 16.3+.
To build the frontend you can run the following command
cd packages/commentami-react-components
npm run build
This will place in the dist
folder the compiled components.
If you want to see them in action you can start the demo from packages/commentami-demo
cd packages/commentami-demo
npm run watch
To save comments on the server and have an example of sockets and HTTP REST apis you will need to start the server as described below.
Commentami requires Node.js 8.9.0+.
The Hapi plugin and server packages require Hapi 17+.
To install all the dependecies you can run
npm install
in the root of the project.
Commentami requires an instance of Postgres (version 9.5+) and redis to function correctly. For simplicity, a preconfigured docker-compose
file has been provided. To run it:
docker-compose up postgres redis
- Note: Ensure you are using the latest version of Docker for (Linux/OSX/Windows)
- Note: Commentami needs PostgreSQL >= 9.5
The initial tables can be created by executing:
npm run pg:init
This command will also migrate the tables to their most recent structure.
We use postgrator
for database migrations. You can find the sql files in the packages/commentami-backend-core/database/migrations
folder. To run the migrations manually:
npm run pg:migrate // either in the root folder or in the `commentami-backend-core` folder
As the Postgresql docker container has its 5432 port forwarded on the local machine the database can be accessed with pgAdmin.
To access the database using the pgAdmin you have to fill in also the container IP beside the database names and access credentials. The container IP can be seen with docker ps
. Use IP 127.0.0.1 and use postgres as username/password to connect to database server.
To run tests
run test
To run the linter
npm run lint
The following configuration is just for local development/demo, it is not for production environments
If you don't want to run all services and the server on your machine, you can use docker.
To setup the images/containers you should have docker installed locally and then run:
docker-compose build
This should produce something like the following output
# docker-compose build
postgres uses an image, skipping
Building app
Step 1/4 : FROM node:8.11.2-alpine
---> 348d500a6d80
Step 2/4 : WORKDIR /usr/app
---> Using cache
---> 52dc46987fdb
Step 3/4 : COPY . .
---> 4014adb5d79e
Step 4/4 : RUN npm install --quiet
---> Running in 889e76abe927
up to date in 2.931s
Removing intermediate container 889e76abe927
---> ca0ed1c45dae
Successfully built ca0ed1c45dae
Successfully tagged server_app:latest
To run the backend app you can now use the following command
docker-compose up
Run
docker ps
and take the name of your app
container
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e7e59d3c637b commentami_app "npm run start" Less than a second ago Up 10 seconds 0.0.0.0:8080->8080/tcp commentami_app_1
a311174dcadd postgres:10 "docker-entrypoint.s…" Less than a second ago Up 12 seconds 0.0.0.0:5432->5432/tcp commentami_postgres_1
172f656dc618 redis:alpine "docker-entrypoint.s…" Less than a second ago Up 11 seconds 0.0.0.0:6379->6379/tcp commentami_redis_1
and then tun
docker exec commentami_app_1 npm run pg:init
To run the tests you can use
docker exec commentami_app_1 npm test
Note: the server running on docker does not reaload the code if you change it.
Once you have a database running and all the tables set up, you can try to run curl
for the list endpoint
curl http://localhost:8080/comments\?resource\=\test
the output should be something like
{"comments":[],"total":"0","limit":100,"offset":0}
Copyright nearForm Ltd 2018. Licensed under Apache 2.0 license.
We have a contributing guide and a code of conduct.