Skip to content

Commit

Permalink
chore: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
beeman committed Aug 8, 2023
0 parents commit 1929c5a
Show file tree
Hide file tree
Showing 529 changed files with 28,844 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
node_modules
tmp
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
33 changes: 33 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# API Url
API_URL=http://localhost:3000/api
# Enable login with Discord
AUTH_DISCORD_ENABLED=true
# Enable login with password
AUTH_PASSWORD_ENABLED=true
# Enable user registration
AUTH_REGISTER_ENABLED=true
# Domains to allow cookies for (comma-separated)
COOKIE_DOMAINS=localhost,127.0.0.1
# URL of the database to connect to
DATABASE_URL="postgresql://pubkeystack:pubkeystack@localhost:5432/pubkeystack?schema=public"
# Enable database provisioning
DATABASE_PROVISION=true
# Enable database reset on each startup
DATABASE_RESET=false
# Discord Admin IDs (comma-separated)
DISCORD_ADMIN_IDS=
# Discord OAuth2 client ID and secret (required)
DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=
# Enable GraphQL Playground
GRAPHQL_PLAYGROUND=true
# JWT Secret (generate a random string with `openssl rand -hex 32`)
JWT_SECRET=
# Host to listen on
HOST=127.0.0.1
# Port to listen on
PORT=3000
# The URL of the Web UI, used to redirect to the Web UI after login.
# In a typical deployment, this is the same as the API_URL with the '/api' suffix removed (the default).
# This means you will probably only need to set this if you are running a local development setup.
WEB_URL=http://localhost:4200
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
libs/sdk/src/generated/*
tmp
42 changes: 42 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
},
"rules": {}
}
]
}
61 changes: 61 additions & 0 deletions .github/workflows/build-publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: build-publish-docker

on:
push:
branches:
- dev
- main
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker (dev)
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
if: github.ref == 'refs/heads/dev'
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push Docker (main)
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
if: github.ref == 'refs/heads/main'
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push Docker (Manual)
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
if: github.event_name == 'workflow_dispatch'
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
labels: ${{ steps.meta.outputs.labels }}
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
dist
tmp
/out-tsc

# dependencies
node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
.env

# System Files
.DS_Store
Thumbs.db
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
strict-peer-dependencies=false
auto-install-peers=true
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Add files here to ignore them from prettier formatting

/dist
/coverage
tmp
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"singleQuote": true,
"printWidth": 120,
"semi": false,
"trailingComma": "all",
"arrowParens": "always"
}
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"nrwl.angular-console",
"esbenp.prettier-vscode",
"firsttris.vscode-jest-runner",
"dbaeumer.vscode-eslint"
]
}
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
################################################################################
# BASE
# This is the stage that the other stages in this file are based on.
# - defines the Node version
# - set global configuration
# - set default work dir
################################################################################
FROM node:18.16-alpine as base

RUN apk add --update --no-cache git python3 make g++

ENV HUSKY=0

# Apply Yarn settings
RUN yarn config set cache-folder ~/.yarn \
&& yarn config set network-timeout 300000 -g \
&& yarn config set prefer-offline true

# Create app directory
WORKDIR /workspace

# Copy package.json and the lock file
COPY package.json yarn.lock /workspace/

# Install app dependencies
RUN yarn

# Copy source files
COPY . .

# Build apps
RUN yarn build

COPY prisma/schema.prisma /workspace/prisma/schema.prisma

# Expose default port
EXPOSE 3000

# Start server
CMD ["yarn", "start"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Bram Borggreve https://github.com/beeman

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# PubKey Stack

## Getting Started

### Prerequisites

- Node v18 or higher
- Yarn
- Docker

### Installation

Clone the repo and install dependencies:

```bash
git clone [email protected]:pubkeyapp/pubkey-stack.git
cd pubkey-stack
yarn
```

### Environment variables

Copy the `.env.example` file to `.env` and fill in the missing values.

```bash
cp .env.example .env
```

### Starting the services

You will need to start the database before starting the backend.

```bash
yarn dev:services
```

### Pushing the database schema

If you start from scratch, you will need to push the database schema to the database.

```bash
yarn prisma db push
```

Also, after each change to the schema in `prisma/schema.prisma`, you will need to run the above command again.

### Starting the API

```bash
yarn dev:api
```

### Starting the web ui

```bash
yarn dev:web
```

### Starting the SDK generator

```bash
yarn dev:sdk
```
Loading

0 comments on commit 1929c5a

Please sign in to comment.