mirror of
https://github.com/psforever/PSFPortal.git
synced 2026-07-13 15:34:39 +00:00
Add schema and readme
This commit is contained in:
parent
20a3bc3a20
commit
d36fbbde9a
3 changed files with 131 additions and 1 deletions
53
README.md
Normal file
53
README.md
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
# PSFPortal
|
||||||
|
An API + webapp to manage PSForever accounts, characters, and servers.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
* User registration, login, and sessions
|
||||||
|
* Home page
|
||||||
|
* Admin management
|
||||||
|
|
||||||
|
### Upcoming Features
|
||||||
|
* Email verification + captcha
|
||||||
|
* Changing passwords
|
||||||
|
* WorldServer mangement
|
||||||
|
|
||||||
|
## Developing
|
||||||
|
This requires a relatively modern version of Node that supports async/await and ES6 (v13.x+). Tested using v13.3.0. You may still get `(node:61412) ExperimentalWarning: The ESM module loader is experimental.`. Ignore this as ESM is essentially stable in recent versions.
|
||||||
|
|
||||||
|
First download and install the Node dependencies:
|
||||||
|
```
|
||||||
|
git clone https://github.com/psforever/PSFPortal
|
||||||
|
cd PSFPortal/
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
Next, install PostgreSQL from your package manager.
|
||||||
|
Load the DB schema into a fresh database (in this case named psforever):
|
||||||
|
|
||||||
|
```
|
||||||
|
psql psforever < db/schema.sql
|
||||||
|
```
|
||||||
|
|
||||||
|
Before running, you will need to create a `.env` file like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
PGUSER=...
|
||||||
|
PGHOST=...
|
||||||
|
PGPASSWORD=...
|
||||||
|
PGDATABASE=...
|
||||||
|
PGPORT=...
|
||||||
|
COOKIE_SECRET=<make this very long and random>
|
||||||
|
```
|
||||||
|
|
||||||
|
Never share/release/commit your `.env` file.
|
||||||
|
|
||||||
|
Finally, run the following commands:
|
||||||
|
```
|
||||||
|
# Will start the frontend Webpack builder with hot reload
|
||||||
|
npm run dev
|
||||||
|
# And in another terminal, will start the backend server
|
||||||
|
npm run dev-server
|
||||||
|
```
|
||||||
|
|
||||||
|
## Production Running/Building
|
||||||
|
Follow the same steps as above, but instead run `npm run production` at the very end.
|
||||||
77
db/schema.sql
Normal file
77
db/schema.sql
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
CREATE TABLE IF NOT EXISTS "accounts" (
|
||||||
|
"id" SERIAL PRIMARY KEY NOT NULL,
|
||||||
|
"username" VARCHAR(64) NOT NULL UNIQUE,
|
||||||
|
"passhash" VARCHAR(64) NOT NULL,
|
||||||
|
"created" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"last_modified" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"inactive" BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
"gm" BOOLEAN NOT NULL DEFAULT FALSE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "characters" (
|
||||||
|
"id" SERIAL PRIMARY KEY NOT NULL,
|
||||||
|
"name" VARCHAR(64) NOT NULL,
|
||||||
|
"account_id" INT NOT NULL REFERENCES accounts (id),
|
||||||
|
"faction_id" INT NOT NULL,
|
||||||
|
"gender_id" INT NOT NULL,
|
||||||
|
"head_id" INT NOT NULL,
|
||||||
|
"voice_id" INT NOT NULL,
|
||||||
|
"created" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"last_login" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"last_modified" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"deleted" BOOLEAN NOT NULL DEFAULT FALSE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "logins" (
|
||||||
|
"id" SERIAL PRIMARY KEY NOT NULL,
|
||||||
|
"account_id" INT NOT NULL REFERENCES accounts (id),
|
||||||
|
"login_time" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"ip_address" VARCHAR(32) NOT NULL,
|
||||||
|
"canonical_hostname" VARCHAR(132) NOT NULL,
|
||||||
|
"hostname" VARCHAR(132) NOT NULL,
|
||||||
|
"port" INT NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "loadouts" (
|
||||||
|
"id" SERIAL PRIMARY KEY NOT NULL,
|
||||||
|
"characters_id" INT NOT NULL REFERENCES characters (id),
|
||||||
|
"loadout_number" INT NOT NULL,
|
||||||
|
"exosuit_id" INT NOT NULL,
|
||||||
|
"name" VARCHAR(36) NOT NULL,
|
||||||
|
"items" TEXT NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "lockers" (
|
||||||
|
"id" SERIAL PRIMARY KEY NOT NULL,
|
||||||
|
"characters_id" INT NOT NULL REFERENCES characters (id),
|
||||||
|
"items" TEXT NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE "session" (
|
||||||
|
"sid" varchar NOT NULL COLLATE "default",
|
||||||
|
"sess" json NOT NULL,
|
||||||
|
"expire" timestamp(6) NOT NULL
|
||||||
|
)
|
||||||
|
WITH (OIDS=FALSE);
|
||||||
|
ALTER TABLE "session" ADD CONSTRAINT "session_pkey" PRIMARY KEY ("sid") NOT DEFERRABLE INITIALLY IMMEDIATE;
|
||||||
|
|
||||||
|
--These triggers update the last_modified timestamp column when a table is updated
|
||||||
|
CREATE OR REPLACE FUNCTION fn_set_last_modified_timestamp()
|
||||||
|
RETURNS TRIGGER AS $$
|
||||||
|
BEGIN
|
||||||
|
NEW.last_modified = NOW();
|
||||||
|
RETURN NEW;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
DROP TRIGGER IF EXISTS trigger_accounts_set_last_modified on accounts;
|
||||||
|
CREATE TRIGGER trigger_accounts_set_last_modified
|
||||||
|
BEFORE UPDATE ON accounts
|
||||||
|
FOR EACH ROW
|
||||||
|
EXECUTE PROCEDURE fn_set_last_modified_timestamp();
|
||||||
|
|
||||||
|
DROP TRIGGER IF EXISTS trigger_players_set_last_modified on characters;
|
||||||
|
CREATE TRIGGER trigger_players_set_last_modified
|
||||||
|
BEFORE UPDATE ON characters
|
||||||
|
FOR EACH ROW
|
||||||
|
EXECUTE PROCEDURE fn_set_last_modified_timestamp();
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "psfwebui",
|
"name": "psfportal",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "A web interface to PSForever servers.",
|
"description": "A web interface to PSForever servers.",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue