Configure TypeScript project references

Improvements:
- The common/ project is automatically built by dependent projects
- Building common/ in in the "prepare" script is thus no longer necessary
- Vite and server hot-reloading now work if files in common/ change
- Recompiling common after every change is done automatically
- Using "go to definition" now jumps to the .ts file rather than the .d.ts

Changes:
- Use TypeScript project references to refer to common/ from client/ and server/
- Set "composite" and "declarationMap" options in common/tsconfig.json
    - See https://www.typescriptlang.org/docs/handbook/project-references.html
- Use tsc --build in order to build references automatically
- Replace nodemon and ts-node with ts-watch in server in order to use the new tsc --build mode
    - See https://github.com/TypeStrong/ts-node/issues/897#issuecomment-647035509
    - Remove now unneeded SIGUSR2 signal handler which was for nodemon
- Use tsc-watch before Vite in client in order for hot-reloading to work if common/ changes
- Update TypeScript version
- Add vite.config.node.json to be consistent with expected Vite project defaults

GitLab: #151
Change-Id: Id2f84fe45e44c4d8b4e6d3b324e1aee322c52df6
11 files changed
tree: f0d3f2811b6226790dc5ceb37a2da546de180307
  1. .hooks/
  2. client/
  3. common/
  4. server/
  5. .dockerignore
  6. .eslintrc.cjs
  7. .gitignore
  8. .gitmodules
  9. .gitreview
  10. .prettierrc.json
  11. docker-compose.yml
  12. Dockerfile
  13. Jenkinsfile
  14. package-lock.json
  15. package.json
  16. README.md
README.md

Jami-web

Jami-web is a web server that starts a Dameon on NodeJS express server and serve a React web client.

The first milestone is to allow user with LDAP credentials to connect to the account using JAMS service and start chatting with their contacts using instant messaging.

Next step will be to implement a video protocol such as WebRTC to allow audio and video calls from the users browser to another Jami contact allowing cross-platform communications.

Main dependencies

How to start the server

After building the Jami daemon you can use the following command to start the node js server using the LD_LIBRARY_PATH

LD_LIBRARY_PATH="${PWD}/daemon/src/.libs"

To build the dring.node Javascript interface to talk to the daemon api go to the daemon repo and use ./configure --with-nodejs then execute make -j4 to build the daemon

Create a symbolic link to jamid.node inside server/:

cd server
ln -s ../daemon/bin/nodejs/build/Release/jamid.node jamid.node

Then, start the servers:

# Install the package dependencies
npm install

# Start the client and backend servers
LD_LIBRARY_PATH="${PWD}/daemon/src/.libs" npm start

You may also start the servers individually:

npm start --workspace client
npm start --workspace server

How to build for production

# Build the client app and the server. The resulting files are available in `client/dist` and `server/dist` respectively
npm run build

# Preview the production build locally
npm run start:prod

Docker

You may run the web server in a Docker container. This will automatically build the daemon and do the necessary linking.

1. Build the daemon

cd daemon
docker build --build-arg config_args="--with-nodejs" -t jami-daemon .
cd ..

2. Build and run the web server and client

docker build --target development --tag jami-web .
docker run -it \
  -p 3001:3001 \
  -p 3000:3000 \
  -p 5000:5000 \
  --volume ${PWD}/client/src:/web-client/client/src \
  --volume ${PWD}/server/src:/web-client/server/src \
  --volume ${PWD}/client/.env.development:/web-client/client/.env.development \
  --volume ${PWD}/server/.env:/web-client/server/.env \
  jami-web

Using [docker-compose](docker run -p 3000:3000 -it jami-project)

This will use a Docker Volume to enable auto-refresh when you change a file.

# First build the daemon if necessary
docker-compose build jami-daemon

# Then build the project and start the container
docker-compose build
docker-compose up