diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..70065e9 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,23 @@ +# Contributing + +You can greatly support Plunk by contributing to this repository. + +Support can be asked in the `#contributions` channel of the [Plunk Discord server](https://useplunk.com/discord) + +### 1. Requirements + +- Docker needs to be [installed](https://docs.docker.com/engine/install/) on your system. + +### 2. Set your environment variables + +- Copy the `.env.example` files in the `api`, `dashboard` and `prisma` folder to `.env` in their respective folders. + +### 3. Start resources +- Run `yarn services:up` to start a local database and a local redis server. +- Run `yarn migrate` to apply the migrations to the database. +- Run `yarn build:shared` to build the shared package. + + +- Run `yarn dev:api` to start the API server. +- Run `yarn dev:dashboard` to start the dashboard server. + diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..7cc4950 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,15 @@ +version: '3' +services: + db: + image: postgres + ports: + - 55432:5432 + environment: + POSTGRES_PASSWORD: postgres + POSTGRES_USER: postgres + POSTGRES_DB: postgres + + redis: + image: redis + ports: + - 56379:6379 \ No newline at end of file diff --git a/package.json b/package.json index eff921e..75ed10f 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,7 @@ "private": true, "license": "MIT", "workspaces": { - "packages": [ - "packages/*" - ] + "packages": ["packages/*"] }, "engines": { "npm": ">=6.14.x", @@ -33,6 +31,8 @@ "preinstall": "node tools/preinstall.js", "migrate": "prisma migrate dev", "migrate:deploy": "prisma migrate deploy", - "generate": "prisma generate" + "generate": "prisma generate", + "services:up": "docker compose -f docker-compose.dev.yml up -d", + "services:down": "docker compose -f docker-compose.dev.yml down" } } diff --git a/packages/api/src/app.ts b/packages/api/src/app.ts index 43093ac..e53a767 100644 --- a/packages/api/src/app.ts +++ b/packages/api/src/app.ts @@ -10,7 +10,7 @@ import { type NextFunction, type Request, type Response, json } from "express"; import helmet from "helmet"; import morgan from "morgan"; import signale from "signale"; -import { API_URI, NODE_ENV } from "./app/constants"; +import { APP_URI, NODE_ENV } from "./app/constants"; import { task } from "./app/cron"; import { Auth } from "./controllers/Auth"; import { Identities } from "./controllers/Identities"; @@ -53,7 +53,7 @@ const server = new (class extends Server { this.app.use( cors({ - origin: [API_URI], + origin: [APP_URI], credentials: true, }), ); diff --git a/packages/api/src/app/constants.ts b/packages/api/src/app/constants.ts index fcbddca..0a9660a 100644 --- a/packages/api/src/app/constants.ts +++ b/packages/api/src/app/constants.ts @@ -29,7 +29,7 @@ export const NODE_ENV = validateEnv<"development" | "production">( export const REDIS_URL = validateEnv("REDIS_URL"); // URLs -export const API_URI = validateEnv("API_URI", "http://localhost:8080"); +export const API_URI = validateEnv("API_URI", "http://localhost:4000"); export const APP_URI = validateEnv("APP_URI", "http://localhost:3000"); // AWS diff --git a/prisma/.env.example b/prisma/.env.example index 335dc4e..ee7f048 100644 --- a/prisma/.env.example +++ b/prisma/.env.example @@ -1 +1 @@ -DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres \ No newline at end of file +DATABASE_URL=postgresql://postgres:postgres@localhost:55432/postgres \ No newline at end of file