@3sixty/node 0.0.0-stage → 0.20.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +34 -2
  3. package/bin/index.js +4 -0
  4. package/dist/locales/en.json +18011 -0
  5. package/docs/changelog.md +0 -0
  6. package/docs/commands/bootstrap-dev.md +51 -0
  7. package/docs/commands/help.md +61 -0
  8. package/docs/commands/identity-create.md +67 -0
  9. package/docs/commands/identity-import.md +37 -0
  10. package/docs/commands/identity-list.md +31 -0
  11. package/docs/commands/identity-remove.md +46 -0
  12. package/docs/commands/identity-resolve.md +38 -0
  13. package/docs/commands/identity-verifiable-credential-create.md +58 -0
  14. package/docs/commands/identity-verification-method-create.md +55 -0
  15. package/docs/commands/identity-verification-method-import.md +46 -0
  16. package/docs/commands/node-identity-get.md +31 -0
  17. package/docs/commands/node-identity-set.md +36 -0
  18. package/docs/commands/node-org-id-get.md +32 -0
  19. package/docs/commands/node-org-id-set.md +37 -0
  20. package/docs/commands/org-users-list.md +40 -0
  21. package/docs/commands/tenant-create.md +55 -0
  22. package/docs/commands/tenant-get.md +34 -0
  23. package/docs/commands/tenant-import.md +46 -0
  24. package/docs/commands/tenant-list-by-org.md +34 -0
  25. package/docs/commands/tenant-list.md +31 -0
  26. package/docs/commands/tenant-org-alias-remove.md +39 -0
  27. package/docs/commands/tenant-org-id-set.md +39 -0
  28. package/docs/commands/tenant-remove.md +34 -0
  29. package/docs/commands/tenant-update.md +46 -0
  30. package/docs/commands/user-create.md +73 -0
  31. package/docs/commands/user-get.md +43 -0
  32. package/docs/commands/user-remove.md +43 -0
  33. package/docs/commands/user-update-password.md +58 -0
  34. package/docs/commands/user-update.md +58 -0
  35. package/docs/commands/vault-key-create.md +58 -0
  36. package/docs/commands/vault-key-import.md +43 -0
  37. package/docs/commands/vault-key-remove.md +37 -0
  38. package/docs/commands/vault-key-update.md +40 -0
  39. package/docs/configuration.md +234 -0
  40. package/docs/deployment-docker.md +142 -0
  41. package/docs/deployment-ec2.md +193 -0
  42. package/docs/deployment.md +4 -0
  43. package/docs/open-api/spec.json +24802 -0
  44. package/docs/usage.md +239 -0
  45. package/locales/en.json +1 -0
  46. package/package.json +39 -5
  47. package/src/index.js +12 -0
@@ -0,0 +1,193 @@
1
+ # Node Deployment Amazon AWS EC2
2
+
3
+ ## Amazon AWS EC2 Instance
4
+
5
+ To run the server on an AWS EC2 instance follow the steps below:
6
+
7
+ First follow one of the many online guides to create your EC2 instance with the ability to connect to it in terminal mode.
8
+
9
+ Network requirements are for the `https` port to be open to any address range i.e. `0.0.0.0`.
10
+
11
+ You should alias a domain name to the IP address of the instance e.g. `twin-node-api.example.com` using your DNS provider e.g. Cloudflare.
12
+
13
+ ## Install Git
14
+
15
+ For retrieving the code from the repo.
16
+
17
+ ```shell
18
+ sudo yum install git -y
19
+ git -version
20
+ ```
21
+
22
+ ## Install NVM and Node
23
+
24
+ For building and running the application.
25
+
26
+ ```shell
27
+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
28
+ nvm install 20
29
+ node -v
30
+ ```
31
+
32
+ ## Install nginx
33
+
34
+ To serve the app through an https reverse proxy.
35
+
36
+ ```shell
37
+ sudo yum install nginx -y
38
+ nginx -v
39
+ ```
40
+
41
+ ## Configuring nginx
42
+
43
+ We need to configure nginx to use the certificate and reverse proxy https traffic to the node.
44
+
45
+ ```shell
46
+ sudo nano /etc/nginx/nginx.conf
47
+ ```
48
+
49
+ The configuration should be along the lines of:
50
+
51
+ ```shell
52
+ server {
53
+ listen 80;
54
+ server_name twin-node-api.example.com;
55
+
56
+ # Redirect all traffic
57
+ return 301 https://$server_name$request_uri;
58
+ }
59
+
60
+ server {
61
+ listen [::]:443 ssl ipv6only=on;
62
+ listen 443 ssl;
63
+
64
+ server_name twin-node-api.example.com;
65
+
66
+ ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
67
+ ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
68
+
69
+ location / {
70
+ # Redirect the https traffic to the node instance
71
+ proxy_pass http://localhost:3000;
72
+ proxy_set_header Host $host;
73
+ proxy_set_header X-Real-IP $remote_addr;
74
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
75
+ proxy_set_header X-Forwarded-Proto $scheme;
76
+ }
77
+
78
+ location /socket {
79
+ # Redirect the wss traffic to the node instance
80
+ proxy_pass http://localhost:3000;
81
+ proxy_set_header Host $host;
82
+ proxy_set_header Upgrade $http_upgrade;
83
+ proxy_set_header Connection "upgrade";
84
+ }
85
+ }
86
+ ```
87
+
88
+ Once configured you can restart nginx with `sudo systemctl restart nginx`
89
+
90
+ Run `sudo systemctl enable nginx` to auto start the server on instance startup.
91
+
92
+ ## Building the server
93
+
94
+ We clone the repo, build it and then make a copy of the relevant .env file.
95
+
96
+ ```shell
97
+ git clone https://github.com/3sixtyglobal/node.git
98
+ cd apps
99
+ npm install
100
+ npm run dist
101
+ cd apps/node
102
+ cp .env.example-local-entity-storage .env
103
+ ```
104
+
105
+ The .env file can be modified to suit your own use case. For example to set the location for the storage.
106
+
107
+ ```shell
108
+ TWIN_STORAGE_FILE_ROOT="/home/ec2-user/twin-node/"
109
+ ```
110
+
111
+ ## Bootstrapping the server
112
+
113
+ You can now bootstrap the server, this will initialise all the required services and generate an initial configuration file. You should take note of the information in the logging as it will display information such as node admin passwords which will only be displayed once.
114
+
115
+ ```shell
116
+ node ./dist/es/index.js
117
+ ```
118
+
119
+ You should also now be able to access the server at `https://twin-node-api.example.com`
120
+
121
+ ## Configure the server to restart with server
122
+
123
+ We now need to install the server as a service, so that after any reboot it will continue to run.
124
+
125
+ Stop the server with `Ctrl-C`.
126
+
127
+ Create a service file e.g. `twin-node.service`
128
+
129
+ You might need to modify the location for the node version, you can find this out using `whereis node`
130
+
131
+ ```shell
132
+ [Unit]
133
+ Description=3Sixty Node
134
+ After=network.target
135
+
136
+ [Service]
137
+ ExecStart=/home/ec2-user/.nvm/versions/node/v20.16.0/bin/node /home/ec2-user/twin-node/apps/twin-node/dist/es/index.js
138
+ Restart=always
139
+ User=ec2-user
140
+ Group=ec2-user
141
+ Environment=PATH=/usr/bin:/usr/local/bin
142
+ Environment=NODE_ENV=production
143
+ WorkingDirectory=/home/ec2-user/twin-node/apps/twin-node/
144
+
145
+ [Install]
146
+ WantedBy=multi-user.target
147
+ ```
148
+
149
+ Reload systemd and start the service.
150
+
151
+ ```shell
152
+ sudo systemctl daemon-reload
153
+ sudo systemctl enable ./twin-node.service
154
+ sudo systemctl start twin-node.service
155
+ ```
156
+
157
+ To check the status of the service.
158
+
159
+ ```shell
160
+ sudo systemctl status twin-node.service
161
+ ```
162
+
163
+ or
164
+
165
+ ```shell
166
+ sudo journalctl -u twin-node | tail
167
+ ```
168
+
169
+ ## Upgrade EC2 Instance
170
+
171
+ To upgrade a previous installation on an EC2 instance with the latest version.
172
+
173
+ ```shell
174
+ sudo systemctl stop twin-node.service
175
+ cd apps
176
+ git reset --hard
177
+ git pull
178
+ npm i
179
+ npm run dist
180
+ cd apps/node
181
+
182
+ # Update any env vars if necessary
183
+ # nano .env
184
+
185
+ # If you want to start from clean configuration you should remove the databases manually
186
+ # and also remove the engine-state file
187
+ # rm /home/ec2-user/twin-node/engine-state.json
188
+
189
+ # To perform a test run before launching the service permanently
190
+ # npm run start
191
+
192
+ sudo systemctl start twin-node.service
193
+ ```
@@ -0,0 +1,4 @@
1
+ # Node Deployment
2
+
3
+ - [Docker](./deployment-docker.md) - Guide to deploying with docker.
4
+ - [Amazon AWS EC2](./deployment-ec2.md) - Guide to deploying with Amazon AWS EC2.