Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: commune-forum #179

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions apps/commune-forum/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import baseConfig, { restrictEnvAccess } from "@commune-ts/eslint-config/base";
import nextjsConfig from "@commune-ts/eslint-config/nextjs";
import reactConfig from "@commune-ts/eslint-config/react";

/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: [".next/**"],
},
...baseConfig,
...reactConfig,
...nextjsConfig,
...restrictEnvAccess,
];
5 changes: 5 additions & 0 deletions apps/commune-forum/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
24 changes: 24 additions & 0 deletions apps/commune-forum/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { fileURLToPath } from "url";
import createJiti from "jiti";

// Import env files to validate at build time. Use jiti so we can load .ts files in here.
createJiti(fileURLToPath(import.meta.url))("./src/env");

/** @type {import("next").NextConfig} */
const config = {
reactStrictMode: true,

/** Enables hot reloading for local packages without a build step */
transpilePackages: [
"@commune-ts/api",
"@commune-ts/db",
"@commune-ts/ui",
// "@commune-ts/validators",
],

/** We already do linting and typechecking as separate tasks in CI */
eslint: { ignoreDuringBuilds: true },
typescript: { ignoreBuildErrors: true },
};

export default config;
50 changes: 50 additions & 0 deletions apps/commune-forum/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "commune-forum",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "next build",
"dev": "next dev --port 3009",
"lint": "eslint",
"start": "next start",
"type-check": "tsc --noEmit"
},
"dependencies": {
"@commune-ts/api": "workspace:*",
"@commune-ts/db": "workspace:*",
"@commune-ts/providers": "workspace:*",
"@commune-ts/types": "workspace:*",
"@commune-ts/ui": "workspace:*",
"@commune-ts/utils": "workspace:*",
"@commune-ts/wallet": "workspace:*",
"@heroicons/react": "catalog:",
"@t3-oss/env-nextjs": "catalog:",
"@tanstack/react-query": "catalog:",
"@trpc/client": "catalog:",
"@trpc/react-query": "catalog:",
"@trpc/server": "catalog:",
"@uiw/react-markdown-preview": "^5.1.1",
"luxon": "^3.5.0",
"next": "catalog:",
"react": "catalog:react18",
"react-dom": "catalog:react18",
"rustie": "catalog:",
"tsafe": "catalog:",
"zod": "catalog:"
},
"devDependencies": {
"@commune-ts/eslint-config": "workspace:*",
"@commune-ts/tailwind-config": "workspace:*",
"@commune-ts/tsconfig": "workspace:*",
"@next/eslint-plugin-next": "catalog:",
"@types/luxon": "^3.4.2",
"@types/node": "catalog:",
"@types/react": "catalog:react18",
"@types/react-dom": "catalog:react18",
"jiti": "catalog:",
"postcss": "catalog:",
"tailwindcss": "catalog:",
"typescript": "catalog:"
}
}
5 changes: 5 additions & 0 deletions apps/commune-forum/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
plugins: {
tailwindcss: {},
},
};
10 changes: 10 additions & 0 deletions apps/commune-forum/public/bg-pattern.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions apps/commune-forum/public/discord-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions apps/commune-forum/public/docs-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/commune-forum/public/favicon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions apps/commune-forum/public/github-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions apps/commune-forum/public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions apps/commune-forum/public/send-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions apps/commune-forum/public/stake-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions apps/commune-forum/public/telegram-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions apps/commune-forum/public/unstake-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions apps/commune-forum/public/wallet-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions apps/commune-forum/public/x-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions apps/commune-forum/src/app/api/trpc/[trpc]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";

import { appRouter, createTRPCContext } from "@commune-ts/api";

import { env } from "~/env";

/**
* Configure basic CORS headers
*/
const setCorsHeaders = (res: Response) => {
res.headers.set("Access-Control-Allow-Origin", "*");
res.headers.set("Access-Control-Request-Method", "*");
res.headers.set("Access-Control-Allow-Methods", "OPTIONS, GET, POST");
res.headers.set("Access-Control-Allow-Headers", "*");
};

export const OPTIONS = () => {
const response = new Response(null, {
status: 204,
});
setCorsHeaders(response);
return response;
};

const handler = async (req: Request) => {
const response = await fetchRequestHandler({
endpoint: "/api/trpc",
router: appRouter,
req,
createContext: () =>
createTRPCContext({
session: null,
headers: req.headers,
jwtSecret: env.JWT_SECRET,
authOrigin: env.AUTH_ORIGIN,
}),
onError({ error, path }) {
console.error(`>>> tRPC Error on '${path}'`, error);
},
});

setCorsHeaders(response);
return response;
};

export { handler as GET, handler as POST };
Loading