2021-01-04 08:26:39 -05:00
|
|
|
# Getting started
|
2019-03-31 10:02:05 -04:00
|
|
|
|
2019-03-31 12:57:26 -04:00
|
|
|
## Preparing for running the code
|
|
|
|
|
2022-05-18 04:31:02 -04:00
|
|
|
**Notice:** *There are [specialised instructions for docker](../setup/docker.md) if you prefer running code this way!*
|
2019-03-31 12:57:26 -04:00
|
|
|
|
2020-11-14 16:24:44 -05:00
|
|
|
1. Clone the repository with `git clone https://github.com/hedgedoc/hedgedoc.git hedgedoc-server`
|
2019-03-31 14:10:32 -04:00
|
|
|
(cloning is the preferred way, but you can also download and unzip a release)
|
2020-07-01 05:52:17 -04:00
|
|
|
|
2019-03-31 12:57:26 -04:00
|
|
|
2. Enter the directory and run `bin/setup`, which will install npm dependencies
|
|
|
|
and create configs. The setup script is written in Bash, you would need bash
|
|
|
|
as a prerequisite.
|
2020-07-01 05:52:17 -04:00
|
|
|
|
2021-01-04 07:07:44 -05:00
|
|
|
3. Setup the [config file](../configuration.md) or set up
|
|
|
|
[environment variables](../configuration.md).
|
2019-03-31 12:57:26 -04:00
|
|
|
|
|
|
|
## Running the Code
|
|
|
|
|
2020-07-02 11:22:52 -04:00
|
|
|
Now that everything is in place, we can start HedgeDoc:
|
2019-03-31 12:57:26 -04:00
|
|
|
|
2020-07-01 05:52:17 -04:00
|
|
|
1. `yarn run build` will build the frontend bundle. It uses webpack to do that.
|
|
|
|
2. Run the server with `node app.js`
|
2019-03-31 12:57:26 -04:00
|
|
|
|
|
|
|
## Running the Code with Auto-Reload
|
|
|
|
|
|
|
|
The commands above are fine for production, but you're a developer and surely
|
|
|
|
you want to change things. You would need to restart both commands whenever you
|
|
|
|
change something. Luckily, you can run these commands that will automatically
|
|
|
|
rebuild the frontend or restart the server if necessary.
|
|
|
|
|
|
|
|
The commands will stay active in your terminal, so you will need multiple tabs
|
|
|
|
to run both at the same time.
|
|
|
|
|
2020-07-01 05:52:17 -04:00
|
|
|
1. Use `yarn run dev` if you want webpack to continuously rebuild the frontend
|
2019-03-31 12:57:26 -04:00
|
|
|
code.
|
|
|
|
|
2020-07-01 05:52:17 -04:00
|
|
|
2. To auto-reload the server, the easiest method is to install [nodemon](https://www.npmjs.com/package/nodemon)
|
|
|
|
and run `nodemon --watch app.js --watch lib --watch locales app.js`.
|
2019-03-31 12:57:26 -04:00
|
|
|
|
2019-03-31 10:02:05 -04:00
|
|
|
## Structure
|
|
|
|
|
2019-03-31 12:57:26 -04:00
|
|
|
The repository contains two parts: a server (backend) and a client (frontend).
|
|
|
|
most of the server code is in `/lib` and most of the client code is in `public`.
|
|
|
|
|
2019-03-31 10:02:05 -04:00
|
|
|
```text
|
2020-07-02 11:22:52 -04:00
|
|
|
hedgedoc-server/
|
2019-03-31 10:02:05 -04:00
|
|
|
├── docs/ --- documentation
|
2019-03-31 12:57:26 -04:00
|
|
|
├── lib/ --- server code
|
|
|
|
├── test/ --- test suite
|
|
|
|
└── public/ --- client code
|
2019-03-31 10:02:05 -04:00
|
|
|
├── css/ --- css styles
|
|
|
|
├── docs/ --- default documents
|
|
|
|
├── js/ --- js scripts
|
|
|
|
├── vendor/ --- vendor includes
|
|
|
|
└── views/ --- view templates
|
|
|
|
```
|