Skip to content

Commit 6a25bcf

Browse files
authored
Merge pull request #6 from graycraft/bugfix/2
Add proxy port, describe requirements and usage
2 parents 5a8ddb9 + feb5f2d commit 6a25bcf

File tree

7 files changed

+95
-8
lines changed

7 files changed

+95
-8
lines changed

.env.development

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
HOSTNAME=localhost
22
NODE_ENV=development
3-
PORT=3000
3+
NODE_NO_WARNINGS=1
4+
NODE_OPTIONS=--experimental-vm-modules
5+
PORT=8000
6+
PORT_PROXY=80

.env.production

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
HOSTNAME=graycraft.me
22
NODE_ENV=production
3+
NODE_NO_WARNINGS=1
4+
NODE_OPTIONS=--experimental-vm-modules
35
PORT=4000
6+
PORT_PROXY=443

README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,84 @@
11
# Graycraft
22

33
Client and server logic of the [graycraft.me](https://graycraft.me) website.
4+
5+
## Requirements
6+
7+
Bash ^5.0.0:
8+
9+
```bash
10+
$ bash --version
11+
GNU bash, version 5.1.16(1)-release
12+
```
13+
14+
Node.js 22.11.0:
15+
16+
```bash
17+
$ node -v
18+
v22.11.0
19+
```
20+
21+
NPM 10.9.0:
22+
23+
```bash
24+
$ npm -v
25+
10.9.0
26+
```
27+
28+
## Setup
29+
30+
### Debian / Ubuntu
31+
32+
```bash
33+
$ sudo apt-get install build-essential libcairo2-dev libgif-dev libjpeg-dev libpango1.0-dev librsvg2-dev
34+
```
35+
36+
<https://www.npmjs.com/package/canvas>
37+
38+
### Git
39+
40+
Clone the Git repository:
41+
42+
```bash
43+
$ git clone <gh|https|ssh>graycraft/me.git
44+
```
45+
46+
### Node.js
47+
48+
Use appropriate Node.js version:
49+
50+
```bash
51+
$ nvm use
52+
```
53+
54+
### NPM
55+
56+
Install modules for usage:
57+
58+
```bash
59+
$ npm i --production
60+
```
61+
62+
Install modules for development:
63+
64+
```bash
65+
$ npm i
66+
```
67+
68+
### Environment
69+
70+
Optionally `NODE_NO_WARNINGS` can be exported from `.env` file to silence process warnings regarding experimental features.
71+
72+
This command also enables `--experimental-vm-modules` option for running [Jest with ESM](https://jestjs.io/docs/ecmascript-modules):
73+
74+
```bash
75+
$ export $(cat .env.production | xargs)
76+
```
77+
78+
## Usage
79+
80+
Run production server script:
81+
82+
```bash
83+
$ npm start
84+
```

app.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ app.use('/', routerIndex);
4444
* Catch 404 and forward to error handler.
4545
*/
4646
app.use(((req, res, next) => {
47-
const { HOSTNAME, PORT } = process.env,
48-
host = HOSTNAME + ':' + PORT,
47+
const { HOSTNAME, PORT_PROXY } = process.env,
48+
host = HOSTNAME + ':' + PORT_PROXY,
4949
cssBuffer = nodeFs.readFileSync('public/stylesheets/style.css'),
5050
css = String(cssBuffer),
5151
{ color: colorQuery, size: sizeQuery } = req.query,

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graycraft.me",
3-
"version": "0.5.1-alpha",
3+
"version": "0.5.2-alpha",
44
"description": "Client and server logic of the graycraft.me website.",
55
"main": "index.mts",
66
"private": true,

routes/index.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import graycraft from '../source/graycraft.umd.js';
1717

1818
const router = express.Router(),
1919
indexHandler: RequestHandler = (req, res) => {
20-
const { HOSTNAME, PORT } = process.env,
21-
host = HOSTNAME + ':' + PORT,
20+
const { HOSTNAME, PORT_PROXY } = process.env,
21+
host = HOSTNAME + ':' + PORT_PROXY,
2222
cssBuffer = nodeFs.readFileSync('public/stylesheets/style.css'),
2323
scriptBuffer = nodeFs.readFileSync('public/javascripts/graycraft.umd.js'),
2424
css = String(cssBuffer),

0 commit comments

Comments
 (0)