# Installing Cryptomask Server

## Prerequisites

To run Cryptomask server you need the below prerequisites.

* Windows/Mac OS/Ubuntu Server with 4GB RAM
* Node JS Version 18.18.0
* PostgreSQL Version 15.4 (stable)

## Quickstart

Running the server is straightforward. To get started, configure the service application by updating the necessary values in the `.env` file.

{% code title=".env" %}

```bash
NODE_ENV=development
BACKEND_PORT=3001	
SECRET=SUPER_SECRET_TOKEN_NEVER_DISCLOSE	
DATABASE_URL="postgresql://<REPLACE_USERNAME>:<REPLACE_WITH_YOUR_POSTGRES_PASSWORD>@localhost:5432/cryptomask"
MORALIS_API_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJub25jZSI6IjNjNTBjYjQxLTExNTktNDgzNS1iZTU1LWMwMmUyNTNmOTAxMyIsIm9yZ0lkIjoiMzU0MTI2IiwidXNlcklkIjoiMzYzOTcwIiwidHlwZUlkIjoiN2EzYTE2YzItYTBjNS00Nzg5LWI1OGQtMjkyZmM4MjM5MGU0IiwidHlwZSI6IlBST0pFQ1QiLCJpYXQiOjE2OTI2ODI1MjUsImV4cCI6NDg0ODQ0MjUyNX0.i-2kfCVT0Jfw0USaSTTVM6eQg2pbrZMNO1YwplIObsY
```

{% endcode %}

{% hint style="info" %}
For the production release you need to changed `NODE_ENV=production`
{% endhint %}

{% hint style="info" %}
`postgres`  is the default username
{% endhint %}

* The `SECRET` is a password you choose, and it’s crucial to keep it highly confidential. This value is used to sign JWT tokens, ensuring the security of your application.&#x20;
* To obtain you your `MORALIS_API_KEY` from below link

{% embed url="<https://docs.moralis.com/2.0/web3-data-api/evm/get-your-api-key>" %}

## Installing Node JS

{% tabs %}
{% tab title="Linux" %}
Download and run the NodeSource setup script for Node.js 18

```bash
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
```

Install Node.js

```bash
sudo apt install -y nodejs
```

Verify installation

```bash
node -v
```

{% endtab %}

{% tab title="MAC OS" %}
Install Node JS Using Homebrew

```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

Install Node.js

```bash
brew install node@18
```

Verify the Installation

```bash
node -v
```

{% endtab %}

{% tab title="Windows" %}
Install Node JS using the Official Installer

**Download the Node.js Installer**:

* Go to the [Node.js official website](https://nodejs.org/).
* Click on the **"Previous Releases"** link to find version 18.8.0.
* Download the appropriate installer for your system (e.g., 64-bit MSI).

**Run the Installer**:

* Double-click the downloaded `.msi` file.
* Follow the installation wizard:
  * Accept the license agreement.
  * Choose the installation directory.
  * Enable the option to add Node.js to the PATH.
    {% endtab %}
    {% endtabs %}

## Installing Cryptomask Server dependencies

Open terminal in the root of the server script and run the below command to install project dependencies.

```bash
npm install
```

Migrate database

```bash
npx primsa migrate dev
```

To start development server, run

```bash
npm run dev
```

## Running in Production server

To run this backend service in a production environment you need to install PM2 and run the script as service. Follow below instruction for achieve this.&#x20;

Installing PM2 as global node module

```bash
npm install pm2 -g
```

And run below command to spin up the production server

```javascript
pm2 start app.config.json
```
