forked from tsai/budibase
51 changed files with 341 additions and 81 deletions
@ -0,0 +1,28 @@ |
|||
version: "3.8" |
|||
services: |
|||
db: |
|||
container_name: postgres |
|||
image: postgres |
|||
restart: always |
|||
environment: |
|||
POSTGRES_USER: root |
|||
POSTGRES_PASSWORD: root |
|||
POSTGRES_DB: main |
|||
ports: |
|||
- "5432:5432" |
|||
volumes: |
|||
#- pg_data:/var/lib/postgresql/data/ |
|||
- ./init.sql:/docker-entrypoint-initdb.d/init.sql |
|||
|
|||
pgadmin: |
|||
container_name: pgadmin-pg |
|||
image: dpage/pgadmin4 |
|||
restart: always |
|||
environment: |
|||
PGADMIN_DEFAULT_EMAIL: root@root.com |
|||
PGADMIN_DEFAULT_PASSWORD: root |
|||
ports: |
|||
- "5050:80" |
|||
|
|||
#volumes: |
|||
# pg_data: |
|||
@ -0,0 +1,41 @@ |
|||
SELECT 'CREATE DATABASE main' |
|||
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'main')\gexec |
|||
|
|||
CREATE TABLE categories |
|||
( |
|||
name text COLLATE pg_catalog."default", |
|||
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ), |
|||
CONSTRAINT categories_pkey PRIMARY KEY (id) |
|||
); |
|||
|
|||
CREATE TABLE customers |
|||
( |
|||
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ), |
|||
name text COLLATE pg_catalog."default", |
|||
email text COLLATE pg_catalog."default", |
|||
age integer, |
|||
"dateOfBirth" date, |
|||
CONSTRAINT customers_pkey PRIMARY KEY (id) |
|||
); |
|||
|
|||
CREATE TABLE customer_category |
|||
( |
|||
customer_id integer, |
|||
category_id integer, |
|||
notes text COLLATE pg_catalog."default", |
|||
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ), |
|||
CONSTRAINT "Category" FOREIGN KEY (category_id) |
|||
REFERENCES public.categories (id) MATCH SIMPLE |
|||
ON UPDATE NO ACTION |
|||
ON DELETE NO ACTION |
|||
NOT VALID, |
|||
CONSTRAINT "Customer" FOREIGN KEY (customer_id) |
|||
REFERENCES public.customers (id) MATCH SIMPLE |
|||
ON UPDATE NO ACTION |
|||
ON DELETE NO ACTION |
|||
NOT VALID |
|||
); |
|||
|
|||
|
|||
INSERT INTO customers (name, email, age) VALUES ('Mike', 'mike@mike.com', 30); |
|||
INSERT INTO categories (name) VALUES ('Books'); |
|||
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
docker-compose down |
|||
docker volume prune -f |
|||
@ -0,0 +1,22 @@ |
|||
#!/usr/bin/env node
|
|||
const updateDotEnv = require("update-dotenv") |
|||
|
|||
const arg = process.argv.slice(2)[0] |
|||
|
|||
/** |
|||
* For testing multi tenancy sub domains locally. |
|||
* |
|||
* Relies on an entry in /etc/hosts e.g: |
|||
* |
|||
* 127.0.0.1 local.com |
|||
* |
|||
* and an entry for each tenant you wish to test locally e.g: |
|||
* |
|||
* 127.0.0.1 t1.local.com |
|||
* 127.0.0.1 t2.local.com |
|||
*/ |
|||
updateDotEnv({ |
|||
ACCOUNT_PORTAL_URL: |
|||
arg === "enable" ? "http://local.com:10001" : "http://localhost:10001", |
|||
COOKIE_DOMAIN: arg === "enable" ? ".local.com" : "", |
|||
}).then(() => console.log("Updated worker!")) |
|||
@ -0,0 +1,24 @@ |
|||
#!/usr/bin/env node
|
|||
const updateDotEnv = require("update-dotenv") |
|||
|
|||
const arg = process.argv.slice(2)[0] |
|||
|
|||
/** |
|||
* For testing multi tenancy sub domains locally. |
|||
* |
|||
* Relies on an entry in /etc/hosts e.g: |
|||
* |
|||
* 127.0.0.1 local.com |
|||
* |
|||
* and an entry for each tenant you wish to test locally e.g: |
|||
* |
|||
* 127.0.0.1 t1.local.com |
|||
* 127.0.0.1 t2.local.com |
|||
*/ |
|||
updateDotEnv({ |
|||
ACCOUNT_PORTAL_URL: |
|||
arg === "enable" ? "http://local.com:10001" : "http://localhost:10001", |
|||
COOKIE_DOMAIN: arg === "enable" ? ".local.com" : "", |
|||
PLATFORM_URL: |
|||
arg === "enable" ? "http://local.com:10000" : "http://localhost:10000", |
|||
}).then(() => console.log("Updated worker!")) |
|||
@ -0,0 +1,17 @@ |
|||
const env = require("../environment") |
|||
const { Headers } = require("@budibase/auth").constants |
|||
|
|||
/** |
|||
* This is a restricted endpoint in the cloud. |
|||
* Ensure that the correct API key has been supplied. |
|||
*/ |
|||
module.exports = async (ctx, next) => { |
|||
if (!env.SELF_HOSTED) { |
|||
const apiKey = ctx.request.headers[Headers.API_KEY] |
|||
if (apiKey !== env.INTERNAL_API_KEY) { |
|||
ctx.throw(403, "Unauthorized") |
|||
} |
|||
} |
|||
|
|||
return next() |
|||
} |
|||
Loading…
Reference in new issue