Skip to content

Commit

Permalink
feat: docs.page 2024 refresh (#359)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Diarmid <[email protected]>
  • Loading branch information
Ehesp and Salakar authored Aug 29, 2024
1 parent f6466a0 commit 5c8a5d6
Show file tree
Hide file tree
Showing 294 changed files with 11,498 additions and 26,995 deletions.
9 changes: 0 additions & 9 deletions .eslintignore

This file was deleted.

40 changes: 0 additions & 40 deletions .eslintrc

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Code quality

on:
pull_request:

jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Biome
uses: biomejs/setup-biome@v2
with:
version: latest
- name: Run Biome
run: biome ci .
22 changes: 0 additions & 22 deletions .github/workflows/website.yaml

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# We ignore this since we're using Bun for workspace management, and some environments
# will detect this file and use npm instead of bun.
package-lock.json

# dependencies
node_modules
/.pnp
Expand Down
8 changes: 0 additions & 8 deletions .prettierignore

This file was deleted.

10 changes: 0 additions & 10 deletions .prettierrc.json

This file was deleted.

1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
26 changes: 26 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Contributing

This repository uses [Bun](https://bun.sh/) for workspace and dependency management. To get started, run the following commands:

```bash
bun install
```

The repository is structured as follows:

- `api`: The API server which is served via `https://api.docs.page`. This is an express application which handles tasks such as fetching content from GitHub and markdown parsing.
- `og`: A Next.js application which serves the Open Graph images for documentation pages.
- `website`: A Remix application which serves the main `https://docs.page` website, and the documentation rendering for each repository.
- `packages/cli`: A CLI for running various commands and scripts for initialization, checking etc. Used locally and on CI environments.

## Running docs.page

Generally, you'll want to interface with the website and api. To run these concurrently, you can use the following command:

```bash
bun dev
```

This will start the website on `http://localhost:5173` and the api on `http://localhost:8080`.

> The API requires a `GITHUB_APP_ID` and `GITHUB_APP_PRIVATE_KEY` to be set in your environment. These are used to authenticate with the GitHub API. You can create a GitHub App in your GitHub account settings.
9 changes: 5 additions & 4 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM oven/bun:1.0.29
FROM oven/bun:1.1.22

ARG BUILD_SHA=default_value
ENV __BUILD_SHA=$BUILD_SHA

WORKDIR /opt/app
COPY . /opt/app
RUN cd /opt/app && bun install --frozen-lockfile --production
COPY . .
RUN bun install --frozen-lockfile --production

WORKDIR /opt/app/api

WORKDIR /opt/app
CMD ["bun","run","start"]
Binary file removed api/bun.lockb
Binary file not shown.
18 changes: 12 additions & 6 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
"license": "MIT",
"dependencies": {
"@code-hike/mdx": "0.7.2",
"@docs.page/cli": "workspace:*",
"@mdx-js/mdx": "2.2.1",
"@octokit/graphql": "5.0.0",
"@types/cors": "^2.8.12",
"@octokit/webhooks": "^13.2.7",
"@shikijs/transformers": "1.12.1",
"@shikijs/twoslash": "^1.12.1",
"@types/express": "^4.17.13",
"@types/morgan": "^1.9.3",
"@types/node": "^18.0.0",
"a2a": "^0.2.0",
"camelcase": "7.0.0",
"cors": "2.8.5",
"dotenv": "16.0.1",
"esbuild": "0.14.47",
"express": "4.18.1",
Expand All @@ -26,21 +28,23 @@
"hast-util-parse-selector": "3.1.0",
"is-badge": "^2.1.0",
"js-yaml": "4.1.0",
"jszip": "^3.10.1",
"lodash.get": "^4.4.2",
"mdx-bundler": "9.0.1",
"morgan": "1.10.0",
"node-fetch": "3.2.6",
"pm2": "5.3.0",
"probot": "12.2.8",
"octokit": "^4.0.2",
"rehype-accessible-emojis": "0.3.2",
"rehype-katex": "6.0.2",
"rehype-slug": "5.0.1",
"remark-comment": "1.0.0",
"remark-gfm": "3.0.1",
"remark-math": "5.1.1",
"remark-parse": "10.0.1",
"shiki": "1.1.7",
"shiki": "1.12.1",
"unist-util-visit": "4.1.0",
"zod": "3.22.4",
"zod-to-json-schema": "^3.23.1",
"zod-validation-error": "0.2.2"
},
"scripts": {
Expand All @@ -49,9 +53,11 @@
},
"devDependencies": {
"@octokit/webhooks-types": "^6.2.4",
"@types/bun": "^1.1.6",
"@types/js-yaml": "^4.0.5",
"@types/lodash.get": "^4.4.9",
"rollup": "3.9.1",
"ts-node": "^10.8.1",
"typescript": "4.7.4"
"typescript": "5.5.3"
}
}
35 changes: 16 additions & 19 deletions api/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
import express, { Router, text } from 'express';
import morgan from 'morgan';
import cors from 'cors';
import { config } from 'dotenv';
import express, { Router, text } from "express";
import morgan from "morgan";

import bundle from './routes/bundle';
import preview from './routes/preview';
import mdx from './routes/mdx';
import probot from './probot';
import { notFound } from './res';
import { notFound } from "./res";
import bundle from "./routes/bundle";
import preview from "./routes/preview";
import schema from "./routes/schema";
import githubWebhook from "./routes/webhooks.github";

config();
import { ENV } from "./env";

const PORT = process.env.PORT || 8080;
const PORT = ENV.PORT;
const app = express();
app.use(text());
app.use(cors());
app.use(morgan('dev'));
app.use(morgan("dev"));
app.use(express.json());
app.use(
express.urlencoded({
extended: true,
}),
);
app.use(probot);

const router = Router();
router.get('/status', (_, res) => res.status(200).send('OK'));
router.post('/preview', preview);
router.get('/bundle', bundle);
router.post('/mdx', mdx);
router.all('*', (_, res) => notFound(res));
router.get("/status", (_, res) => res.status(200).send("OK"));
router.get("/schema.json", schema);
router.post("/preview", preview);
router.get("/bundle", bundle);
router.post("/webhooks/github", githubWebhook);
router.all("*", (_, res) => notFound(res));
app.use(router);

app.listen(PORT, () => {
Expand Down
23 changes: 23 additions & 0 deletions api/src/bundler/error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export class BundlerError extends Error {
code: number;
name: string;
source?: string;

constructor({
code,
name,
message,
source,
}: {
code: number;
name: string;
message: string;
source?: string;
}) {
super(message);
this.code = code;
this.name = name;
this.message = message;
this.source = source;
}
}
Loading

0 comments on commit 5c8a5d6

Please sign in to comment.