Skip to content
This repository was archived by the owner on Nov 21, 2024. It is now read-only.

Commit edec76b

Browse files
committed
add readme and init script
1 parent 07dc139 commit edec76b

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Installation
2+
3+
```
4+
# Clone and install deps
5+
git clone https://github.com/anonymousthing/paradb-api.git
6+
cd paradb-api
7+
yarn
8+
9+
# Install and start postgres
10+
sudo apt install postgresql
11+
sudo service postgresql start
12+
13+
# Create postgres user for yourself
14+
sudo -u postgres createuser --interactive --pwprompt
15+
16+
# Edit .env to fill out your username and password!
17+
18+
# Create db and instantiate schema
19+
createdb paradb
20+
db/init.sh
21+
22+
# Create symlink from "fe" to the actual frontend dist directory
23+
ln -s /path/to/obento2/dist/paradb fe
24+
25+
# Start server
26+
yarn start
27+
```

db/init.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
HERE="$(realpath "${0}" | xargs dirname)"
4+
5+
psql -d paradb -f "$HERE/init.sql"
6+
psql -d paradb -f "$HERE/fake_data.sql"

db/init.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DROP TABLE maps;
1+
DROP TABLE IF EXISTS maps;
22
CREATE TABLE maps (
33
id varchar(16) not null,
44
title varchar(256) not null,
@@ -10,7 +10,7 @@ CREATE TABLE maps (
1010
album_art text
1111
);
1212

13-
DROP TABLE complexities;
13+
DROP TABLE IF EXISTS complexities;
1414
CREATE TABLE complexities (
1515
map_id varchar(32) not null,
1616
complexity int not null,

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
require('dotenv').config();
22

3+
if (process.env.PGUSER == '' && process.env.PGPASSWORD == '') {
4+
console.error('PGUSER and PGPASSWORD have been left blank in .env -- intentional?');
5+
}
6+
37
import express from 'express';
48
import path from 'path';
59
import apiRouter from './api';

0 commit comments

Comments
 (0)