|
| 1 | +# TypeX |
| 2 | + |
| 3 | +A TypeScript based Image/File uploading server. Fast and Elegant. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +1. Prerequisites |
| 8 | + 1. Node |
| 9 | + 2. Common Databases |
| 10 | +2. Installation |
| 11 | + 1. Get the Source |
| 12 | + 2. Setting up configurations |
| 13 | + 1. Upload Size |
| 14 | + 2. Site Settings |
| 15 | + 3. Administrator user |
| 16 | + 4. Database configuration |
| 17 | + 5. Session Secret |
| 18 | + 6. Web server port |
| 19 | + 3. Example Config |
| 20 | + 4. Compiling Source |
| 21 | + 5. Running Compiled Source |
| 22 | + |
| 23 | +## Prerequisites |
| 24 | + |
| 25 | +Dependencies needed for running TypeX |
| 26 | + |
| 27 | +### Node & Typescript |
| 28 | + |
| 29 | +Node.JS is what runs the show, and you will need it before anything else. Install it [here](https://nodejs.org) |
| 30 | + |
| 31 | +Once Node is installed install Typescript by doing |
| 32 | + |
| 33 | +```sh |
| 34 | +npm i typescript -g |
| 35 | +``` |
| 36 | + |
| 37 | +Verify your installation by running these commands |
| 38 | + |
| 39 | +```sh |
| 40 | +tsc -v |
| 41 | +npm -v |
| 42 | +node -v |
| 43 | +``` |
| 44 | + |
| 45 | +They should all output something along the lines of |
| 46 | + |
| 47 | +```sh |
| 48 | +-> tsc -v |
| 49 | +Version 3.8.3 |
| 50 | +-> npm -v |
| 51 | +node 6.14.4 |
| 52 | +-> node -v |
| 53 | +v13.13.0 |
| 54 | +``` |
| 55 | + |
| 56 | +### Common Databases |
| 57 | + |
| 58 | +* MariaDB |
| 59 | +* MySQL |
| 60 | +* PostgreSQL |
| 61 | +* CockroachDB |
| 62 | +* Microsoft SQL Server |
| 63 | +* MongoDB (Coming soon!) |
| 64 | + |
| 65 | +(check out [this](https://github.com/typeorm/typeorm/blob/master/docs/connection-options.md) for all types, you will need to use a different ORM config later on, view [this](https://github.com/typeorm/typeorm/blob/master/docs/connection-options.md#common-connection-options) for every option, more on this on Database configuration setup step) |
| 66 | + |
| 67 | +## Installation |
| 68 | + |
| 69 | +Now that you have considered what prerequisites you would like, lets actually install this! This installation is based on Linux systems, yet will work on both MacOSX and Windows with their respective commands |
| 70 | + |
| 71 | +### Get the Source & Install Dependencies |
| 72 | + |
| 73 | +You can get the source from the releases |
| 74 | + |
| 75 | +```sh |
| 76 | +wget <RELEASE TAR BALL> |
| 77 | +tar -xvf <REALASE> |
| 78 | +cd <REALASE> |
| 79 | +npm i |
| 80 | +``` |
| 81 | + |
| 82 | +### Configuration Options |
| 83 | + |
| 84 | +Every single configuration option will be listed here |
| 85 | + |
| 86 | +#### Upload |
| 87 | + |
| 88 | +**Config Property:** `upload` |
| 89 | + |
| 90 | +| Config Property | Type | Description / Expected Values | |
| 91 | +|---------------------|---------|--------------------------------------------------------------| |
| 92 | +| `upload.fileLength` | integer | how long the random id for a file should be | |
| 93 | +| `upload.tempDir` | string | temporary directory, files are stored here and then deleted. | |
| 94 | +| `upload.uploadDir` | string | upload directory (where all uploads are stored) | |
| 95 | + |
| 96 | +#### Site Settings |
| 97 | + |
| 98 | +**Config Property:** `site` |
| 99 | + |
| 100 | +| Config Property | Type | Description / Expected Values | |
| 101 | +|-----------------|---------|--------------------------------------------------------| |
| 102 | +| `site.protocol` | integer | protocol (http or https) | |
| 103 | +| `site.domain` | string | domain of server (ex. `localhost:8080`, `example.com`) | |
| 104 | + |
| 105 | +#### Administrator User |
| 106 | + |
| 107 | +**Config Property:** `administrator` |
| 108 | + |
| 109 | +| Config Property | Type | Description / Expected Values | |
| 110 | +|-------------------------------|--------|----------------------------------------------------------------------------------------------------------| |
| 111 | +| `administrator.password` | string | password of administrator user (NOT RECOMENDED to use administrator user, set this to a SECURE password) | |
| 112 | +| `administrator.authorization` | string | authorization token that could be used for uploading (NOT RECOMENDED, set this to a SECURE master token) | |
| 113 | + |
| 114 | +#### Database Configuration |
| 115 | + |
| 116 | +**Config Property:** `orm` |
| 117 | + |
| 118 | +| Config Property | Type | Description / Expected Values | |
| 119 | +|-------------------|----------|------------------------------------------------------| |
| 120 | +| `orm.type` | string | `mariadb`, `mysql`, `postgres`, `cockroach`, `mssql` | |
| 121 | +| `orm.host` | string | `localhost` or different IP | |
| 122 | +| `orm.port` | integer | `5432` or different pot | |
| 123 | +| `orm.username` | string | username | |
| 124 | +| `orm.password` | string | password | |
| 125 | +| `orm.database` | string | database to use | |
| 126 | +| `orm.synchronize` | boolean | synchronize database to database, or not | |
| 127 | +| `orm.logging` | boolean | log all queries | |
| 128 | +| `orm.entities` | string[] | entity paths (should not be edited, and should be `["out/src/entities/**/*.js"]`) | |
| 129 | + |
| 130 | +#### Session Secret |
| 131 | + |
| 132 | +**Config Property:** `sessionSecret` |
| 133 | + |
| 134 | +A Random string of characters (anything) |
| 135 | + |
| 136 | +#### Port |
| 137 | + |
| 138 | +**Config Property:** `port` |
| 139 | + |
| 140 | +Port to run the webserver on |
| 141 | + |
| 142 | +### Example Config |
| 143 | + |
| 144 | +```json |
| 145 | +{ |
| 146 | + "upload": { |
| 147 | + "fileLength": 6, |
| 148 | + "tempDir": "./temp", |
| 149 | + "uploadDir": "./uploads" |
| 150 | + }, |
| 151 | + "site": { |
| 152 | + "protocol": "http", |
| 153 | + "domain": "localhost:8000" |
| 154 | + }, |
| 155 | + "administrator": { |
| 156 | + "password": "1234", |
| 157 | + "authorization": "Administrator master" |
| 158 | + }, |
| 159 | + "orm": { |
| 160 | + "type": "postgres", |
| 161 | + "host": "localhost", |
| 162 | + "port": 5432, |
| 163 | + "username": "postgres", |
| 164 | + "password": "password", |
| 165 | + "database": "typex", |
| 166 | + "synchronize": true, |
| 167 | + "logging": false, |
| 168 | + "entities": [ |
| 169 | + "out/src/entities/**/*.js" |
| 170 | + ] |
| 171 | + }, |
| 172 | + "sessionSecret": "aoshfyujfnbyurkjh53748uyfhn", |
| 173 | + "port": 8000 |
| 174 | +} |
| 175 | +``` |
| 176 | + |
| 177 | +### Compiling Typescript for running |
| 178 | + |
| 179 | +Compile the Typescript code before running the code, or you can run it with `ts-node` which is not recommended. ***MAKE SURE YOU ARE IN THE PROJECT DIR!*** |
| 180 | + |
| 181 | +```sh |
| 182 | +tsc -p . |
| 183 | +``` |
| 184 | + |
| 185 | +### Running Compiled Source |
| 186 | + |
| 187 | +Run the webserver by running |
| 188 | + |
| 189 | +```sh |
| 190 | +node out/src |
| 191 | +``` |
0 commit comments