Skip to content

Commit

Permalink
Upgrade stack packages (#42)
Browse files Browse the repository at this point in the history
* refactor: totally empty sample project

* refactor: everything

* feat: all sorts of things

* fix: ts bugs

* fix: ready for live db

* fix: re add missing command args

* refactor: update everything

* refactor: add basic layouts

* refactor: add guilds

* refactor: add index page

* refactor: add commands page

* refactor: add premium page

* refactor: add .github dir

* refactor: add dockerfile

* ci: less restrictive tsconfig

* refactor: update/insert/disconnect on signin

* ci: update Dockerfile

* refactor: undo git merge bs
  • Loading branch information
yoshirahh authored Feb 20, 2022
1 parent 99ff8c5 commit cd92e78
Show file tree
Hide file tree
Showing 110 changed files with 3,362 additions and 3,778 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["next/babel"],
"plugins": ["superjson-next"]
}
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 4,
"useTabs": false
}
48 changes: 23 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
# Install dependencies only when needed
FROM node:16.13.1-alpine AS deps
FROM node:16-buster-slim AS base
RUN apt-get update && apt-get install libssl-dev ca-certificates -y
WORKDIR /app

WORKDIR /opt/app
COPY package.json yarn.lock ./
COPY prisma prisma
RUN yarn install --frozen-lockfile

# Rebuild the source code only when needed
# This is where because may be the case that you would try
# to build the app based on some `X_TAG` in my case (Git commit hash)
# but the code hasn't changed.
FROM node:16.13.1-alpine AS builder
FROM base as build
RUN export NODE_ENV=production
RUN yarn

ENV NODE_ENV=production
WORKDIR /opt/app
COPY . .
COPY --from=deps /opt/app/node_modules ./node_modules
COPY --from=deps /opt/app/prisma ./prisma
RUN yarn run prisma:generate
RUN yarn build

# Production image, copy all the files and run next
FROM node:16.13.1-alpine AS runner

ARG X_TAG
WORKDIR /opt/app
ENV NODE_ENV=production
# COPY --from=builder /opt/app/next.config.js ./
COPY --from=builder /opt/app/public ./public
COPY --from=builder /opt/app/.next ./.next
COPY --from=builder /opt/app/node_modules ./node_modules
CMD ["node_modules/.bin/next", "start"]
FROM base as prod-build

RUN yarn install --production
COPY prisma prisma
RUN yarn run prisma:generate
RUN cp -R node_modules prod_node_modules

FROM base as prod

COPY --from=prod-build /app/prod_node_modules /app/node_modules
COPY --from=build /app/.next /app/.next
COPY --from=build /app/public /app/public
COPY --from=build /app/prisma /app/prisma

EXPOSE 3000
CMD ["yarn", "start"]
160 changes: 87 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,88 @@
# AutoMute.us Web Application

## Getting Started

To run this application in development:

```bash
yarn install
yarn dev
```

To run this application in production:

```bash
yarn install
yarn build
yarn start <PORT> # e.g. yarn start 8080
```

## Environment Setup

To properly run this application, you need the following services and files:

- A PostgreSQL database with the schema defined in `prisma/schema.prisma` (TODO: have an `.sql` structure file here)
- A dot-env file configured in the root folder as `.env` containing the variables as outlined in `.env.sample`:

```bash
DISCORD_CLIENT_ID= # the Discord Client ID (https://discord.com/developers)
DISCORD_CLIENT_SECRET= # the Discord Client Secret (https://discord.com/developers)
DATABASE_URL= # db connection string (i.e. postgres://<user>:<password>@<host>:<port>/<db>)
NEXTAUTH_URL= # canonical URL of deploy instance (i.e. https://automute.us)
SECRET= # an encryption secret for any JSON Web Tokens (local sign-in sessions)
```

Additionally, you'll need to set up a valid callback URL in your Discord application registration (https://discord.com/developers) under "OAuth2" settings to match the pattern

```
<NEXTAUTH_URL>/api/auth/callback/discord
```

## Deployment

This application is deployed using Docker. To build and run this application:

```bash
docker build -t automuteus .
docker run --name automuteus -dp <PORT>:3000 automuteus:latest
```

You can stop and remove this application container with

```bash
docker stop automuteus
docker rm automuteus
```

**Note:** The name `automuteus` in the above commands can be substituted with any name you prefer.

## Planned Features

### General Features

- [x] **Discord sign-in**: sign in to the site with Discord OAuth2.

### Web Dashboard

The web dashboard will allow configuration and control of instances of the hosted AutoMuteUs bot.

- [ ] **Discord server invites**: invite bot with specific link to servers that the user has admin permissions on
- [ ] **Premium status checking**: check to see if a guild you're in has premium.
- [ ] **Settings management**: edit bot configuration online and have it save, per server
- [ ] Shareable settings: add ability to publish popular bot configs and share them
- [ ] **Stats and leaderboards**: view server stats and leaderboards in a more user-friendly manner than Discord embeds.
# AutoMute.us Web Application

## Getting Started

To run this application in development:

```bash
yarn install
yarn dev
```

To run this application in production:

```bash
yarn install
yarn build
yarn start <PORT> # e.g. yarn start 8080
```

## Environment Setup

To properly run this application, you need the following services and files:

- A PostgreSQL database with the schema defined in `prisma/schema.prisma` (TODO: have an `.sql` structure file here)
- A dot-env file configured in the root folder as `.env` containing the variables as outlined in `.env.sample`:

```bash
# JWT Secret
SECRET=

# NextAuth route base(s)
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_URL_INTERNAL=http://localhost:3000
NEXTAUTH_SECRET=

# Discord oAuth
DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=

# Prisma DB connections
DATABASE_URL=
#SHADOW_DATABASE_URL=

# AutoMuteUs stats
GALACTUS_API=http://localhost:5858/api

```

Additionally, you'll need to set up a valid callback URL in your Discord application registration (https://discord.com/developers) under "OAuth2" settings to match the pattern

```
<NEXTAUTH_URL>/api/auth/callback/discord
```

## Deployment

This application is deployed using Docker. To build and run this application:

```bash
docker build -t automuteus .
docker run --name automuteus -dp <PORT>:3000 automuteus:latest
```

You can stop and remove this application container with

```bash
docker stop automuteus
docker rm automuteus
```

**Note:** The name `automuteus` in the above commands can be substituted with any name you prefer.

## Planned Features

### General Features

- [x] **Discord sign-in**: sign in to the site with Discord OAuth2.

### Web Dashboard

The web dashboard will allow configuration and control of instances of the hosted AutoMuteUs bot.

- [ ] **Discord server invites**: invite bot with specific link to servers that the user has admin permissions on
- [ ] **Premium status checking**: check to see if a guild you're in has premium.
- [ ] **Settings management**: edit bot configuration online and have it save, per server
- [ ] Shareable settings: add ability to publish popular bot configs and share them
- [ ] **Stats and leaderboards**: view server stats and leaderboards in a more user-friendly manner than Discord embeds.
- [ ] Raw stats exports: export files (permissively) of game data so that people can create their own visualizations and metrics.
104 changes: 55 additions & 49 deletions components/commands/ArgTable.tsx
Original file line number Diff line number Diff line change
@@ -1,56 +1,62 @@
import { Table } from "react-bootstrap";
import { CommandArg } from "../../types/Command";

import * as AMUS from "../../utils/interfaces";

function ArgTable(props: {
cmd: string;
args: Array<AMUS.CommandArg>;
export default function ArgTable(props: {
cmd: string;
args: Array<CommandArg>;
}): React.ReactElement {
const { cmd, args } = props;
const { cmd, args } = props;

if (!args.length)
return (
<div className="text-muted">
<em>None</em>
</div>
);

if (!args.length)
return (
<div className="text-muted">
<em>None</em>
</div>
<Table
striped
borderless
variant="dark"
responsive
style={{ borderRadius: "5px" }}
>
<thead>
<tr>
<th style={{ width: "10%" }}>Name</th>
<th style={{ width: "10%" }}>Type</th>
<th style={{ width: "50%" }}>Description</th>
<th>Values</th>
</tr>
</thead>
<tbody>
{args.map((a) => (
<tr key={`${cmd}-arg-${a.name}`}>
<td className="text-monospace">{a.name}</td>
<td className="text-monospace">{a.type}</td>
<td>
{a.description.map((e, i) => (
<span key={"desc3-" + i}>{e}</span>
))}
</td>
<td>
{a.values ? (
a.values.map((v) => (
<code
key={`${cmd}-arg-${a.name}-${v}`}
className="me-2"
>
{v}
</code>
))
) : (
<span className="text-muted">-</span>
)}
</td>
</tr>
))}
</tbody>
</Table>
);

return (
<Table striped borderless variant="dark" responsive style={{borderRadius: "5px"}}>
<thead>
<tr>
<th style={{ width: "10%" }}>Name</th>
<th style={{ width: "10%" }}>Type</th>
<th style={{ width: "50%" }}>Description</th>
<th>Values</th>
</tr>
</thead>
<tbody>
{args.map((a) => (
<tr key={`${cmd}-arg-${a.name}`}>
<td className="text-monospace">{a.name}</td>
<td className="text-monospace">{a.type}</td>
<td>
{a.description.map((e, i) => (
<span key={"desc3-" + i}>{e}</span>
))}
</td>
<td>
{a.values ? (
a.values.map((v) => (
<code key={`${cmd}-arg-${a.name}-${v}`} className="mr-2">
{v}
</code>
))
) : (
<span className="text-muted">-</span>
)}
</td>
</tr>
))}
</tbody>
</Table>
);
}

export default ArgTable;
Loading

0 comments on commit cd92e78

Please sign in to comment.